[SalesForce] Purpose of apex:commandbutton immediate=”true”

Can someone tell me what exactly are we benefiting from setting this property to true ?.

As per documentation, validation rules will be skipped…does it mean the object's validation rules ?

Also what would be a use case where we would want this ?

Best Answer

Setting immediate=true does not fire getters or setters and skips validation.

An example use case:

-> You have inputfields for a given object with "required=true" or where the field is required.

-> You have a cancel button.

If the user presses the cancel button and immediate=true is not set and the fields are blank, they will get an error that a field is required.

A blog post with the above information and more:

http://www.sfdcpoint.com/salesforce/immediate-attribute-commandbutton-commandlink-visualforce/

Related Topic