views:

37

answers:

1

How to generate popup while displaying validation error? For 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?

A: 

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 facesContext.messageList.empty}" ...>

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.

Babu