Ajax4JSF issues with MyFaces Ajax Components
Posted by cagataycivici on November 28, 2006
I’ve posted an entry about how much I like AJAX4JSF some time ago but it turns out the lib causes issues with myfaces ajax components. I’ve not tried all of the ajax components we have but when the AJAX4JSF filter is configured in the application components like inputsuggestajax begin to fail.
Ajax4JSF filter is the cause of this, I haven’t digged what it does deeply but simply removing the filter config makes the myfaces components work again. Me and my buddy Yigit needed to use both ajax4jsf and myfaces ajax component together without any problems, so we came up with an interesting hack. In myfaces we generally use a request parameter called affectedAjaxComponent when making an ajax call with dojo, the idea is to disable ajax4jsf’s filter to intervene when there is a parameter with key affectedAjaxComponent in request parameter map. In order to apply the hack, we’ve checked out the code of ajax4jsf code from java.net, applied the hack and made our own quick fix build.
The hack works for us right now in our project but of course I’ll prefer ajax4jsf and myfaces ajax components work together without any hacks in general.
UPDATE: 28.11.2007
Solution: By setting forceparser to false, myfaces ajax components started working with Ajax4JSF. The config must be as follows;
| <filter> <display-name>Ajax4jsf Filter</display-name> <filter-name>ajax4jsf</filter-name> <filter-class>org.ajax4jsf.Filter</filter-class> <init-param> <param-name>forceparser</param-name> <param-value>false</param-value> </init-param> </filter> <filter-mapping> <filter-name>ajax4jsf</filter-name> <servlet-name>Faces Servlet</servlet-name> <dispatcher>REQUEST</dispatcher> <dispatcher>FORWARD</dispatcher> <dispatcher>INCLUDE</dispatcher> </filter-mapping> |
Many thanks to Sergey Smirnov for this.

November 28, 2006 at 8:00 pm
What is curious - we use MyFaces components with Ajax4jsf and use them very active and without any additional modifications. Including inputSuggestAjax. May be the problem is somewhere around?
Ajax4jsf requires the Ajax filter decrated first in the web.xml. Do you follow this rule?
November 28, 2006 at 8:38 pm
I was very excited about Ajax4JSF. I tried out the samples. I fooled around with a few examples myself. I kicked the tires.
Then I tried to use Ajax4JSF on a Facelets project that had a lot of composition components. None of my comp components worked. It seems Ajax4JSF does not play nice with Facelets composition components.
November 28, 2006 at 8:40 pm
yes ajax4jsf filter is the first one. The version is 1.0.3 and the myfaces version is the nightly 1.1.5 snaphots. That’s strange but when I remove the filter decleration problem goes away. Same issue was discussed in myfaces mailing list before.
November 28, 2006 at 9:19 pm
Rick, most of our projects that we do for our customers uses Facelets. So supporting Facelets is a number one priority for Ajax4jsf.
What is important in case of having Facelets in the environment is moving ViewHandler declaration from faces-config.xml to web.xml
Starting with upcomming version 1.0.4, this will be not a requirement any more
November 28, 2006 at 9:30 pm
Cagatay,
1.0.3 has some showstopper bugs, however we did not meet any problems with inputSuggestAjax there.
This is one of our use cases that uses this component
http://livedemo.exadel.com/a4j-testCases/tomahawk/inputSuggest.jsf
(P.S. This is not an official demo. The link is temporary)
November 28, 2006 at 10:01 pm
Oops. Sorry, it need to have Apache server configured to open this project for public.
Let’s discuss this issue in details on the Exadel forum. It is more convenience to post code snippets there.
November 28, 2006 at 10:53 pm
Thanks for the info Sergey, yes exadel forum is a better place to discuss.
January 7, 2007 at 7:01 pm
Guys, do you have any solution that resolve the problem without applying the hack?
Unfortunately, didn’t find anything on exadel forum.
January 7, 2007 at 7:06 pm
The only topic I found on this problem, was the
http://forum.exadel.com/viewtopic.php?t=5107
January 19, 2007 at 3:10 am
I agree with Rick HighTower.
I developed a sample web application which works absolutely fine with MyFaces 1.1.1, Ajax4JSF
The moment i add Facelets 1.1.12 still everything works fine except the a4j tags.
Here is the snippet which doesnt reRender onchange event which works fine without Facelets
I posted a query on Exadel forums to know right versions . None of my queries get answered on Exadel forums
March 14, 2007 at 11:42 pm
Cagatay,
I think its not relative to the topic but
I have a question regarding tree implementation in myfaces. is there way to close all the expanded nodes except the selected one. meaning..there should be only one expanded tree node at any given time. could you please shed some lights on this thing?
Thanks,
parsi
March 20, 2008 at 7:54 pm
We are still having issues that Rick and Bansi referred to with incorporating a4j tags into facelets compositions. They don’t seem to work. We are using MyFaces 1.1.5, Facelets 1.1.14, and Rich Faces 3.1.4. We are following all the configuration recommendations as well; a4j filter defined before others and FaceletViewHandler defined in a web.xml context-param.
Any further suggestions would be appreciated.
Lee