The objective is to have numberOfSections variable in the controller and then dynamically generate these sections on the vf page with the same format. How can this be achieved?
Asked
Active
Viewed 568 times
2 Answers
0
You can use apex:dynamicComponent to accomplish this: Creating and Displaying Dynamic Components

codingangel
- 37
- 2
0
What have you tried so far, what doesn't work? Your question is very poor and unlikely to attract more answers.
Easiest is to have a list of items (not just a counter, a list) and iterate it with <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>

eyescream
- 18,088
- 2
- 34
- 46