0

How can I pass the var attribute from my <apex:repeat> tag to a controller variable? Here var contains API name of object field. From that I need to get label for that particular field to display it in table column. I am using facet to display column label.

<apex:repeat value="{!SelectedFields}" var="FieldLable"  id="xyz">  
    <apex:column id="clm" >                   
        <apex:outputfield value="{!ab.con[FieldLable]}" />
        <apex:facet name="header">{!Lable}</apex:facet>                       
    </apex:column>                      
</apex:repeat>
5

You don't need to pass it to Apex. Just use the $ObjectType global variable. Here I will rename your variables to be less confusing and conform to your description. Please also note it's label, not lable.

<apex:repeat value="{!selectedFields}" var="fieldName">
    <apex:facet name="header">
        {!$ObjectType.MyObject__c.fields[fieldName].label}
    </apex:facet>
</apex:repeat>
| improve this answer | |
  • thanks adrain . It helped , this is what i used <apex:facet name="header">{!$ObjectType[selectedObject].fields[FieldLable].Label}</apex:facet> – mak k Oct 9 '17 at 6:24
  • @mak If this answer addressed your problem, please consider accepting it by clicking on the check mark/tick to the left of the answer, turning it green. This marks the question as resolved to your satisfaction, and awards reputation both to you and the person who answered. If you have >= 15 reputation points, you may also upvote the answer if you wish. There is no obligation to do either. – Adrian Larson Oct 9 '17 at 13:10

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.