5 Replies Latest reply on Aug 19, 2008 1:01 PM by merlin-hst

    Can't generate ajax call from JSF page

    gbpanchal

      I am using JBoss RichFaces Ajax4JSF functionality.

      I am making different ajax calls from the application. The problem is that that ajax call is working fine when i do it from individual jsf page.
      But, when i put that jsf page in the application flow(means, call that page from another jsf page), that ajax call is going to server and updates the bean data but it is not reRandering it on the jsf page.

      I have used,
      <a4j:commandButton id="cmdAjaxBack" action="#{testBean.prev}" value="Ajax Back" styleClass="button" reRender="currentGroup"/>
      to generate ajax call.
      Here, currentGroup is a id of the dataTable componeent.

      I don't know why it is behaving like this, probably, the call is not passing thorugh Ajax4JSF filter. But, how to make it to pass thorugh it.

      Please, reply as soon as possible, as i need to build functionality rapidly and i have stuck up on this issue.

        • 1. Re: Can't generate ajax call from JSF page
          merlin-hst

          I'm having the same problem but can't get it working even on a single page ;( But the sample I've found here seems to work: http://sezera.blogspot.com/2008/07/sample-springhibernatejsfrichfaces.html
          My xhtml-site looks like:

          <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
          "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
          <html xmlns="http://www.w3.org/1999/xhtml"
           xmlns:ui="http://java.sun.com/jsf/facelets"
           xmlns:h="http://java.sun.com/jsf/html"
           xmlns:f="http://java.sun.com/jsf/core"
           xmlns:c="http://java.sun.com/jstl/core"
           xmlns:a="http://www.conergy.com/jsf"
           xmlns:ex="http://www.conergy.com/jsf/components"
           xmlns:rich="http://richfaces.org/rich"
           xmlns:a4j="http://richfaces.org/a4j">
          
          <f:loadBundle basename="resources.resource" var="bundle"/>
          
          <head>
          ...
          </head>
          <body>
          ...
          <a4j:outputPanel ajaxRendered="true">
           <a4j:log popup="true" id="log_pop" level="ALL" style="width: 800px; height: 300px;"></a4j:log>
           </a4j:outputPanel>
          
          
           <a4j:outputPanel ajaxRendered="true">
           <h:messages globalOnly="false" errorClass="errorMessage" infoClass="infoMessage" />
           <rich:messages />
           </a4j:outputPanel>
          
          <a4j:region renderRegionOnly="true" id="inputGroup">
          <h:panelGrid id="ajaxdemo" columns="2" border="0" columnClasses="panelc" >
          
           <h:inputText id="myInput" value="#{authorizationController.myTestProperty}">
           <a4j:support id="myAjaxSupport" event="onkeyup" reRender="myOutput"></a4j:support>
           </h:inputText>
          
           <h:outputText id="myOutput" forceId="true" border="2" value="#{authorizationController.myTestProperty}"></h:outputText>
           </h:panelGrid>
          </a4j:region>
          
          </body>
          </html>
          
          


          Tried it with the Sun JSF RI (Mojarra) and also MyFaces with different versions and browsers. I'm also using Spring and Hibernate.

          Thanks, Lothar

          • 2. Re: Can't generate ajax call from JSF page

            I do not see the form on your page.

            • 3. Re: Can't generate ajax call from JSF page
              merlin-hst

              You're right. I've tried to simplify the page but I've tried it before and now again with a surrounding h:form with no luck ;(

              • 4. Re: Can't generate ajax call from JSF page
                merlin-hst

                Is there any known problem with Apache Tomahawk because I currently use it and can't remove it.

                • 5. Re: Can't generate ajax call from JSF page
                  merlin-hst

                  After hours and days of searching I've found the (?) solution. If I add the following part to my web.xml it works perfect:

                   <filter>
                   <display-name>Ajax4jsf Filter</display-name>
                   <filter-name>ajax4jsf</filter-name>
                   <filter-class>org.ajax4jsf.Filter</filter-class>
                   </filter>
                   <filter-mapping>
                   <filter-name>ajax4jsf</filter-name>
                   <url-pattern>/*</url-pattern>
                   </filter-mapping>
                  

                  Without it I get the described problems. Of course I have the rich faces filter defined.
                   <filter>
                   <display-name>RichFaces Filter</display-name>
                   <filter-name>richfaces</filter-name>
                   <filter-class>org.ajax4jsf.Filter</filter-class>
                   </filter>
                   <filter-mapping>
                   <filter-name>richfaces</filter-name>
                   <servlet-name>Faces Servlet</servlet-name>
                   <dispatcher>REQUEST</dispatcher>
                   <dispatcher>FORWARD</dispatcher>
                   <dispatcher>INCLUDE</dispatcher>
                   </filter-mapping>
                  

                  And no matter if the following part is enabled or not
                   <context-param>
                   <param-name>org.ajax4jsf.VIEW_HANDLERS</param-name>
                   <param-value>com.sun.facelets.FaceletViewHandler</param-value>
                   </context-param>
                  

                  So now it works but I don't now why ;)