2 Replies Latest reply on Jun 17, 2007 9:29 PM by kenees

    Can anybody help me on the JS error

      I'm a newbie on Ajax4JSF, now I'm using SUN JSF RI with Ajax4JSf, with the "Ajax4jsf Developer Guide" I'm trying to get section 4.4 "Simple AJAX Echo Project" worked well. But when I typed something into the input text box to trigger an onkeyup event, I got the JS error "A4J not defined".

      My server container is Tomcat 6.0.13, JDK1.6 and Sun's JSF RI.

      web.xml

      <?xml version="1.0" encoding="UTF-8"?>
      <web-app id="WebApp_ID" 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">
       <display-name>exp_jsf</display-name>
       <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>
       <servlet-name>Faces Servlet</servlet-name>
       <dispatcher>REQUEST</dispatcher>
       <dispatcher>FORWARD</dispatcher>
       <dispatcher>INCLUDE</dispatcher>
       </filter-mapping>
       <servlet>
       <display-name>FacesServlet</display-name>
       <servlet-name>FacesServlet</servlet-name>
       <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
       <load-on-startup>1</load-on-startup>
       </servlet>
       <servlet-mapping>
       <servlet-name>FacesServlet</servlet-name>
       <url-pattern>*.jsf</url-pattern>
       </servlet-mapping>
      </web-app>


      the JSF page
      <!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html>
       <head> <title>Insert Title here</title> </head>
       <%@ page contentType="text/html;charset=UTF-8" %>
       <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
       <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
       <%@ taglib uri="https://ajax4jsf.dev.java.net/ajax" prefix="a4j"%>
       <body bgcolor="white">
       <f:view>
       <h:outputLabel value="Test ajax4jsf"></h:outputLabel>
       <h:inputText value="#{a4j.userInput}">
       <a4j:support event="onkeyup" reRender="label"></a4j:support>
       </h:inputText>
       <br/>
       <h:outputText id="label" value="#{a4j.userInput}"></h:outputText>
       </f:view>
       </body>
      </html>


      generated HTML page source code
      <!DOCTYPE html
      PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
      "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
      <html>
       <head> <title>Insert Title here</title> </head>
      
      
      
      
       <body bgcolor="white">
       <label>
      Test ajax4jsf</label><input type="text" name="j_id_jsp_325866762_2" onkeyup="A4J.AJAX.Submit('j_id_jsp_325866762_0',null,event,{'parameters':{'j_id_jsp_325866762_3':'j_id_jsp_325866762_3'},'actionUrl':'/expjsf/a4jTest.jsf'})" />
      
      
       <br/>
       <span id="label"></span>
       </body>
      </html>
      

      I find there really is not JS defined in the source code of the generated HTML page.Is there something I lost here, Thanks.


        • 1. Re: Can anybody help me on the JS error

          I have changed the web.xml as follow:

          <?xml version="1.0" encoding="UTF-8"?>
          <web-app id="WebApp_ID" 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">
           <display-name>exp_jsf</display-name>
           <context-param>
           <param-name>javax.faces.STATE_SAVING_METHOD</param-name>
           <param-value>server</param-value>
           </context-param>
           <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>
           <servlet-name>Faces Servlet</servlet-name>
           <dispatcher>REQUEST</dispatcher>
           <dispatcher>FORWARD</dispatcher>
           <dispatcher>INCLUDE</dispatcher>
           </filter-mapping>
           <listener>
           <listener-class>
           com.sun.faces.config.ConfigureListener
           </listener-class>
           </listener>
           <servlet>
           <display-name>FacesServlet</display-name>
           <servlet-name>FacesServlet</servlet-name>
           <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
           <load-on-startup>1</load-on-startup>
           </servlet>
           <servlet-mapping>
           <servlet-name>FacesServlet</servlet-name>
           <url-pattern>*.jsf</url-pattern>
           </servlet-mapping>
          </web-app>

          But the problem is still the same, really bothers me, it has taken me several hours on it...

          • 2. Re: Can anybody help me on the JS error

            Problem done.