function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
hemant ranahemant rana 

i want to repeat a pageblocksection in a vf page so that the title should change dynamically account to the values {get;set;} in controller

i want to repeat a pageblocksection in a vf page so that the title should change dynamically account to the values {get;set;} in controller.....
plz help.......

<apex:repeat values="DON'T KNOW WHAT TO PUT IN THIS PLACE">
<apex:pageBlockSection title="{!heading}">
            <Apex:repeat value="{!textvalues}" var="tv">
            {!tv}
            </Apex:repeat>
            </apex:pageBlockSection>
</repeat>
please help....
Sonam_SFDCSonam_SFDC
What is the value that you want to show as the heading of the pagebloacktable?

See apex:repeat should get its values from a method in controller which it can irerate as shown in te below example:

<apex:page controller="repeatCon" id="thePage">

    <apex:repeat value="{!strings}" var="string" id="theRepeat">

        <apex:outputText value="{!string}" id="theValue"/><br/>

    </apex:repeat>

</apex:page>


/*** Controller: ***/

public class repeatCon {

    public String[] getStrings() {
        return new String[]{'ONE','TWO','THREE'};
    }

}

reference: https://www.salesforce.com/us/developer/docs/pages/Content/pages_compref_repeat.htm
hemant ranahemant rana
Hi sonam Thanks for the rep.......

My problem is something different let me show u my code.... i had made a xml parser and want display its value in tree structure but something is getting worng in the SUBHEADING LOOP plz take a look....


VF PAGE----

<apex:page controller="ParseXMLCONTROLLER" sidebar="false" showheader="false">
    <apex:form id="result">
        <apex:inputtextarea cols="40" rows="20" value="{!textToParse}"/>
        <!--apex:inputtextarea cols="40" rows="20"  value="{!parsedText}"/-->
        <apex:commandbutton value="Parse" action="{!parse}" rerender="result"/>

        <apex:pageBlock >
            <apex:pageBlockSection title="{!rootstring}">
                <apex:repeat value="{!count}" var="i">
                <apex:pageBlockSection title="{!heading[i]}">
                <Apex:repeat value="{!textvalues[i]}" var="tv">
                {!tv}
                </Apex:repeat>
                </apex:pageBlockSection>
                </apex:repeat>

                <apex:repeat value="{!count1}" var="j">
                <apex:pageBlockSection title="{!heading12[j]}">
                <apex:repeat value="{!count2}" var="i1">
                <apex:pageBlockSection title="{!Subheading1[i1]}">
                <Apex:repeat value="{!textvalues1[i1]}" var="tv">
                {!tv}
                </Apex:repeat>
                </apex:pageBlockSection>
                </Apex:repeat>
                </apex:pageBlockSection>
                </apex:repeat>
            </apex:pageBlockSection>
        </apex:pageBlock>
    </apex:form>
</apex:page>

CONTROLLER..................

public class ParseXMLCONTROLLER{
    public String textToParse {get; set;}
    public list<integer> count{get;set;}
    public list<integer> count1{get;set;}
    public list<integer> count2{get;set;}
    public String parsedText {get; set;}
    public string rootstring{get;set;}
    public list<string> heading{get;set;}
    public list<string> textvalues{get;set;}
    public list<string> heading12{get;set;}
    public list<string> Subheading1{get;set;}
    public list<string> textvalues1{get;set;}
   
    public PageReference parse()
    {
        if (textToParse == null) {
            parsedText = 'Nothing to parse';
        }
        else
        {
            parse(textToParse);
        }
        return null;
    }

    public ParseXMLCONTROLLER()
    {
        heading= new list<string>();
        textvalues=new list<string>();
        heading12=new list<string>();
        Subheading1=new list<string>();
        textvalues1=new list<string>();
        count=new list<integer>();
        count1=new list<integer>();
        count2=new list<integer>();
    }

    private void parse(String toParse)
    {
        DOM.Document doc = new DOM.Document();
        try
        {
            doc.load(toParse);
            DOM.XMLNode  root = doc.getRootElement();
            rootstring=root.getName();
            list<DOM.XMLNode> CHILDELEMENT=root.getChildElements();
                for(DOM.XMLNode CE : CHILDELEMENT ){
                    if(string.isnotBlank(CE.getText()))
                        {
                             heading.add(CE.getName());
                             count.clear();
                             for(integer i=0;i<heading.size();i++)
                        {
                            count.add(i);
                        }
                            textvalues.add(CE.getText());
                        }
                    else if(string.isblank(CE.getText()))
                    {
                        heading12.add(CE.getName());
                        for(DOM.XMLNode CER:CE.getChildElements())
                        {
                            Subheading1.add(CER.getname());  //------------------problem is here in this list
                            textvalues1.add(CER.getText());
                        }
                    }
               
           
                }
            count1.clear();
            for(integer t=0;t<heading12.size();t++)
            {
                count1.add(t);
            }
            count2.clear();
            for(integer q=0;q<Subheading1.size();q++)
            {
                count2.add(q);
            }
        }
        catch (System.XMLException e) {
            }
    }
}