Monday, December 12, 2016

Visualforce - Beyond Basics Series 13 - Setting property using component

What are all the ways to set properties from Page ?

When the page loads, you can have a action method which will initialize the parameters in the Controller. So, that's the only way to set parameters, as most of the developers know.


What if you cannot edit Controller ?

In some cases, you can't edit Controller, because, there might be some policies in your company to create a new ticket, etc. Or simply you can't because, you need to write more Apex Tests, if you want to deploy changes in Controller.


Is there any other way to set parameters only by changing page ?

yes. When the page gets loaded, after initializing Page's Controller object & all Compenents Controller Objects, Salesforce initializes all Components. That means, we can  use that step to set parameters. It may confuse a bit, but, after looking the code, it will be very easy.

Where is the code ?

For illustration, i have controller with 2 property. Then, a component which will set the property with the value. Then, in the page, we use that component along with the attribute name to assign the value.




No comments:

Post a Comment

Thanks for reading my blog !