Activity › Forums › Salesforce® Discussions › How immediate attribute work on CommandLinks and CommandButtons in Salesforce?
-
How immediate attribute work on CommandLinks and CommandButtons in Salesforce?
Posted by Parul on August 20, 2018 at 8:03 AMHow immediate attribute work on CommandLinks and CommandButtons in Salesforce?
shariq replied 7 years, 9 months ago 3 Members · 2 Replies -
2 Replies
-
Hi Parul,
By setting immediate to true, validation rules are skipped and the action associated with the CommandLinks and CommandButtons is executed immediately.
You can write it like this:
<apex:CommandLink action=”{!cancelApplication}” value=”Cancel” styleClass=”btn” id=”btnCancel” immediate=”true”>
- [adinserter block='9']
-
Hi,
Visualforce Immediate Attribute on CommandLinks and CommandButtons Technical Explanation :-
- When we don’t want the validation rule to be fire during server request we set this attribute Immediate=”true”.
- Default value of this immediate attribute is false.
- When we are having functionality of Back to previous page or cancel button, where we don’t our validation rules to be fired. In this case if we didn’t set Immediate=”true” where validation rule will get fired and we end up in a state of unable to return to previous page.To avoid this case we need to set Immediate=”true” like below Visualforce Immediate Attribute on CommandLinks and CommandButtons example.
<apex:CommandLink action=”{!cancelMethod}” value=”Cancel Link” styleClass=”btn” id=”btnCancel” immediate=”true”>
<apex:commandButton value=”Cancel” immediate=”true” action=”{!cancelbutton}”/>
- We usually wire this attribute in cancel button to skip validation rules.
Hope this helps.
Log In to reply.