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
Ron9Ron9 

rerendering apex:messages

Hey everyone

I'm trying to create a responsive visualforce page, only rerendering the proper pageblocks etc. when needed to avoid doing full page rerenders. BUT I use <apex:messages/> to display error messages and I've not been able to get the apex:messages component to update without doing a full page rerender.

I've tried something like this:

<apex:messages id="msgBlock"/>

...
<apex:commandButton action="{!someMethod} value="button" rerender="msgBlock"/>

 Does anyone know how to do this or something with a simular functionality?

 

Thanks

Ronni

Best Answer chosen by Admin (Salesforce Developers) 
avijchakavijchak

<apex:outputPanel id = "msgPanel"

       <apex:outputLabel value ="{!message}"/>

<apex:outputPanel>

 

<apex:commandButton action="{!someMethod} value="button" rerender="msgPanel"/>

 

or

<apex:outputPanel id = "msgPanel"

       <apex:messages id="msgBlock"/>

<apex:outputPanel>


...
<apex:commandButton action="{!someMethod} value="button" rerender="msgPanel"/>

All Answers

avijchakavijchak

<apex:outputPanel id = "msgPanel"

       <apex:outputLabel value ="{!message}"/>

<apex:outputPanel>

 

<apex:commandButton action="{!someMethod} value="button" rerender="msgPanel"/>

 

or

<apex:outputPanel id = "msgPanel"

       <apex:messages id="msgBlock"/>

<apex:outputPanel>


...
<apex:commandButton action="{!someMethod} value="button" rerender="msgPanel"/>

This was selected as the best answer
Ron9Ron9

Thanks, wrapping the <apex:messages/> in a outputPanel worked for me.