Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to specify which <p:messages> component to send message

Tags:

jsf

primefaces

I would like to update different components depending on results in the bean. Right now I am using:

FacesContext.getCurrentInstance().addMessage(null, new FacesMessage(FacesMessage.SEVERITY_INFO, "test","test"));

And updating the proper component with:

<p:commandButton actionListener="#{Controller.method}" update="messageId"/>
<p:messages id="messageId"/>

Is there a different way to do it? From the bean, can I specify which message component to send the message to?

like image 786
Nick Avatar asked Oct 20 '25 14:10

Nick


1 Answers

As Vasil said - you can bind the messages to ids (component doesn't necessarily need to exist for that id'

FacesContext.getCurrentInstance().addMessage("idspecified", new FacesMessage("Header", "body"));

And then in your xhtml use

<p:message for="idspecified" />
like image 109
VeenarM Avatar answered Oct 23 '25 06:10

VeenarM



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!