How to convert Integer to String in Visualforce page?

How to convert Integer to String in Visualforce page?


TEXT() is used to convert any data type to String in Visualforce page.

Sample Code:


Visualforce page:


<apex:page controller=”SampleController” id=”pag”>
    <apex:form id=”frm”>    
        <apex:pageBlock >
            <apex:pageBlockSection rendered=”{! CONTAINS(setIntegerString, TEXT(aa))}”>
                <apex:pageBlockSectionItem >Name: <apex:inputText /></apex:pageBlockSectionItem>                  
            </apex:pageBlockSection>
        </apex:pageBlock> 
    </apex:form>
</apex:page>


Controller:


public class SampleController {
   Set<Integer> setInteger = new Set<Integer>{1, 3};
   public String setIntegerString {get;set;}
   public Integer aa {get;set;}
   
   public SampleController(){
       aa = 1;
       setIntegerString = ”;
       for(Integer i : setInteger){
           setIntegerString += String.valueOf(i);
       }
   }    
}

Cheers!!!

Leave a Reply