Reputation: 4575
I have an HTML message error already done by the front end developer, so I need to use strictly his design.
Do I need to write a component inherited of <h:message/>
and implement the rendering? Or there is other easy way to display some html automatically inside it when I add error on JSF context using FacesMessage
mechanism?
The perfect solution would be, when I add a FacesMessage
in the context my <div>
with custom HTML would be displayed. Is it possible?
How can I make this kind of customization? How is the easy way?
I don't want to ouse OutputMessage
because I will not using the FacesMessage
mechanism.
Upvotes: 1
Views: 1383
Reputation: 24885
HTML should be added in the XHTML page. Anyway, you can use FacesContext.getMessages(String)
to check if there is some message for a component (and render the appropiate HTML based on that).
For example
<h:outputText value="Here is the message!:" rendered="#{myBean.messageForComponentX}"/>
<h:message for="componentX"/>
And in your bean
public isMessageForComponentX() {
return (FacesContext.getMessages("componentX") != null) && (FacesContext.getMessage("componentX") > 0);
}
You can also check the <rich:notify>
and <p:growl>
components (from RichFaces and PrimeFaces), for custom management of messages.
Upvotes: 2