1 Reply Latest reply on Nov 19, 2010 4:26 AM by Ilya Shaikovsky

    Passing Java Script Variable to a4j:commandButton

    Kumar Reddy Newbie

      Hi,

       

      I've a java script function which will return a variable and I need to pass that parameter to the a4j:commandButton action.I tried to pass the parameter as below but that parameter is not being retrieved in the backend bean.Any advise on this?

       

      <script type="text/javascript">
                                           function onContributionWizardAfterAddEntry(entries) {                                   
                                          var uploadedEntry = entries[0].entryId;  
                                          }

      </script>

       

      <a4j:commandButton tabindex="1"
                                              image="../img/submit.gif"
                                              styleClass="uploadersubmit"   
                                              onmouseover="this.src='../img/submit_over.gif';" 
                                              onmouseout="this.src='../img/submit.gif';"
                                              action="#{objectivelistaction.uploadMediaEntry(uploadedEntry'}"                                       
                                              oncomplete="#{rich:component('uploadPanel')}.hide();disabled=true;"
                                              reRender="portfolioList"/>

       

      Thanks,

      Anil

        • 1. Re: Passing Java Script Variable to a4j:commandButton
          Ilya Shaikovsky Master

          something like:

          <script type="text/javascript">
                                               function onContributionWizardAfterAddEntry(entries) {                                   
                                              var uploadedEntry = entries[0].entryId;  
                                              }

          </script>

           

          <a4j:commandButton tabindex="1"
                                                  image="../img/submit.gif"
                                                  styleClass="uploadersubmit"   
                                                  onmouseover="this.src='../img/submit_over.gif';" 
                                                  onmouseout="this.src='../img/submit.gif';"
                                                  action="#{objectivelistaction.uploadMediaEntry(uploadedEntry'}"                                       
                                                  oncomplete="#{rich:component('uploadPanel')}.hide();disabled=true;"
                                                  reRender="portfolioList">

               <a4j:actionparam name="jsparam" escape="false" value="onContributionWizardAfterAddEntry(something)"

          </a4j:commandButton>

          I have not actually checked live but I have just other sample which shows it live http://livedemo.exadel.com/richfaces-demo/richfaces/actionparam.jsf last one there.