Displaying error message in popup JSF
How to generate popup while displaying validation error? For开发者_StackOverflow中文版 example for <h:inputText required="true">
if I skip and press submit button I want to display <h:message>
in a popup. Is that possible in JSF 2.0 or using jQuery or any other?
Yes it is very much possible.
To generate the popup, use the jQuery dialog widget (documented here).
Place the following in your xhtml:
<h:outputScript rendered="#{not empty facesContext.messageList}" ...>
This will ensure that the javascript will get rendered if there is at least one message.
In the javascript referenced by h:outputScript, load a jQuery dialog with h:messages as the contents. Ensure that the "autoOpen" attribute of the jQuery dialog is set to true. This will render the dialog as soon as the document loads.
Hope this helps.
精彩评论