开发者

Error messages in JSF and Richfaces

开发者 https://www.devze.com 2023-02-15 10:37 出处:网络
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

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).
0

精彩评论

暂无评论...
验证码 换一张
取 消