开发者

Displaying error message in popup JSF

开发者 https://www.devze.com 2023-01-06 07:32 出处:网络
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:messa

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.

0

精彩评论

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