Commandbutton onclick and actionlistener happen at same time
843844Feb 5 2008 — edited Feb 5 2008I started a thread previously with a similar issue, but the title of that thread really doesn't describe the current problem. Sorry for double posting, but I would delete that thread if I could.
I have a command button as:
<h:commandButton id="saveCloseFoil" type="submit"
onclick="javascript:saveText();"
action="#{Item.saveOptionAction}"
value="#{propertiesBundle.saveCloseSubmitLabel}"
actionListener="#{Item.setFoilTextToBean}" />
The saveText() javascript function copies the text from a text editor to a field defined as:
<h:inputHidden id="hiddenTextField" value="" />
The actionlistener should take the value from the hidden field, and put it in the backing bean. The Action then saves that value in its correct place in the database.
The problem is that the onclick and actionlistener are firing at the exact same time(i am verifying this by using the firefox javascript debugger breakpoints for the javascript and JDeveloper breakpoints for the actionlistener. Both breakpoints stop at the same time.)
The strange thing is that in another place in our applicate we have an almost identical button:
<h:commandButton tabindex="3" type="submit" id="submit"
onclick="javascript:setBrowserSettings();"
action="#{Login.loginAction}"
actionListener="#{Login.setBrowserOSSettings}"
value="#{propertiesBundle.loginLabel}">
</h:commandButton>
in which the onclick is run first, then the actionlistener, then the action. I verified this using the exact same method as with the button I am working on now.