Ajax4JSF issues with MyFaces Ajax Components

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.

12 Responses to Ajax4JSF issues with MyFaces Ajax Components

  1. 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?

  2. 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.

  3. Cagatay says:

    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.

  4. 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

  5. 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)

  6. 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.

  7. Cagatay says:

    Thanks for the info Sergey, yes exadel forum is a better place to discuss.

  8. Arsen says:

    Guys, do you have any solution that resolve the problem without applying the hack?

    Unfortunately, didn’t find anything on exadel forum.

  9. Arsen Abdrakhmanov says:

    The only topic I found on this problem, was the
    http://forum.exadel.com/viewtopic.php?t=5107

  10. bansi says:

    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

  11. parsi says:

    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

  12. Lee says:

    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

%d bloggers like this: