JeffJak
JeffJak

Reputation: 2068

Create a message similar to p:messages using PrimeFaces without adding to FacesContext?

I am using Primefaces 2.3.0 and JSF2.0.

I like the html output that Primefaces p:messages gives me. But I due to existing design, I would like to create the html without needing the to add the messages using FacesContext.getCurrentInstance().addMessage.

Essentially, I would like to do something like this:

<p:messages value="test"/>

I realize probably would not use p:messages but an existing tags that just outputs something very similar to what p:messages outputs.

I am hoping there is maybe another component that p:messages is using.

Thanks for any ideas.

Upvotes: 10

Views: 7103

Answers (2)

Dominik
Dominik

Reputation: 396

You can now use the StaticMessage component

  <p:staticMessage severity="info" summary="INFO!" detail="Hey, i'm a info!" />

See https://www.primefaces.org/showcase/ui/message/staticMessage.xhtml

Upvotes: 0

Cjxcz Odjcayrwl
Cjxcz Odjcayrwl

Reputation: 22877

The most minimalistic example I've found that looks exactly the same using my theme is:

<div class="ui-message-error">
    <span class="ui-message-error-icon"/>
    <span class="ui-message-error-detail">test</span>
</div>

I've removed classes ui-widget ui-corner-all from div, because I don't use rounded corners etc., but if it makes a difference in your case, well, the example would be a bit longer.

Upvotes: 13

Related Questions