7 Replies Latest reply on Sep 3, 2010 2:07 AM by danwin

    JS onchange submit not rendered

    danwin

      Hello,

       

      I want to execute some logic by selecting an element from a dropdown list. But the java onchange script (onchange="this.form.submit()") doesn't submit and the page doesn't reload. From the source of the webpage the submit statement is missing. Has anybody a clue why the script get not rendered to the webpage?

       

      My JSP that contains the onchange="this.form.submit()":

       

      <body>  
      <f:view>  
          <h3><center>Welcome to Employee Home Page</center></h3>  
          <h:form>  
              <h3>Select an Employee Number from the drop down:</h3>  
              <br>  
              <br>  
              <h:selectOneMenu id="selEmpNo" onchange="this.form.submit()" valueChangeListener="#{employee.employeeReport}">  
                  <f:selectItem itemLabel="select" />  
                  <f:selectItems value="#{employee.empNoList}" id="emp" />  
              </h:selectOneMenu>  
          </h:form>  
      
      

       

      The HTML source without onchange script:

       

      <body>   
      
          <h3><center>Welcome to Employee Home Page</center></h3>  
          <br>  
          <br>  
      <form id="j_id_jsp_1115269439_1" name="j_id_jsp_1115269439_1" method="post" action="/jsfsample/employee/EmployeeHome.jsp">  
      <input type="hidden" name="j_id_jsp_1115269439_1" value="j_id_jsp_1115269439_1" />    
      
              <h3>Select an Employee Number from the drop down:</h3>  
              <br>  
              <br>  
              <select id="j_id_jsp_1115269439_1:selEmpNo" name="j_id_jsp_1115269439_1:selEmpNo" size="1">   <option value="" selected="selected">select</option>  
          <option value="1">1</option>  
          <option value="2">2</option>  
          <option value="3">3</option>  
      </select>  
      
      

       

      Thanks in advance,

      Daniel

        • 1. Re: JS onchange submit not rendered
          ssilvert

          I tried it and it works for me.

           

          What JBoss AS and JSF version are you using?

           

          Stan

          • 2. Re: JS onchange submit not rendered
            danwin

            Hello Stan,

             

            I am running a JBoss 5.1.0.GA and deploying a jboss-faces.jar within the WEB-INF/lib folder.

             

            Manifest of the JAR:

             

            Manifest-Version: 1.0
            Specification-Title: JBoss
            Created-By: 1.5.0_15-b04 (Sun Microsystems Inc.)
            Ant-Version: Apache Ant 1.6.2
            Implementation-Title: JBoss [Trinity]
            Specification-Vendor: JBoss (http://www.jboss.org/)
            Specification-Version: 4.2.3.GA
            Implementation-Vendor-Id: http://www.jboss.org/
            Implementation-Version: 4.2.3.GA (build: SVNTag=JBoss_4_2_3_GA date=20 0807181417)
            Implementation-Vendor: JBoss Inc.
            Implementation-URL: http://www.jboss.org/

             

            Must the Specification-Version match the JBoss version? I will try it out.

             

            Best regards,

            Daniel

            • 3. Re: JS onchange submit not rendered
              ssilvert

              In general, you should not need to put jboss-faces.jar in WEB-INF/lib.  You should also not need to put an JSF implemenation jars in WEB-INF/lib.  Are you trying to use MyFaces instead of Mojarra?

               

              Stan

              • 4. Re: JS onchange submit not rendered
                danwin

                Hi Stan,

                 

                I have removed the jboss-faces.jar from the lib, compiled and deployed without getting any errors from JBoss. I just added the package because the tutorial I am working through requires. Beside I have installed j2ee 6 but .. unfortunately the submit java script still doesn't get rendered.

                 

                After googling for the signification of "Mojarra" (Sun's JSF Implementation) I can say no, I don't use MyFaces.

                 

                Thanks,

                Daniel

                • 5. Re: JS onchange submit not rendered
                  ssilvert

                  What do you mean by, "I have installed j2ee 6".  JEE6 is not something you can install.  It's a specification that is followed on JBoss AS6, not AS5.

                   

                  If you leave the JSF implementation out of your WAR and just let the built-in Mojarra implementation take over then your page should render properly.  As I said, I have already verified that it works.  Make sure you follow these instructions.

                   

                  Stan

                  • 6. Re: JS onchange submit not rendered
                    danwin

                    I have installed SDK 6. Obviously I misunderstood an answer from another thread where I've also posted a question: http://community.jboss.org/thread/111035?start=15&tstart=0

                     

                    my WEB-INF/libs

                    • jaxen-full.jar
                    • jdbc2_0-stdext.jar
                    • jstl.jar
                    • saxpath.jar
                    • standard.jar
                    • toplink-essentials-agent.jar

                     

                    I followed the JBossWithJSFCDDL instructions and I can't find significant differences.

                     

                    My web.xml

                    <?xml version="1.0" encoding="UTF-8"?>
                    <web-app
                        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
                        xmlns="http://java.sun.com/xml/ns/javaee"
                        xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                        xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
                        http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
                        id="WebApp_ID"
                        version="2.5">

                       <servlet>
                          <servlet-name>javax.faces.FacesServlet</servlet-name>
                          <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>            
                       </servlet>  
                      
                       <servlet-mapping>
                          <servlet-name>javax.faces.FacesServlet</servlet-name>
                          <url-pattern>/employee/*</url-pattern>
                       </servlet-mapping>

                    </web-app>

                    • 7. Re: JS onchange submit not rendered
                      danwin

                      Problem solved. I removed a second jsf-api.jar from "jboss-5.1.0.GA/common" folder - I copied and forgot it there.

                       

                      The only one that must exist is the one at "jboss-5.1.0.GA/server/default/deploy/jbossweb.sar".