如何在visualforce页面中动态生成章节?

问题描述 投票:0回答:1

VF Page with 3 sections

我们的目标是在控制器中拥有numberOfSections变量,然后在vf页面上以相同的格式动态生成这些部分。如何实现这个目标?

salesforce apex visualforce
1个回答
0
投票

你可以使用 apex:dynamicComponent 来实现。创建和显示动态组件


0
投票

到目前为止,你试过什么,有什么没用的?你的问题很差,不可能吸引更多的答案。

最简单的是有一个项目列表(不仅仅是一个计数器,一个列表),然后用它来迭代。<apex:repeat>.

public class Stack61357421 {
    public List<String> sectionTitles {get; private set;}

    public Stack61357421(){
        sectionTitles = new List<String>{'lorem', 'ipsum', 'dolor', 'sit', 'amet'};
    }
}

<apex:page controller="Stack61357421" tabStyle="Account">
<apex:pageBlock title="Hi stack">
    <apex:repeat value="{!sectionTitles}" var="title">
        <apex:pageBlockSection title="{!title}">
            content goes here
        </apex:pageBlockSection>
    </apex:repeat>
</apex:pageBlock>
</apex:page>

enter image description here

© www.soinside.com 2019 - 2024. All rights reserved.