0 Replies Latest reply on Jun 9, 2011 4:34 AM by Nikita Sumeiko

    Which of the events are invoked faster: onclick or call to actionListener?

    Nikita Sumeiko Newbie

      I have <a4j:commandLink> with it's actionListener. Java action, which is invoked, is using value from <h:inputHidden>, as it's connected to BackEnd with binding attribute.

      However, before invoking actionListener action, I need that <h:inputHidden> value would be updated, therefore I am adding small function into onclick event of <a4j:commandLink>, which is updating a value. Here's an example:

      <h:inputHidden id="myHidden" value="" binding="" />

       

      <a4j:commandLink

           onclick="updateHidden('newValue')"

           actionListener="#{...}"

           oncomplete="cleanHidden();"

           render="anyPanel"

           value="Click here"

           execute="@all"

      >

           <f:param name="myParam" />

      </a4j:commandLink>

       

      <script type="text/javascript">

           function updateHidden(value){

                var hidden = "#{rich:component('myHidden')}";

                hidden.val(value);

           }

       

           function cleanHidden(){

                var hidden = "#{rich:component('myHidden')}";

                hidden.val("");

           }

      </script>

      The value in <h:inputHidden> is filled in correctly as I am debugging it via Firebug. However, my actionListener's Java function takes old values instead of updated ones, when I am debugging with Eclipse?!

      Therefore, I came up to a question, which of the events are invoked faster: onclick or call to actionListener, when I am clicking on a link?!

      If they are invoked in the same time, than maybe values are not updated before the BackEnd is called...

       

      Any suggestions on that?