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
regurireguri 

Unknown property 'IOLineHistoryController1.ioLinehistory.LineName'

Hi All,

The below visualforce page throws this error while referencing wrapper class field. "Error: Unknown property 'IOLineHistoryController1.ioLinehistory.LineName'"

Visualforce page:

<apex:page controller="IOLineHistoryController1" action="{!getRecordsTodisplay}">
<apex:form >
<apex:pageBlock >
  <apex:pageblockTable value="{!display_list}" var="rec">
      <apex:column value="{!rec.LineName}" />
  </apex:pageblockTable>
</apex:pageBlock>
</apex:form>
</apex:page>


Controller class

public with sharing class IOLineHistoryController1 {
public string channelIOId{get;set;}
public List<ioLinehistory> display_list { get;set;}
public PageReference getRecordsTodisplay()
{
   for (IO_Line__C line:iolineList)
         {
           for(IO_Line__History lhistory:line.Histories)
           {
               display_list.add(new ioLinehistory(line.id, line.name,lhistory ));
            }
         }
         return null;
}
public List<IO_Line__C>  iolineList{get;set;}
public class ioLinehistory
    {
        String LineId {get;set;}
        String LineName {get;set;}
        IO_Line__History lineHistory {get;set;}
        public ioLinehistory(String lid, String lName, IO_Line__History lineHistory1)
        {
            this.LineId = lid;
            this.LineName = lName;
            this.lineHistory =lineHistory1;
        }
    }
  



public IOLineHistoryController1() {
   
      display_list = new List<ioLinehistory>();
       channelIOId= ApexPages.CurrentPage().getParameters().get('chId');
       System.debug('channelIOId:'+channelIOId);
       iolineList= new List<IO_Line__C>([Select i.Name, i.Id, i.Channel_IO__c, (Select Id, IsDeleted, ParentId, CreatedBy.Name, CreatedDate, Field, OldValue, NewValue From Histories) From IO_Line__c i where i.Channel_IO__c=:channelIOId]);
       
       
    }
}
if I replace
<apex:column value="{!rec.LineName}" />
with
<apex:column value="{!rec}" />
I am able to see the complete record.
Please let me know if I missed something.

Thanks
Praveen
Best Answer chosen by reguri
ZedroidZedroid
Hi Praveen,

You have declared default access specifier in the wrapper class by which the property is set to be private and cannot be accessed in visualforce page.

Please declare as public in your wrapper class.

//wrapper class
    public class ioLinehistory
    {
        public String LineId {get;set;}
        public String LineName {get;set;}
        public IO_Line__History lineHistory {get;set;}
       
        public ioLinehistory(String lid, String lName, IO_Line__History lineHistory1)
        {
            this.LineId = lid;
            this.LineName = lName;
            this.lineHistory =lineHistory1;
        }
    }

Hopefully your error message gone by then.

Regards,
Zedriod.

All Answers

ZedroidZedroid
Hi Praveen,

You have declared default access specifier in the wrapper class by which the property is set to be private and cannot be accessed in visualforce page.

Please declare as public in your wrapper class.

//wrapper class
    public class ioLinehistory
    {
        public String LineId {get;set;}
        public String LineName {get;set;}
        public IO_Line__History lineHistory {get;set;}
       
        public ioLinehistory(String lid, String lName, IO_Line__History lineHistory1)
        {
            this.LineId = lid;
            this.LineName = lName;
            this.lineHistory =lineHistory1;
        }
    }

Hopefully your error message gone by then.

Regards,
Zedriod.
This was selected as the best answer
regurireguri
Thanks Zedriod.