4 Replies Latest reply on Jul 18, 2006 6:28 PM by Gavin King

    Ajax4JSF experiences

    Gavin King Master

      OK, so I spent some time playing with JSF yesterday afternoon. Overall I'm pretty happy with the APIs but....

      So, what I've noticed so far is:

      (0) <a4j:region> is required in MyFaces, as per Ajax4JSF docs (ugly!)
      (1) <a4j:region selfRendered="true"> breaks with Seam, probably some problem to do with phase listeners/filters
      (2) <a4j:region selfRendered="false"> is totally broken, at least in JSP/MyFaces. Might be OK in facelets and/or the RI
      (3) The echo example works with a <h:outputText> as the component to be re-rendered, but not with a <h:inputText>

      Does anyone know how to solve any of these problems?

      Ajax4JSF is implemented as a servlet filter instead of as a custom UIViewRoot (which is the route that Jacob/Ed/Adam have been going down).

      The Ajax4JSf docs hint that the difference b/w the UIViewRoot implementations in MyFaces and the RI is what causes problems in MyFaces, which leads me to wonder if they really should be replacing the viewroot. Furthermore, it seems to be their hacked lifecycle that causes probelm (1) on Seam. However, it might be that Ajax4JSF is doing extra stuff compared to what is in facelets CVS (Ajax4JSF seems to do partial restores as well as partial renders).

      Anyway, my conclusion is that this stuff needs some serious work to be usable...

      I will contact the Exadel guys next week probably.

        • 1. Re: Ajax4JSF experiences
          Thomas Heute Master

          I tried as well and got mixed experience.

          I was able to do some stuff but not everything i wanted...

          For instance i wanted to update the search result as i typed the searchString in the booking example.

          It broke on s:link, if i removed them from the ajax region, then i have another problem: i have concurrent calls on the searchString of the Stateful Bean. By marking it stateless then i have the list correctly updated.

          So yes there are several issues...

          • 2. Re: Ajax4JSF experiences
            Vitaly Rudensky Newbie

            I've just make some tests with
            Seam 1.0.1GA
            ajax4jsf 1.0rc2
            Facelets 1.1.11

            It looks like working.

            Echo Example:
            #{bean} is Seam stateful EJB

            <ui:define name="body">
             <a4j:status startText="Performing Request" startStyle="color:red"
             stopStyle="color:green" stopText="Request Done" for="region" />
             <a4j:region selfRendered="true" id="region">
             <h:form id="inputForm">
             <h:outputText value="Type the Text:" />
             <h:inputText value="#{bean.text}" size="50">
             <a4j:support event="onkeyup" reRender="repeater,repeater2" />
             <h:form id="outputForm">
             <h:outputText value="Text in the AJAX Response:" />
             <h:outputText id="repeater" value="#{bean.text}" />
             <h:inputText id="repeater2" value="#{bean.text}" />

            Another test with <h:inputText> and AJAX reRendered <h:dataTable> is also working.

            Here is my web.xml
            <?xml version="1.0" encoding="utf-8"?>
            <web-app version="2.4" xmlns="http://java.sun.com/xml/ns/j2ee"
             xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
             <!-- ========Seam begin ========== -->
            <!-- ========Seam end ========== -->
            <!-- ======== AJAX4JSF begin ========== -->
             <display-name>Ajax4jsf Filter</display-name>
             <servlet-name>Faces Servlet</servlet-name>
            <!-- ======== AJAX4JSF end ========== -->
            <!-- ========Facelets begin ========== -->
            <!-- ========Facelets end ========== -->
            <!-- ======== JSF begin ========== -->
            <!-- Faces Servlet -->
             <servlet-name>Faces Servlet</servlet-name>
            <!-- Faces Servlet Mapping -->
             <servlet-name>Faces Servlet</servlet-name>
            <!-- MyFaces -->
            <!-- ======== JSF end ========== -->

            in faces-config.xml just seam, facelets view-handler declared in web.xml

            But I've got another problem. In some time after AJAX request WARN on console like this:

            08:16:55,580 WARN [TransactionImpl] Transaction TransactionImpl:XidImpl[FormatId=257, GlobalId=cam-79/754, BranchQual=, localId=754] timed out. status=STATUS_ACTIVE

            • 3. Re: Ajax4JSF experiences
              Igor Shabalov Apprentice

              Gavin, you are always welcome to ask any questions! So far I do not hear any of it, did everything start working?

              Seam is a bit unusual configuration for JSF developers (yet?), however I play with it a few weeks ago and find it very promising. I cannot tell that I fell in love with annotations, but more granular state management and process engine is something that I always appreciate. I still need to prove this on large project, to make my mind, but ? again ? I?d like to try.

              I think we will review our compatibility status with Seam soon.

              (3) must work. Something else is messing around, I believe.

              I can predict the first question from Alex Smirnov ? what version of Ajax4jsf was used, we did several RC builds last weeks, situation may change significantly in just a few days.

              Igor Shabalov.

              • 4. Re: Ajax4JSF experiences
                Gavin King Master

                Hi Igor, thanks. When I get a chance, I want to get some closer discussions going on this topic.

                My suspicion is that some of my problems relate to the MyFaces/AJAX4JSF combo, and some relate to problems b/w you servlet filter and my phaselistener.