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
fretus30fretus30 

How to populate commandButton value and column headerValue with dynamically generated text

Hello


Here the sample of code:

                 <apex:commandButton value="Edit" />

 

Instead of using hardcoded text "Edit" I would like  populate the value tag  with the dynamic text,   based on the parameter (MSG_002) passed into apex class .

  

    <apex:commandButton value="MSG_002" />

 

   example of apex class code :

       if (msgID== "MSG_002" && user.lang == "en_US" ){ return "Edit"}

      else  if (msgID== "MSG_002" && user.lang == "ru" ){ return "Menyat'"}

      else  if (msgID== "MSG_002" && user.lang == "jp" ){ return "Bblala'"}

 

I have created custom component for  outputText

 

       </apex:page>

               <c:outputTextSF msgId="MSG_0003"  />

       </apex:page>

 

<apex:component controller="LangCompController">

      <apex:attribute name="msgId" type="string"            Description="MessageID" assignTo="{!feedMessageID}"/>

      <apex:componentBody >

                  {!customMessage}

      </apex:componentBody>

</apex:component>

 


But I have no idea how to handle the following components

<apex:commandButton value=””>

< apex:pageBlock helpTitle=””>

< apex:pageBlock title=””>

< apex:column headerValue =””>

< apex:sectionHeader subtitle =””>

 

 

Any thought, ideas how to solve this problem?

 

 

John L.John L.

Apex Tags: ---------- <apex:commandButton value="Msg_002" /> Apex Code: ---------- public String Msg_002; public String getMsg_002 () { return getMsg_002; } public void setMsg_002 (String s) { Msg_002 = s; return; }

This general case can be extended as needed;

paul-lmipaul-lmi

that should actually be something like this.  since this is a simple "getter" requirement, all you need is a simple controller method to return the appropriate value.

 

However, Salesforce does provide a better way to do this, with Custom Labels and the Translation Workbench.  If you intend to do a good amount of localization in your app, I'd strongly recommend you contact your sales rep on those features.

 

Apex Tags:
----------

<apex:commandButton value="{!Msg_002}" />


Apex Code:
----------

public String Msg_002;
public String getMsg_002 () { //your custom IF logic would set MSG_002 here
return Msg_002;
}