Monday, December 12, 2016

Visualforce - Beyond Basics Series 20 - Primitive types pass by value

How values passed to Component?

The values are passed to Component in runtime which means the values are assigned/type checked during execution.

How primitive types are handled ?

The primitive types like String, Number, Date passed to the Component as value. That means, when the client Page changes the value, component won't be affected.


What is the problem ?

Like some programming languages, developers expect the primitive types to be pass by reference. So, that they can change them in the called page any time, to reflect the changes in all the component using them. But, it doesn't work that way.

What is the solution ?

The solution is to use a Custom Class which will act as a wrapper/container for the primitive types.


Where is the code ?

This example illustrates how to pass a DateContainer object to the Component, so that when its value changed in the client page, it gets automatically changed inside the component.

No comments:

Post a Comment

Thanks for reading my blog !