Reputation:
I have two global message components in one JSF page:
This
<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 initiate here:
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "No result"));
And second message initiated here:
FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR, "", "Reset problem"));
But when msg1
is invoked, it's message value displays in msg2
too.
How can I avoid this from happening?
Upvotes: 3
Views: 2721
Reputation: 1108632
Preface: I'll assume that replacing globalOnly="true"
by for="someClientId"
and addMessage("someClientId", message)
was already considered and apparently not applicable in your specific case for some reason, the solution would otherwise have been very obvious.
Set redisplay
attribute to false
on the last message component.
<h:messages ... redisplay="false">
Then it won't redisplay messages which are already displayed before in another message component. I only wonder if you can't better finetune the ajax update/render to reference only a specific message component.
Upvotes: 4