webtier@glassfish.java.net

Re: Using JQuery within JSF 2.0

From: <webtier_at_javadesktop.org>
Date: Thu, 26 Aug 2010 16:54:47 PDT

Hi,

We are using JQuery with JSF 2 and we didn't have any problems. For execute JSF actions by AJAX requests we are using the JSF native JavaScript function "jsf.ajax.request" (please see: http://java.dzone.com/articles/jsf-2-client-behaviors).

For the "autocomplete" widget of JQuery UI for example, we used a custom "PhaseListener" to intercept the AJAX call and return the JSON data. We sent with the jQuery AJAX request the name of the ManagedBean and the action to be executed. In our custom PhaseListener we got the ManagedBean via EL and we execute the action via EL too. Then we got the result of the action and write this in the response.

You can use this aproach to map other AJAX requests to JSF. In your custom PhaseListener you will be able to find ManagedBeans, execute actions and return everything you want to your AJAX request.

Cheers
[Message sent by forum member 'rbsrodrigues']

http://forums.java.net/jive/thread.jspa?messageID=481116