10 Replies Latest reply on Apr 14, 2013 7:47 AM by najumu

    a4j:ajax for textbox not working

    knkpchari

      Hello Everybody,

       

      I am migrating to richfaces 4 where as i am facing problem with <a4j:ajax /> for h:inputtextbox with "keyup" action. I am not getting the required output and nt even getting any errors in console. When i tried for <a4j:commandButton /> it is working fine. Can any one help me out, what might be the problem.

       

      Regards,

      Naveen

        • 1. Re: a4j:ajax for textbox not working
          knkpchari

          Hi,

           

          I am able to add other ajax functionality in my application where as still facing problem calling a4j:ajax for inputtext no luck. Any suggestion what i have to do.

           

          Regards,

          Naveen

          • 2. Re: a4j:ajax for textbox not working
            jhuska

            Hello Naveen,

             

            I am not sure whether there is a component h:inputTextBox, is there ? Could you please share your code with use ?

            • 3. Re: a4j:ajax for textbox not working
              rhanus

              following code snippet works for me fine

              - when I insert a char into "inputFilter" the button is enabled immediately

              - when the button "x" is pressed then input text is cleared and the button is disabled

              <h:inputText id="inputFilter" value="#{myBean.filter}">

                   <a4j:ajax event="keyup" render="clearFilter,table"/>

              </h:inputText>

              <a4j:commandButton id="clearFilter" value="x"

                                                     action="#{myBean.clearFilter()}"

                                                     disabled="#{empty myBean.filter}"

                                                     execute="@this"

                                                     render="inputFilter,table,@this"/>

              ....

              <rich:extendedDataTable id="table"

               

              • 4. Re: a4j:ajax for textbox not working
                knkpchari

                Thanks for your response.

                 

                Hi Juraj,

                 

                I typed it wrongly as h:inputtextbox where as i am using h:inputtext only.

                 

                Hi Radim,

                 

                My code is below it is not working.

                </rich:panel>

                        <h:panelGrid columns="2">

                           <h:outputText value="Text:" />

                           <h:inputText value="#{SuccessUser.user1}" >

                           <a4j:ajax event="keyup" render="text" oncomplete="true"></a4j:ajax></h:inputText>

                          <h:outputText value="Echo:" />

                          <h:outputText id="text" value="#{SuccessUser.user1}" />

                       </h:panelGrid>

                       </rich:panel>

                 

                Regards,

                Naveen

                • 5. Re: a4j:ajax for textbox not working
                  rhanus

                  the simplest working sample is here

                  • 6. Re: a4j:ajax for textbox not working
                    knkpchari

                    Hi Radim,

                     

                    i tried the code from that example only. I saw there are few problems in richfaces 4.3.1. Below is my web.xml file

                     

                    <?xml version="1.0" encoding="UTF-8"?>

                     

                    <web-app id="WebApp_ID" version="3.0"

                    xmlns="http://java.sun.com/xml/ns/javaee"

                    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

                    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd">

                    <display-name>Test</display-name>

                     

                            <context-param>

                                <param-name>javax.faces.CONFIG_FILES</param-name>

                                <param-value>/WEB-INF/faces-config.xml</param-value>

                            </context-param>

                     

                            <context-param>

                                <param-name>contextConfigLocation</param-name>

                                <param-value>/WEB-INF/Test-servlet.xml</param-value>

                            </context-param>

                     

                            <servlet>

                                <servlet-name>HrManagement</servlet-name>

                                <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>

                                <load-on-startup>0</load-on-startup>

                            </servlet>

                     

                            <context-param>

                             <param-name>javax.servlet.jsp.jstl.fmt.localizationContext</param-name>

                             <param-value>resources.application</param-value>

                            </context-param>

                     

                            <context-param>

                                <param-name>javax.faces.STATE_SAVING_METHOD</param-name>

                                <param-value>client</param-value>

                            </context-param>

                     

                            <listener>

                             <listener-class>com.sun.faces.config.ConfigureListener</listener-class>

                            </listener>

                     

                            <listener>

                                <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

                            </listener>

                     

                            <listener>

                                <listener-class>org.springframework.web.context.request.RequestContextListener</listener-class> 

                            </listener>

                     

                            <!-- Just here so the JSF implementation can initialize, *not* used at runtime -->

                            <servlet>

                                <servlet-name>Faces Servlet</servlet-name>

                                <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>

                                <load-on-startup>1</load-on-startup>

                            </servlet>

                     

                            <!-- Just here so the JSF implementation can initialize -->

                            <servlet-mapping>

                                <servlet-name>Faces Servlet</servlet-name>

                                <url-pattern>*.jsf</url-pattern>

                            </servlet-mapping>

                     

                            <servlet-mapping>

                                <servlet-name>Faces Servlet</servlet-name>

                                <url-pattern>*.xhtml</url-pattern>

                            </servlet-mapping>

                     

                            <welcome-file-list>

                                <welcome-file>index.jsp</welcome-file>

                            </welcome-file-list>

                    </web-app>

                     

                    My faces-config.xml is as below :

                     

                    <faces-config>

                    <application> 

                            <variable-resolver> 

                                org.springframework.web.jsf.DelegatingVariableResolver  

                            </variable-resolver> 

                         </application>

                         <lifecycle>

                            <phase-listener>com.naveen.module.jsf.SessionExpirationPhaseListener</phase-listener>

                        </lifecycle> 

                    </faces-config>

                     

                    my page after login is success.xhtml the code is below for this.

                     

                    <!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:h="http://java.sun.com/jsf/html"

                          xmlns:a4j="http://richfaces.org/a4j"

                          xmlns:rich="http://richfaces.org/rich"

                          xmlns:f="http://java.sun.com/jsf/core"

                          xmlns:ui="http://java.sun.com/jsf/facelets">

                     

                    <h:head/>

                    <body>

                        <h:form>

                            <f:facet name="header">

                            Ajax Test

                            </f:facet>

                            <h:panelGrid columns="2">

                               <h:outputText value="Text:" />

                               <h:inputText value="#{SuccessUser.user1}" >

                               <a4j:ajax event="keyup" render="text" oncomplete="true"></a4j:ajax></h:inputText>

                              <h:outputText value="Echo:" />

                              <h:outputText id="text" value="#{SuccessUser.user1}" />

                           </h:panelGrid>

                        </h:form>

                    </body>

                    </html>

                    • 7. Re: a4j:ajax for textbox not working
                      jhuska

                      I tried the code from success.xhtml page facelet. It worked for me. I used ViewScoped managed bean. So the problem is somewhere else.

                       

                      Have you tried to run withour Spring support ? I guess that the error will be somewhere there.

                      • 8. Re: a4j:ajax for textbox not working
                        rhanus

                        I don't see any problems in richfaces-4.3.1 in that particular case, it should work

                         

                        try to create a simple richfaces project by using maven archetype:

                        mvn archetype:generate

                        -DarchetypeGroupId=org.richfaces.archetypes

                        -DarchetypeArtifactId=richfaces-archetype-simpleapp

                        -DarchetypeVersion=<version>

                        -DgroupId=<groupId>

                        -DartifactId=<artifactId>

                        compile and package it;

                        mvn clean package -P jee6

                        and finally deploy it

                        this simple webapp does what you want

                        • 9. Re: a4j:ajax for textbox not working
                          knkpchari

                          Hi Juraj,

                           

                          Thanks for you reply. I tried a simple application it worked fine for that. I am also thinking ther emight be some thing else which is creating problem.

                          Is any one tried to integrate spring with richfaces-4.3.1, any examples for this. One thing which i notice is when i am working with spring application

                          request is not reaching to managed beans why i dont know exactly, this is the main problem i am facing.

                           

                          Hi Radim,

                           

                          I will try to work on maven as suggested by you. Thanks for your response.

                           

                          Regards,

                          Naveen

                          • 10. Re: a4j:ajax for textbox not working
                            najumu

                            I solved above isuue, just adding a <h:form> to it. so the resultant code will be

                             

                            </rich:panel>

                                    <h:panelGrid columns="2">

                                       <h:outputText value="Text:" />

                                           <h:form>

                                             <h:inputText value="#{SuccessUser.user1}" >

                                             <a4j:ajax event="keyup" render="text" oncomplete="true"></a4j:ajax></h:inputText>

                                           </h:form>

                                      <h:outputText value="Echo:" />

                                      <h:outputText id="text" value="#{SuccessUser.user1}" />

                                   </h:panelGrid>

                              </rich:panel>