Reputation: 43
So, I am trying to display validation error messages as image title. I want to do that, because messages are quite long and I don't want them to take place on my page.
Tried to bind UIComponent <h:message />
object to controller object, but then I couldn't find out how to get a span's value from UIComponent.
What should I do?
Upvotes: 0
Views: 289
Reputation: 1108642
Just control the markup yourselves inside an <ui:repeat>
while iterating over the messages. You can obtain messages in EL by FacesContext#getMessageList()
.
So instead of,
<h:inputText id="foo" ... />
<h:message for="foo" />
do something like
<h:inputText binding="#{foo}" ... />
<ui:repeat value="#{facesContext.getMessageList(foo.clientId)}" var="message">
<h:graphicImage name="#{message.severity}.png" title="#{message.summary}" />
</ui:repeat>
where the #{message}
is an instance of FacesMessage
, offering the usual getters.
Upvotes: 1
Reputation: 1440
An alternative solution is to define and put all these long messages in .properties
's file, as bundle messages. Take a look here : When to use message bundle and resource bundle
Upvotes: 0