1 Reply Latest reply on Aug 24, 2010 2:48 PM by Nick Belaevski

    Retrieve ActionParam in within ValueChangeListener

    Adam Leclerc Newbie

      I have a dropdown in a rich:dataTable that is supposed to update my model class. My entity is a TransCode which points to another lookup table called "TransCodeStatus". I have a dropdown of the statuses that auto-submits to the server using a4j:support.



      <rich:dataTable id="transCodeTable" binding="#{transCodeBean.dataTable}" value="#{transCodeBean.dataList}" var="_tc" rows="10" rowKeyVar="#{transCodeBean.rowKeyVar}">



      <h:selectOneMenu id="transCodeSelect#{_tc.transCd}"
           <f:selectItems value="#{transCodeBean.statusList}" />
           <a4j:support event="onchange" reRender="transCodeTable"
           oncomplete="$('messages').show();setTimeout(function() {$('messages').hide();}, 4000);">
                <a4j:actionparam name="transCode" value="#{_tc}"
                assignTo="#{transCodeBean.itemInEditMode}" />


      The issue is that for logging purposes I need to get the entity that was changed in the valueChangeListener method. I tried passing it into the bean by an Actionparam, but in the method it ends up still being null.



          public void statusChanged(ValueChangeEvent event)



              LOG.debug( "item " + itemInEditMode );



      prints out "item null"


      How can I get that item? Is it because the valueListener is getting executed before the actionParam gets executed? I'm open to other suggestions on how to set this up as well.

        • 1. Re: Retrieve ActionParam in within ValueChangeListener
          Nick Belaevski Master

          Hi Adam,


          Yes, valueChangeListener is called on JSF lifecycle phase that happens earlier than the ones on which actionparam is called. If you use Seam you can pass "_tc" directly into the method, otherwise you have to lookup it manually:


          • via component.getAttributes().get("rowData") invoked on data table (you can extract source component from event and traverse up to the table)
          • via facesContext.getApplication().evaluateExpressionGet(facesContext, "#{_tc}", Object.class)