1 Reply Latest reply: May 18, 2012 1:03 AM by graham777 RSS

<a4j:ajax event="valueChange" render="second" execute="@this" /> not working

mihirpatro Newbie

Hi ,

<a4j:ajax event="valueChange" render="second" execute="@this" /> is not working and even I have tried with selectitem both are not working not populating the 2nd one.please find the code as below

 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<ui:composition xmlns="http://www.w3.org/1999/xhtml"

    xmlns:h="http://java.sun.com/jsf/html"

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

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

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

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

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

    <h:form>

        <h:selectOneMenu value="#{selectsBean.currentType}"

            valueChangeListener="#{selectsBean.valueChanged}">

            <f:selectItems value="#{selectsBean.firstList}" />

            <a4j:ajax event="valueChange" render="second" execute="@this" />

           

        </h:selectOneMenu>

        <a4j:outputPanel id="second" >

            <h:selectOneMenu value="#{selectsBean.currentType}"

                rendered="#{not empty selectsBean.currentType}">

                <f:selectItems value="#{selectsBean.secondList}" />

            </h:selectOneMenu>

        </a4j:outputPanel>

    </h:form>

</ui:composition>

 

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_3_0.xsd" id="WebApp_ID" version="3.0">

  <display-name>richface</display-name>

  <welcome-file-list>

    <welcome-file>dynamicselect.xhtml</welcome-file>

    </welcome-file-list>

  <servlet>

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

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

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

  </servlet>

  <servlet-mapping>

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

    <url-pattern>/faces/*</url-pattern>

  </servlet-mapping>

 

<servlet>

 

    <servlet-name>Resource Servlet</servlet-name>

    <servlet-class>org.richfaces.webapp.ResourceServlet</servlet-class>

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

</servlet>

    <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>*.faces</url-pattern>

    </servlet-mapping>

    <servlet-mapping>

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

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

    </servlet-mapping>

<servlet-mapping>

    <servlet-name>Resource Servlet</servlet-name>

    <url-pattern>/org.richfaces.resources/*</url-pattern>

</servlet-mapping>

  <context-param>

    <description>State saving method: 'client' or 'server' (=default). See JSF Specification 2.5.2</description>

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

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

  </context-param>

  <context-param>

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

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

  </context-param>

  <context-param>

    <param-name>org.richfaces.resourceOptimization.enabled</param-name>

    <param-value>true</param-value>

</context-param>

<!-- Plugging the "Blue Sky" skin into the project -->

 

<context-param>

   <param-name>org.richfaces.SKIN</param-name>

   <param-value>blueSky</param-value>

</context-param>

<!-- Making the RichFaces skin spread to standard HTML controls -->

<context-param>

      <param-name>org.richfaces.CONTROL_SKINNING</param-name>

      <param-value>enable</param-value>

</context-param>

<!-- Defining and mapping the RichFaces filter -->

<!--<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>

--><listener>

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

  </listener>

</web-app>

 

faces-config.xml

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

 

<faces-config

    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-facesconfig_2_0.xsd"

    version="2.0">

    <application>

        <message-bundle>resources.application</message-bundle>

        <locale-config>

            <default-locale>en</default-locale>

        </locale-config>

    </application>

    <managed-bean>

        <managed-bean-name>selectsBean</managed-bean-name>

        <managed-bean-class>com.richface.SelectsBean</managed-bean-class>

        <managed-bean-scope>request</managed-bean-scope>

    </managed-bean>

    </faces-config>

 

and following jar files are available in my \WebContent\WEB-INF\lib

javax.faces.jar (version 2.1.7 )

jsf-api-2.1.7.jar

jsf-impl-2.1.7.jar

        guava.jar (version 10.0.1)

        cssparser.jar (version 0.9.5)

        sac.jar (version 1.3)

       validation-api.jar (version 1.0.0.GA)

        hibernate-validator.jar (version 4.2.0.)

        atmosphere-runtime.jar (version 0.8.4)

        jms.jar (version 1.1)

        hornetq-jms.jar (version 2.2.7.)

        cdi-api.jar (version 1.0-SP4)

        javax.inject.jar (version 1)

        jsr-250-api.jar (version 1.0)

        ehcache.jar (version 1.6.0)

  • 1. Re: <a4j:ajax event="valueChange" render="second" execute="@this" /> not working
    graham777 Newbie

    I think that the event that you want is

     

    <a4j:ajax event="change" render="second" execute="@this" />

     

    I tried this in my RichFaces 4.2.2 environmeng and I get errors when rendering the page if the event specified is not valid, but it does work with "change".

     

    I have a similar example where a second drop down depends on the first.  I am using <rich:select> but just changed to selectonemenu and everything worked using the "change" event.