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
Mohan SelvamMohan Selvam 

How to access created page alert in apex classes -

hi
i want to create one alert message with ok button in existing visualforce page and i need to use that message
in a perticullar method of exisiting controller[apex classes]
For example
i am having visualforce page named as 'visitWarning'. In that i need to add a code to create alert message with ok button and i should call this alert in AbilityChecking() method [this method occured in my VisitAlertController Class]
Code Example :
Page
VisitWarning

<apex:page standardController="Visits__c"  extensions="VisitAlertPageController" >
 <apex:outputPanel layout="block" style="overflow:auto;height:100px" >
 <apex:pageMessages />
 </apex:outputPanel>
</apex:page>
Apex classes

public class VisitAlertPageController {
.....
......
......

public void VisitScheduledAbility(){
.........
..........
if((currentVisit.Type__c =='Hello' )
{
// I should call the alert here
}
}

}


RamuRamu (Salesforce Developers) 
The below article might help

http://www.salesforcegeneral.com/salesforce-modal-dialog-box/
Andreas MeyerAndreas Meyer
Hi,

not sure if i clearly understand what you want ... but i guess it isn't a popup dialog. If you want to add a message to the page as soon as the user presses the ok button, try this:

public PageReference VisitScheduledAbility(){
	.........
	..........
	if((currentVisit.Type__c =='Hello' )
	{
		// I should call the alert here
		ApexPages.addMessage(new ApexPages.Message(ApexPages.Severity.INFO,'THIS IS YOUR MESSAGE'));
	
	}
	.........
	..........
	return null;

}

note that you have to change your function to return a PageReference and make sure you return null at the end of your function. Moreover alter the severity of the message if needed.

Hope that is what you are looking for ..

Best,
Andreas