Today we're going to talk about two features of JSF 2.0's f:ajax tag: the
event attribute and the listener attribute.
The use of both of these is really, really simple - so I'll just briefly
cover the basics, and then launch directly into the sample code.
The "event" attribute of the ajax tag indicates which event to use to trigger
the ajax request. There are any number of possible events allowed: You can
use the standard browser DOM events (like click, change, keyup, etc. You can
also use two special event values - action and valueChange. These two special
values correspond to the same events that happen on the server side in JSF.
On the client side, action is typically mapped to click, while valueChange is
mapped to change or click, depending on the component.
The "lis... (more)
Even though it's considered bad practice, it's often handy to eval code in
JavaScript. And in my case, it was simply necessary, since the JSF
specification requires eval of scripts. And it's also necessary to execute
those evaluated scripts in the global scope. It's not as easy as it first
looks.
For our first naive implementation, we'd simply used eval(src) in our first
pass at the i... (more)
I've had a few requests on how to write a busy status indicator - you know,
the little spinning ball that's there while an Ajax call is active, and which
goes away once the request is complete. So, I spent about two hours today,
and did just that - including putting it into a component so it's reusable.
As usual, it involved no Java, and only a minimal amount of JavaScript.
First, I need... (more)
A few weeks ago, I blogged about ways to execute scripts on the client which
you were writing out from the server via Ajax. By popular demand, the
latest build of Mojarra now allows execution of inline scripts.
So, instead of having to either bundle code into an tag, or using an
event to execute it later, you can now simply say something like: