10

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.

Akos K
  • 7,071
  • 3
  • 33
  • 46
JeffJak
  • 2,008
  • 5
  • 28
  • 40
  • do you want to show static message text as value (like in your example) or the message text is coming from your backing bean? – Akos K Nov 05 '12 at 21:23
  • 1
    You can just use the same html generated by p:messages. For usage: see this answer [error-message-style-for-a-panel](http://stackoverflow.com/questions/11370481/error-message-style-for-a-panel) – Ravi Kadaboina Nov 05 '12 at 23:07
  • have you found a solution, could you share with us? – Akos K Nov 06 '12 at 20:43
  • So far I have not found a solution that does not involved adding the faces messages. – JeffJak Nov 19 '12 at 19:23

2 Answers2

13

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.

Danubian Sailor
  • 1
  • 38
  • 145
  • 223
0

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

Dominik
  • 406
  • 2
  • 12