5 Replies Latest reply on Jun 27, 2012 4:53 AM by Juraj Húska

    How to get the selected value from rich:select using  listener?

    Sabarinath Selvaraj Newbie

      I am trying to get the selected option value from rich:select  using listener,when i change the options my listener method is not invoked and server showing some errors.

       

      Here is my code

      <h:form>

       

      <h:outputText value="Select Item" />

      <rich:select id="dropDownList1" value="#{SampleManagedBean.selectedItemId}" enableManualInput="false"  defaultLabel="Select an Item" immediate="true"  required="true" >

      <f:selectItems id="selectItems" value="#{SampleManagedBean.itemList}"  var="itemDetail" 

                 itemValue="#{itemDetail.itemId}" itemLabel="#{itemDetail.itemName}"  >

      </f:selectItems>

      <a4j:ajax event="change" listener="#{SampleManagedBean.itemChangeListener}"  immediate="true" execute="@this"/>

      </rich:select>

       

      </h:form>

       

       

      Here is the listener method

       

      public void setItemChangeListener(AjaxBehaviorEvent abe)
      {
      long itemId =(Long) abe.getNewValue();

       

      System.out.println("Selected Item"+itemId);

       

      }

       

       

      the stack trace is

      com.sample.SampleManagedBean@1e50761.itemChangeListener(): javax.el.MethodNotFoundException:

      at com.sun.faces.facelets.el.TagMethodExpression.invoke(TagMethodExpression.java:109) [jsf-impl-2.1.7-jbossorg-2.jar:]

      at org.ajax4jsf.component.behavior.MethodExpressionAjaxBehaviorListener.processAjaxBehavior(MethodExpressionAjaxBehaviorListener.java:71) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

      at javax.faces.event.AjaxBehaviorEvent.processListener(AjaxBehaviorEvent.java:113) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      at javax.faces.component.behavior.BehaviorBase.broadcast(BehaviorBase.java:106) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      at org.ajax4jsf.component.behavior.AjaxBehavior.broadcast(AjaxBehavior.java:348) [richfaces-components-ui-4.2.2.Final.jar:4.2.2.Final]

      at javax.faces.component.UIComponentBase.broadcast(UIComponentBase.java:760) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      at javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      at javax.faces.component.UIViewRoot.processDecodes(UIViewRoot.java:935) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      at com.sun.faces.lifecycle.ApplyRequestValuesPhase.execute(ApplyRequestValuesPhase.java:78) [jsf-impl-2.1.7-jbossorg-2.jar:]

      at com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101) [jsf-impl-2.1.7-jbossorg-2.jar:]

      at com.sun.faces.lifecycle.LifecycleImpl.execute(LifecycleImpl.java:118) [jsf-impl-2.1.7-jbossorg-2.jar:]

      at javax.faces.webapp.FacesServlet.service(FacesServlet.java:593) [jboss-jsf-api_2.1_spec-2.0.1.Final.jar:2.0.1.Final]

      at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:329) [jbossweb-7.0.13.Final.jar:]

      at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:248) [jbossweb-7.0.13.Final.jar:]

      at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:275) [jbossweb-7.0.13.Final.jar:]

      at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:161) [jbossweb-7.0.13.Final.jar:]

      at org.jboss.as.web.security.SecurityContextAssociationValve.invoke(SecurityContextAssociationValve.java:153) [jboss-as-web-7.1.1.Final.jar:7.1.1.Final]

      at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:155) [jbossweb-7.0.13.Final.jar:]

      at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102) [jbossweb-7.0.13.Final.jar:]

      at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109) [jbossweb-7.0.13.Final.jar:]

      at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:368) [jbossweb-7.0.13.Final.jar:]

      at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:877) [jbossweb-7.0.13.Final.jar:]

      at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:671) [jbossweb-7.0.13.Final.jar:]

      at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:930) [jbossweb-7.0.13.Final.jar:]

      at java.lang.Thread.run(Thread.java:619) [rt.jar:1.6.0_06]

       

       

      what may be the problem?