I'm using JSF ajax ( we can NOT change that =\ ) in my application and we need to wait for action from the user. I mean, before call the ajax method, i need ask to the user if he wants to revert all the changes in the page using custom dialog. If he wants to go ahead and revert I will call the Java method by ajax and ok, but if not we dont need to call the ajax.
Let me try be more specific:
This is a code for the revert button for my huge page:
<h:commandButton value="#{msg.revertBtn}" accesskey="R" styleClass="actionButton" action="#{styleController.revertChanges}">
<f:ajax execute="@this" onstart="return method();" render="styleCcFormtyleCcTable">
</h:commandButton>
Before calling the ajax it will run my javascript function: method()
I need have the user stuck in method()
until he clicks in Yes
or Now
button in my custom confirm dialog and then return true or false.
Any idea how to solve that?
I know some of you guys wont agree with me, because I did a huge workaround to have it working.
What I did was:
I created a Custom Confirm Dialog and it has a variable which store the user reply. Then, whenever the user clicks on the button it will be stored there.
So, in the button I added an click function that checks my variable and if it has any reply it goes and do something but it not I call my custom dialog.
And into my custom dialog I am "clicking" in the button, but now with the reply. After that you need to make sure you will erase the variable.
Just that. 2 days doing that o.O Let me know if you guys need the code for that.