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
ShravanKumarBagamShravanKumarBagam 

ApexPages Message

Hi,

I' using page messages to display message on vf page.

 

  I want to display message as show below...

How can i achieve that

 

Message:'You Selected'+' '+a.name

 

ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.Info,'You Selected'+' '+a.name );
ApexPages.addMessage(msg);

zmcelrath87zmcelrath87

Shravan,

 

Use the apex pageMessages tag:

 

<apex:page>

<!-- This will display every ApexPages.Message -->
<!-- added to the page with ApexPages.addMessage(msg) -->
<apex:pageMessages/>

</apex:page>

 

Regards,

 

Zach McElrath

Skoodat LLC

 

ShravanKumarBagamShravanKumarBagam

 

 

 

Hi,

 

I'm able to display message, but i want to change color as show below.

 

Message:You Selected United Oil & Gas, Singapore
Where United Oil & Gas, Singapore is Account name.
Gunners_23Gunners_23

Inorder to style messages, you cannot use the pageMessages tag there won't be any attributes for "Style" in that tag. Your best

 

bet is using "<apex:messages>" tag in this salesforce stylesheets won't be enabled and you can style however u want

SeAlVaSeAlVa

Try with the following

 

<apex:pageMessages escape="false" />

 And in your apex

ApexPages.Message msg=new ApexPages.Message(ApexPages.Severity.Info,'You Selected <b>'+ a.name  + '</b>');
ApexPages.addMessage(msg);

 Regards

alanw707alanw707

How come when I do the same thing. It says it only takes an Exception type

 

Compile Error: Argument must be an exception type

joe1.3898212780713167E12joe1.3898212780713167E12
I know this is an old thread, but just in case somehone else comes here looking for answers...
@Alanw707, be sure you use addMessage (singular) and not addMessages (plural) when using SeAiVa's code snippet. Easy typo to make.