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 Answer 1

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;
       }
   } 
1
  • Oh...indeed. As usual, the stupidest thing. Nevertheless, thank you so much for your help!!!
    – Noam
    Commented Dec 7, 2014 at 16:17

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .