3 Replies Latest reply on Dec 27, 2011 10:27 AM by Lu Han

    migrate actionListener of actionParam to 4.1?

    Michael Heinen Newbie

      How can I migrate the actionListener of a nested actionparam from richfaces 3.3.3 to richfaces 4.1?

      The a4j:param tag does not have an actionListener attribute anymore.

      The actionListener is also not called if I move the actionListener to the outer commandbutton.

       

      3.3.3 code:

      <a4j:commandButton render="#{MyController.rerenderIds}"

                         oncomplete="#{MyController.oncompleteIds">

      <t:inputHidden id="hello" forceId="true" value="#{requestScope['hello']}"/>

      <a4j:actionparam name="foo"

                       assignTo="#{requestScope['foo']}"

                       value="#{MyController.someValue}"

                       actionListener="#{MyController.doIt}"/>

      </a4j:commandButton>

       

      Do I have to use a4j:actionListener and provide a separate class for each actionListener?

      Or should I try to use EL2 in order to pass parameters directly into the actionListener?

        • 1. Re: migrate actionListener of actionParam to 4.1?
          Vitaliy Pavlov Novice

          Hi, Michael

           

          Try this solution:

           

          <h:form>

            <t:inputHidden id="hello" forceId="true" value="#{requestScope['hello']}"/>

            <a4j:commandButton render="#{MyController.rerenderIds}"

                       actionListener="#{MyController.doIt}"

                       oncomplete="#{MyController.oncompleteIds}">

               <a4j:param  name="foo"

                           assignTo="#{requestScope['foo']}"

                           value="#{MyController.someValue}"/>

            </a4j:commandButton>

          </h:form>

          • 2. Re: migrate actionListener of actionParam to 4.1?
            Michael Heinen Newbie

            Hi Vitaliy,

            this does not work in my case because a4j:param ist executed after the actionListener of the commandButton.

             

            I found a workaround with a simple f:param tag:

            <f:param id="foo" name="foo" value="#{MyController.someValue}"/>

            foo is set as a request parameter(!) before the actionListener is exeucted and therefore available in the actionListener.

             

            But with f:param I cannot bind values of my backing beans directly. The values are accessible only as request parameters.

             

            Any other idea with Richfaces tags?

            • 3. Re: migrate actionListener of actionParam to 4.1?
              Lu Han Newbie

              <a4j:actionparam name="foo"  assignTo="#{requestScope['foo']}"   value="#{MyController.someValue}"  actionListener="#{MyController.doIt}"/>

              ->

              <a4j:param name="foo"  assignTo="#{requestScope['foo']}"   value="#{MyController.someValue}"  listener="#{MyController.doIt}"/>

               

              Or, you can use jsFunction. More reading: http://community.jboss.org/wiki/UseA4jjsFunctionToProxyTheJavascript