Extended Functionality of Visualforce - Part 1
Discover the Advanced Capabilities of Visualforce - Part 1
There's more to Visualforce than pages
Many of you in the Force.com development community are excited about the introduction of Visualforce Pages, and a lot of that excitement has centered around the new flexibility for user interfaces. However the emphasis on the new UI formatting may cause you to overlook some of the cool ways you can create powerful functionality to extend the capabilities of your Force.com applications.
This series of articles will take a look at using Visualforce to implement the functionality of dependent picklists, available through the standard Force.com Builder interface. The next section of this series will walk through the definition of the custom objects that form the foundation of the functionality, as well as the code for the page and controller. The third section of this series will show you the use of the dependent picklists in action - to bring up a report with the selection conditions indicated by the new dependent picklist implementation.
You may be wondering why we would bother to implement something already available - but there are a couple of good reasons.
The task ahead: dependent picklists - plus
Dependent picklists allow an application to control the display of values in a child picklist, based on the value selected in the parent picklist. This capability comes in handy in loads of situations, but there are times when you could use a little more functionality based on this type of dependency.
For instance, you may want to have the value in a picklist be associated with additional data - something you could easily do with additional custom fields in a table. In addition, in order to change values for a picklist, or the dependencies between picklists, you have to go into the Force.com Builder. If you find the values or dependencies change fairly frequently, you may want to avoid this process.
The architecture of the solution
The way to avoid these problems is to use two custom objects, with a relationship between them. Every value that you wanted to display in the dependent picklist would be in the child table, with a relationship to a value in the parent table.
You could give the appropriate people access to these tables through standard Force.com pages, to help in creating the right values to be used in the picklists. This standard technology will make it easy to populate the values desired for the picklists. Once the values are entered, you could easily discover both the values and dependencies through simple SOQL queries on the two related objects.
A couple of solid advantages, in some cases, but there is still that matter of implementation. How do you get the values to display properly in a Force.com page, enforcing the dependencies between values?
What else can you show me?
These articles will walk you through creating a user interface for the picklists, the controller logic to populate them, and their use in the larger context of a Force.com page.
Now that you understand the challenge ahead, we can jump right into the implementation. In addition to creating dependent picklist functionality without these limitations, these articles will hopefully get you more familiar with best practices, tips and techniques for creating your own Visualforce pages and controllers.
So let's get started . . .