I'm using JSF OpenFaces, and I have an Ajax call in a command button.
This Ajax call, calls a Java method, and it has onsuccuess
and onfailure
attributes.
<o:commandLink value="Save" id="SaveButton"
action="#{operationController.save}"
onsuccess="#Do something#"
onerror="#Do something else#"/>
The java is quite simple:
public void save() {
if(case1)
doAction1();
else if(case2)
doAction2(); //throw new error?
}
What I want to do, without sending the event to the Java method (due to code\signature limitation), is to invoke 1 JS function in case1 and another JS function in case2.
I thought about throwing an error in case2 and then I know it will go to the onerror
attribute, but I don't think it's a good practice.
I thought about putting an if
inside the onsuccess
but I don't know what can I check there.
What else can I do?
Thanks