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
vasu takasivasu takasi 

how to change the font style of a string in controller(in message class)

hi

i have a controller like

 

public with sharing class assignment5
{
    public string name{get;set;}
    public assignment5(ApexPages.StandardSetController controller)
     {

      }
    
    public void selected_name()
    {
             //name.fontstyle='bold';      
            ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.info, 'you selected  '+name);
            Apexpages.addMessage(mymsg);
    }
}

 

page:-

<apex:page standardController="account" recordSetVar="acc" >
    
    <apex:form id="f1">
       <apex:sectionHeader title="Assighment 5"/>
        <apex:pageBlock >
          <apex:pageMessages ></apex:pageMessages>
            <apex:pageBlockTable value="{!acc}" var="a" >
            <apex:column headerValue="Name" id="col1">
                <apex:commandLink action="{!selected_name}" reRender="f1" >
                    {!a.name}
                    <apex:param value="{!a.name}" name="n"  assignTo="{!name}"/>
                </apex:commandlink>
            </apex:column>
            <apex:column value="{!a.BillingState}" id="col2" />
            <apex:column value="{!a.phone}" id="col3" />
            <apex:column value="{!a.website}" id="col4"/>
            </apex:pageBlockTable>
        </apex:pageBlock>
    </apex:form>
</apex:page>

 

in vf page the font style of   "name" should be in bold.

ex: you selected  xxxxx

Best Answer chosen by Admin (Salesforce Developers) 
Eugene PozniakEugene Pozniak

Try to add in controller following:

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.info, 'you selected  <b>' + name + '</b>');
            Apexpages.addMessage(mymsg);

 

On the page add: <apex:pageMessages escape="false" />

 

escape="false" - A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape="false", the character escape sequence displays as written. 

 

 

All Answers

Eugene PozniakEugene Pozniak

Try to add in controller following:

ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.info, 'you selected  <b>' + name + '</b>');
            Apexpages.addMessage(mymsg);

 

On the page add: <apex:pageMessages escape="false" />

 

escape="false" - A Boolean value that specifies whether sensitive HTML and XML characters should be escaped in the HTML output generated by this component. If you do not specify escape="false", the character escape sequence displays as written. 

 

 

This was selected as the best answer
vasu takasivasu takasi

thank you, Its working

HussainHussain

hi,

i want to change the background color of my row when i click the name how  can we do this for the same code