webtier@glassfish.java.net

Re: [webtier] JSF 2.0 Ajax question

From: Jim Driscoll <Jim.Driscoll_at_Sun.COM>
Date: Sun, 11 Jan 2009 17:00:17 -0800

Lincoln Baxter, III wrote:
> Just a quick question in case this use case isn't already out there. How
> would I use the current JSF 2.0 ajax functionality to call a server-side
> method through ajax, preferably without needing to render a hidden
> command***** field. Is that possible?
>
> A4J enabled this through the <a4j:jsFunction> tag.



I'm not sure I understand exactly what you're asking for (I don't know
A4J), but attaching an ActionListener to a an action calls that method
when it's used for Ajax (and you can do something similar with
ValueChangeListener). Is that what you're looking for? The method
signatures aren't arbitrary (which might be what you mean by hidden
fields), but it can do any action within that constraint. The docs I
found for jsfunction (at
http://www.jboss.org/file-access/default/members/jbossajax4jsf/freezone/docs/tlddoc/a4j/jsFunction.html)
seems to imply similar usage.

The demos (even the simple ones) have that usage sprinkled about - I
still need to write a demo that does a ValueChange using the js
functions, but the ajax-tag demo does that using the <f:ajax> tag.

Let me know if that answers your question.

Jim