Monday, December 12, 2016

Visualforce - Beyond Basics Series 16 - Use immediate for better performance

What is field validation ?

As you know each input field in the page will be associated to some SObject/Controller parameter with some datatype like String, Date, Number, etc. So, When user fills in the data & submits it, visualforce performs some basic integrity validation to check if field datatype matches the value. Also, it performs requiredness check.


When it is performed ?

This will be performed only when user submits the form with either button click or custom action in the page.

Is it possible to skip that ?

When you submit form, if you are not going to send the values to the server, there's no point in validating them. So, it is possible to skip the validation step by immediate attribute in action functions like,

  • CommandButton
  • CommandLink
  • ActionSupport
  • ActionFunction
  • ActionPollar


What is the advantage of it ?

This will improve the page performance which means that page gets updated quickly. And if you use this very often, the net performance is quite high.


Where is the code ?

In this example, you can see that i have used immediate for Cancel button. Because, while cancelling, we are not going to send any form data to server, so, there's no point of validating it.


No comments:

Post a Comment

Thanks for reading my blog !