Showing posts with label f:ajax. Show all posts
Showing posts with label f:ajax. Show all posts

Thursday, January 20, 2011

JSF 2.0 observations on JavaScript format for Ajax

I notice that on the version of JSF 2.0 I have on GlassFish, that the jsf.js page may not be included to make a call to jsf.ajax.request(), if you need access to this function. I guess in that case you would either add a do-nothing f:ajax tag to your JSF file, or do some include of the jsf.js library programmatically. The former option may be better.

Also I noticed that if you want to key in on a non-default event when calling jsf.ajax.request() that you will need to create an object for the last parameter that includes the property javax.faces.behavior.event...but be careful: you will get a JavaScript error if you try to do this all in line without some extra work. Property names typically do not have periods in them ("."). So you have to do something like the following:

...onkeyup="var lArgs = {}; lArgs['render'] = 'form:output'; lArgs['javax.faces.behavior.event'] = 'keyup'; jsf.ajax.request(this,event,lArgs);"

Friday, October 29, 2010

kudos to JSF 2.0's f:ajax tag!

It has been verging on too long since my last blog entry.

I have been reading in JSF 2.0: the complete referece by Burns, Schalk and Griffin about the f:ajax tag, and the Ajax implementation in JSF 2.0.

It's really cool.

Here is my background with Ajax. I have implemented Ajax solutions in JSF apps using straight JavaScript. This was kinda hard but not too bad actually. But I am fairly comfortable with JavaScript. I have also worked with the JSF Blueprint auto-suggest component. This worked out rather well and hid much of the details of the JavaScript functionality behind a JSF component. I have also studied a bit more than half of Deepak Vohra's book Ajax in Oracle JDeveloper and seen what a huge number of ways there are to do Ajax...and that is just with Java! I have also been working with ADF 10g's PPR solutions and my own frame/iframe kluges for years as well.

I really like the simplicity of the f:ajax tag. For starters, I love that you can get some basic, useful Ajaxian functionality simply by including the f:ajax tag either inside or wrapped around you JSF tags! This basically would do the equivalent of submitting those fields when the default event for those JSF components fires. The default JavaScript client event for a component is a sensible value depending on whether it is an action component or a value-change component.

Then it is possible to have all the flexibility of doing Ajax from raw JavaScript.

It is certainly much much easier than having to construct a bunch of JavaScript then do a bunch of request hijacking from a PhaseListener, like in JSF 1.1 and 1.2.

Thumbs way up guys!