This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara on-line!
See this thread for details.
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


Win a copy of OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA forum!
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: 16022
    
  20

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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: possibility to change action