Error messages in JSF and Richfaces
How can I display validation error messages in JSF and Richfaces in the开发者_如何学JAVA form of an icon beside the field and a tooltip with the error message appears when the mouse hover on the error icon ?
Here is what you can do:
- Use
<h:message tooltip="true" showSummary="true" showDetail="true" for=... />
: this way the detail will appear as tooltip, hide the summary, replace it with an icon (see how). - Create a
<rich:panel id="myid" rendered="#{bean.errorDisplayed}"><h:graphicImage src"patho/to/image.png" /></rich:panel>
, create the tooltip<rich:toolTip for="myid"><h:message for="inputid" /></rich:toolTip>
, in the backingbean use FacesContext.getMessages(String clientId) to check form messages. To get the clientId of the input use UIComponentBase.getClientId - Simply use
h:message
, and do some js tricks to wrap the displayed message in a tooltip, and display an icon (all of the js libraries have tooltip plugins).
精彩评论