GeeCON Prague 2014*
The moose likes JSF and the fly likes possibility to change action Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » JSF
Bookmark "possibility to change action " Watch "possibility to change action " New topic
Author

possibility to change action

Erik Gothe
Greenhorn

Joined: Jan 17, 2013
Posts: 2
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

Joined: Jan 17, 2013
Posts: 2
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

Joined: Jun 25, 2001
Posts: 16101
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
 
GeeCON Prague 2014
 
subject: possibility to change action