Show global faces message only in the first h: messages component

I have two global message components in one JSF page:

it

 <h:messages id="msg1" layout="table" globalOnly="true" showDetail="true" showSummary="false"/>

      

And this:

<h:messages id="msg2" layout="table" globalOnly="true" showSummary="true" showDetail="true"/>

      

The first one is initiated here:

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "No result"));

      

And the second post started here:

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "Reset problem"));

      

But when called msg1

it is also displayed in msg2

.

How can I avoid this?

+3


source to share


1 answer


Foreword: I am assuming that replacing globalOnly="true"

with for="someClientId"

and addMessage("someClientId", message)

has already been considered and does not seem to apply in your particular case for whatever reason, the solution would otherwise be very obvious.


Set the attribute redisplay

to on false

to the last component of the message.



<h:messages ... redisplay="false">

      

Then it will not re-render messages that are already displayed earlier in another message component. I'm just wondering if you can improve finetune ajax update / render to only reference a specific post component.

+2


source







All Articles