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
Gaurav Agnihotri 11Gaurav Agnihotri 11 

unable to display a message on the Visualforce page

I want to display a message when a button is invoked in VF page. 
 
I declared it as a public string:

public string broadcastMessage { get; set; }

I am updating the value in a button calling a class search()
if (oppSplits.size() > 0)
		{

			//oppSplitSize = true;
			if (oppSplits.size() <= 400)
			{
				OpportunityEdit newOppEdit = new OpportunityEdit();
				newOppEdits = newOppEdit.createOppEditList(oppSplits);
				newOppEditsSearch = newOppEdit.createOppEditList(oppSplits);

			}
			else
			{
				
				broadcastMessage = 'The record size is more than 400. Refine the Query to reduce the size';
				System.debug('broadcastmessage='+broadcastMessage);
			}
		}

the value is not updating in the VF page.

Not sure what I am doing wrong!


 
Raj VakatiRaj Vakati
Use  apex:pageMessages

try like below
 
<apex:page controller="theController">
<apex:pageMessage severity="Error" summary="First Error message on page" strength="1"></apex:pageMessage>
<apex:pageMessage severity="Error" detail="Second Error message on page" strength="2"></apex:pageMessage>
<apex:pageMessages ></apex:pageMessages>
 
</apex:page>
 
public class theController {
 
public theController(){
 
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'First Error Message added from apex'));
ApexPages.addmessage(new ApexPages.message(ApexPages.severity.Error, 'Second Error Message added from apex'));
 
}
}