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
Iceman123Iceman123 

Unknown property: datatable / repeater and handing of class within a class

Hi there,

 

I am having trouble getting the repeater below to recognize the fields of the subclass (Door).  Am I overlooking something, or is this not supported?  If so, are there any workarounds?  

 

Thanks a lot in advance for the feedback,

Pi

 

 

---------------------------

public class Door {
     public String DoorName = '';
     public String DoorID = '';
    
        public String getDoorName()
        {
            return DoorName;
        }
        public String getDoorID()
        {
            return DoorID;
        }    
}

public class Car {
    
     public String CarName = '';
     public List<Door> Doors = new List<Door>();
    
        public String getCarName()
        {
            return CarName;
        }
      
        public List<Door> getDoors()
        {
            return Doors;
        }           
   }

 

    public List<Car> getReturnedCars()
    {
        return this.rCars;
    }  
    

 

 

As you can see, the Car class has a list of Doors.  The following is the page code which throws the unknown property error:

 

    <apex:dataTable value="{!getReturnedCars}" var="c" id="theTable" rowClasses="odd,even"
                        styleClass="tableClass" cellspacing="1" cellpadding="1" border="0">
        <apex:column colspan="2" width="400">
            <apex:outputText value="{!c.CarName}"/>   <----- works fine
            <apex:repeat value="   {!c.Doors}" var="d" id="theRepeat">  
                <apex:outputText value="{!d.DoorName}" id="theValue"/><br/> <----- throws an Unknown property 'String.DoorName'
            </apex:repeat>            
        </apex:column>    
    </apex:dataTable>

getReturnedCars returns a List of Cars objects.    c.CarName is working fine.  c.Doors should have returned a list of Door objects.  But then it has trouble getting to the DoorName field of the Door object within the repeater.  Am I referencing the DoorName field correctly?  What is the right way to implement this?

Best Answer chosen by Admin (Salesforce Developers) 
Iceman123Iceman123
I tried using 2 repeaters (apex:repeat) nested, instead of the dataTable and it works :)

All Answers

Iceman123Iceman123

            <apex:repeat value="   {!c.Doors}" var="d" id="theRepeat">  
                <apex:smileysurprised:utputText value="{!d}" id="theValue"/><br/> <----- throws an Unknown property 'String.DoorName'
            </apex:repeat>

 

If I change the repeater to just d (for the Door object), it prints out the right number of objects I am expecting, eg.

 

[core.apexpages.el.adapters.ApexObjectValueELAdapter@d282a, core.apexpages.el.adapters.ApexObjectValueELAdapter@1c80361]

 

I'm not sure how to get it to access the fields of the Door object though ...

 

 

Iceman123Iceman123
I tried using 2 repeaters (apex:repeat) nested, instead of the dataTable and it works :)
This was selected as the best answer