I'm looking a way to have a close button on the pagemessage after it displays the message or dismiss after few seconds something similar to JQuery.
VFP:
<apex:pageMessages id="showmsg"></apex:pageMessages>
APEX:
ApexPages.addmessage(new ApexPages.message(
ApexPages.severity.CONFIRM,'Saved successfully!'));
Best Answer
I have tried something similar in the past.
For click to clear action
Although I didn't get any close symbol, I was able to capture any click on the
outputPanel
which contained thepageMessage
, and call anactionFunction
which would simply reRender the panel. This would clear the messages. You could try to inject some symbol or message through JavaScript.Timed clearing
So the important thing here is that on save I make the timer boolean as true. And then rerender the panel that contains the
ActionPoller
. The ActionPoller waits for 10 seconds and then calls the timerOff method and rerenders theoutputPanel
containing thepageMessage
.See the relevant VF sections and controller below to achieve the above two scenarios. It uses pure Visualforce and controller logic to achieve this.
Visualforce
Controller