3 Replies Latest reply: Jun 29, 2011 6:58 AM by gimbal2 RSS

    valueChangeListener (selectOneListbox)

    872101
      I have a selectOneListbox in a JSP page. I would like to get the new value when the user change it. But now I get it only after I press a button. Is is possible to get is without any procedure?
        • 1. Re: valueChangeListener (selectOneListbox)
          gimbal2
          Well, you can let the select box submit the form on change to fire the valueChangeListener. This will cause a page reload, but no action will be performed:
          <h:selectOneMenu value="#{bean.value}" onchange="this.form.submit();" valueChangeListener="#{bean.valueChangeListener}" immediate="true">
          (the immediate=true is to skip validations - you be the judge if you need it or not).

          Or you can use an Ajax enabled component. If you use JSF 2.0 you don't need anything else as basic Ajax support is built in; if you use JSF 1.2 then a library like Richfaces will provide what you need.
          • 2. Re: valueChangeListener (selectOneListbox)
            872101
            It seems the solution. But I always get the following exception:
            SEVERE: JSF1073: javax.faces.event.AbortProcessingException caught during processing of APPLY_REQUEST_VALUES 2 : UIComponent-ClientId=j_id_id18:j_id_id41, Message=Identity 'CountryBean' does not reference a MethodExpression instance, returned type: beans.CountryBean
            SEVERE: Identity 'CountryBean' does not reference a MethodExpression instance, returned type: beans.CountryBean
            Have you any idea what is wrong?
            • 3. Re: valueChangeListener (selectOneListbox)
              gimbal2
              'CountryBean' does not reference a MethodExpression instance, returned type: beans.CountryBean
              Seems like your EL is wrong. It must resolve to a setter method of a bean while it seems to be resolving to the bean itself. Hard to say without the code.