You need to sign in to do that
Don't have an account?

Order of Execution method in Command Button
Hi folks,
Can anyone tell me how to execute the action mthod as first and javascript function as second .
My problem is: I have command button which has action method and js function.
I want to execute action function as first like (handle all the validation errors ) and then execute javascript function if there is no valdiation error.
If there is valdiation error then the page still remains same.
For this so far i have tried following
< apex:commandButton value="Next" styleClass="btn btn-success" action="{!tab3}" reRender="TabContent" oncomplete="changeStyle('{!$Component.tab3}','{!$Component.tab2}','{!$Component.tab1}','{!$Component.tab4}');"/>
Here am using oncomplete method but it doesnot work what I expect. Is there anyway to implement ?
Thanks in advance
Karthick
Can anyone tell me how to execute the action mthod as first and javascript function as second .
My problem is: I have command button which has action method and js function.
I want to execute action function as first like (handle all the validation errors ) and then execute javascript function if there is no valdiation error.
If there is valdiation error then the page still remains same.
For this so far i have tried following
< apex:commandButton value="Next" styleClass="btn btn-success" action="{!tab3}" reRender="TabContent" oncomplete="changeStyle('{!$Component.tab3}','{!$Component.tab2}','{!$Component.tab1}','{!$Component.tab4}');"/>
Here am using oncomplete method but it doesnot work what I expect. Is there anyway to implement ?
Thanks in advance
Karthick
The way that you have to approach this is to execute the action method and set a flag to indicate if there were any validation problems. Then you rerender some JavaScript when the action method completes which does whatever it needs to only if the flag indicates no errors occurred :
There's an example of conditionally rendering some JavaScript based on the completion of an action method on my blog at:
http://bobbuzzard.blogspot.co.uk/2011/05/refreshing-record-detail-from-embedded.html