1

Im trying to dispaly nested wrappers lists in my vf page but cannot save due to "unknown property" error on my child list. I know its probably a simple declaration problem but i couldnt figure it out myself so i hope someone here could help me.

Class:

public class MyController{
       public list <firstwrapper> first_list {get; set;}
       public list<secondwrapper> second_list {get; set;}

       public class firstwrapper{
           public Account acc {set;get;}
           public list <secondwrapper> second_list {set;get;}
           public firstwrapper(Account acc, list <secondwrapper> second_list){
               this.acc = acc;
               this.second_list = second_list;
           }
       }

       public class secondwrapper{
           decimal counter {set;get;}
           integer num {set;get;}
           decimal average {set;get;}
           contact con {set;get;}
           public secondwrapper(decimal counter, integer num, decimal averege, contact con){
               this.counter  = counter ;
               this.num = num;
               this.average = average;
               this.con = con;
           }
       }           

       public MyController{
                first_list = new list <firstwrapper>();
                second_list = new list<secondwrapper>();
               //pseudo code:
               for(account list){
                   second_list.clear();
                   for(contact list){
                        //some code
                        second_list.add(contact, decimal, etc.)      
                   }
                   first_list.add(second_list, account)
               }
        }

visual force page:

<apex:pageBlock title="Title">
     <apex:pageblocktable value="{!firstwrapper}" var="first">
            <apex:column headervalue="Account Name">
                <apex:outputtext value="{!first.acc.Name}"/>
            </apex:column>
            <apex:column  headerClass="ct">
                <apex:facet name="Facet Name">
                </apex:facet>
                <apex:pageblocktable value="{!first.second_list}" var="sec">
                    <apex:column headervalue="contact name">
                        <apex:outputtext value="{!sec.con.name}"/>
                    </apex:column>
                    <apex:column headervalue="counter" value="{!sec.counter}"/>
                    <apex:column headervalue="num" value="{!sec.num}"/>
                    <apex:column headervalue="average" value="{!sec.average}"/> 
                 </apex:pageblocktable> 
           </apex:column>
    </apex:pageblocktable>

I'm getting: Error: Unknown property 'MyController.secondwrapper.con', while trying to save the vf page.

Any help will be appreciated. THANK YOU.

1

The fields of your secondwrapper class are not public so the Visualforce page can't see them. Change the class to:

   public class secondwrapper{
       public decimal counter {set;get;}
       public integer num {set;get;}
       public decimal average {set;get;}
       public contact con {set;get;}
       public secondwrapper(decimal counter, integer num, decimal averege, contact con){
           this.counter  = counter ;
           this.num = num;
           this.average = average;
           this.con = con;
       }
   } 
  • Oh...indeed. As usual, the stupidest thing. Nevertheless, thank you so much for your help!!! – Noam Dec 7 '14 at 16:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.