,

Controller Extensions

In Chapter 9: Visualforce Pages, you experienced the different granularity of various Visualforce components. For instance, a single set of tags can create an entire detail page. But if you want to change the way a detail page looks beyond the scope of page layouts, you must build the entire Visualforce page using more discrete components.

Visualforce controllers give you similar options, but with a difference. You can build a custom controller with Apex code that replaces all the functionality of a standard controller, and there are times when this approach may be desirable; however, Visualforce also gives you another option, in the form of controller extensions.

A controller extension uses all the functionality in a standard controller. The controller extension expands or modifies that functionality by adding new capabilities or replacing standard capabilities with modified versions of the same actions. With this approach, you do not have to recreate everything that a standard controller does to simply tweak or extend its operation.

In this section, you create a controller extension to handle dynamically populating a picklist based on the value of another picklist. You are, in effect, duplicating the operation of a standard dependent picklist, but in a way that allows you to extend that functionality in the next section.

The dependent picklist adds a value for a position type to each Position record. The values available for this field are dependent on the particular department. For instance, you might have a Developer position in the Engineering department, but not in the Finance department. Time to begin.

Modifying Your Force Platform Database

Your first step is to add an object to your Force Platform database. The Position Type object will contain two fields: the Position Type field, which is the name of a position, and the Department field, which associates the particular Position Type with that Department.

In addition, you need to create a lookup relationship between the Product object and the new Position Type object.

The initialization task described at the start of this chapter created both of these components for you.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.138.37.151