Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

possibility to change action

 
Erik Gothe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am doing a javascript confirmation of a form before submitting doing this:

<a4j:commandButton id="save" reRender="resultPanel,preSaveCheck" value="Save" action="#{attributesItem.save}"
disabled="#{!attributesItem.unsaved}" ajaxSingle="true" onclick="if(!confirmDialog()){return false;}"/>

When confirmDialog returns false i want to revert my changes by calling #{attributesItem.revert}.

is it possible to change action method?
How do I make that happen?
 
Erik Gothe
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I found the solution. I did like this:

<a4j:commandButton id="save" reRender="resultPanel,preSaveCheck" value="Save" action="#{attributesItem.save}"
disabled="#{!attributesItem.unsaved}" ajaxSingle="true" onclick="if(!confirmDialog()){revertSave();return false;}"/>
<a4j:jsFunction name="revertSave" action="#{attributesItem.revert}"/>
 
Tim Holloway
Saloon Keeper
Posts: 18303
56
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Actually, you are probably better off tying that code to onsubmit, rather than onclick. Most of the time, I don't think you will notice the difference, though.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic