I have a below class:

class abc{

public object__c var1;
public string var2;


Assume that in my controller extension I have created a list of class abc:

List<abc> somelist=new List<abc>();
somelist.add(new object__C);

and I have added object__c record to somelist. Object__c has field1__c, field2__c in it. How can I use the list - somelist in my visualforce page to access field1__c and field1__c and display these fields. I started with this:

<apex:pageBlockTable value="{! somelist}" var="rt" > 
 <apex:column value="{!rt.field1__c}"/>

But this gives an error , I guess I cannot access like rt.field1__c. Please let me know how can I do this.

  • 1
    first declare the inner variables with getter and setter and use rt.var1.field1__c in the page to read the value from controller. – george thomas Mar 17 '16 at 3:51
  • Great! that gives me what I want. Can you please answer my other question which I recently asked. It related to this. – SfdcBat Mar 17 '16 at 3:55

If you want to access variable in VF page it should be in get property.

your variable should be in getter setter property

class abc{

public object__c var1;
public string var2;
public List<abc> somelist {get;set;}


If any variable you want to access in VF page that should be getter setter property

If you don't want to set the variable values from page then use private set;. This way you can set the variable value only in controller side but if you try to set the variable value in VF page, It will not bind the value to your variable.


The "get" method is used to pass data from your Apex code to your Visualforce page..

Set The "set" method is used to pass values from your visualforce page to the controller


| improve this answer | |
  • Thanks. I guess I need to use rt.var1.field1__c in my VF page. I do have get and set for the list somelist. Can you please answer my other question which I asked very recently before this question? – SfdcBat Mar 17 '16 at 3:56

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.