Monday, December 12, 2016

Visualforce - Beyond Basics Series 19 - Include fields in Std Controller

How Standard Controller works ?

Standard controller is nothing but a standard object which will give access to sObject & all its standard actions. So, this will be applicable to both standard and custom controller.


What fields are included ?

When you load a page for a record by passing id value, standard controller doesn't load with all the fields for the record. Because, that is unnecessary. So, it will fetch only the fields used in visualforce page/components tree.


What are all the ways to include fields ?

So, either you can add the fields in the page using any standard output/input tags (or) you can use addFields() API in standard controller to pass the list of fields in the controller/extension side.

What is the easiest way ?

But, when you don't want to actually display the fields, but what them to process something in Apex Controller/Extension, you could do one of the following trick to force include,

  •   OutputField/inputField with rendered=false
  •   use inputHidden


Where is the code ?

The following example used OutputField & inputHidden tag to actually force including the fields in the Standard Controller.

1 comment:

Thanks for reading my blog !