You need to sign in to do that
Don't have an account?
tj reddy
Accessing Custom Labels dynamically from visualforce components
Hi All,
I have a field label__c where i am storing custom label name related to each record.
Here i am able to display this in visualforce page by using {!$Label[label__c]}, but i am not able to use same in visualforce components.
Please help me out in achiving this.
Thanks in advance.
I have a field label__c where i am storing custom label name related to each record.
Here i am able to display this in visualforce page by using {!$Label[label__c]}, but i am not able to use same in visualforce components.
Please help me out in achiving this.
Thanks in advance.
We also need to look at version of visualforce component.
Thanks again for your responses.
All Answers
I believe while you are referring the field in visualforce, you call it as object.fieldapiname like below.
<apex:page standardController="account">
{!$Label[Account.test_la__c]}
</apex:page>
Similarly, in a component when i try this it shows me the value correctly. Not sure, if this is what you are looking for.
Component: i am passing the account info from VF Page. i think this could be done without that also i.e. fetch the value in the component itself directly.
<apex:component controller="testcomponent">
<apex:attribute assignTo="{!accountObj}" name="account12" type="Account" description="test"/>
{!$Label[accountObj.test_la__c]}
</apex:component>
Component Controller:
public class testcomponent {
public account accountObj{get;set;}
}
VF including component:
<apex:page standardController="account">
Please mark this as right if this solution works for you.
Thanks,
We also need to look at version of visualforce component.
Thanks again for your responses.