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
Proposal ButtonProposal Button 

why the warning message not displaying in red in VF page

Hi I am trying to display a warning mess in the VF page. I succeded in getting the warning message but i want to display in Red color but it it throwing in black. Here is the thing i added in the controller and in the VF page

 

Controller:

 

 if(Opportunity.Not_Closed_won__c == True)
        {        
        ApexPages.Message errMsg = new ApexPages.Message(ApexPages.Severity.ERROR, 'Any changes made to the quote will not flow to Magnys');
ApexPages.addMessage(errMsg);
 }

 

 

VF page:

 <font color="red"><b><apex:messages /></b></font>

 

The characters which are in red is the warning mess i am trying to display but i am geeting the warning mess in black in the vf page. Can you please let me know why?

Reppin__505Reppin__505

I think you have to override the Salesforce Style sheet since the error message is generaed by Salesforce functionality.

 

FYI, you can reduce your message code to one line using :

 

 

ApexPages.addMessage(new ApexPages.Message(ApexPages.severity.Error, 'Message Here'));

 

 

 

Proposal ButtonProposal Button

IF i reduce the message code to a line as you said i am unable to get the warning message in VF page.

Reppin__505Reppin__505

Oh, sorry. You will need to use <apex:pageMessages ></apex:pageMessages> in your VF page.

jwetzlerjwetzler

You can add CSS directly to your messages component:

 

 

<apex:messages style="color:red"/>

 

 

Proposal ButtonProposal Button

I added as you said but still the warning message is not turning to Red color

bob_buzzardbob_buzzard

Have you used the <apex:messages/> tag as Jill suggested, or have you stuck with your <apex:pageMessages/> tag - they are used in different ways.

 

I've not had success styling the contents of a pagemessages component, even though there is an escape attribute, regardless of whether I set it to true or false, my HTML appears as text.  

 

Your best bet in this situation is to override the Salesforce styles, as recommended above.  Note though that if Salesforce change their style names, you will have to revisit your page to override the latest salesforce styles.