Visualforce Concepts

,

The Visualforce technology is an implementation of the model-view-controller architecture pattern, as shown in the figure below. This pattern separates the user interface layer, or view, from the underlying data layer, or model. The connection between the model and the view is the controller layer, which handles the interaction between the user interface and the data.

Figure 150. Model-View-Controller architecture


The model component of Visualforce is typically the data model, which you have been working with throughout the previous portion of this book. The view component of Visualforce are Visualforce pages, the subject of the rest of this chapter, and the controller component is handled by Visualforce components, discussed in this chapter and Chapter 12: Extended Visualforce Components and Controllers

Tip

You can also use Apex classes as the model component for Visualforce, which you will learn about in Chapter 10: Apex.


Visualforce Pages

The user interface layer of Visualforce, representing the view of the model-view-controller architecture, is implemented with Visualforce pages, which are the focus of this chapter. You create Visualforce pages with both standard HTML and a set of special tags that tap into the power of the Force Platform model.

Visualforce tags cover two basic areas of functionality. One group of tags creates user interface objects that are automatically associated with Force Platform objects or that interact with functions implemented on the Force Platform. Another group of tags handles interactions between the page and the Force Platform server without refetching the page, similar to the way that AJAX (asynchronous Java script and XML) operates.

You can combine a Visualforce page with standard Force Platform tabs in your applications. You can integrate a Visualforce page into your application from a number of different points in your application:

  • From a custom tab

  • As an override for a standard tab, replacing a normal display for an object

  • As an override for standard or custom buttons or links

  • Embedded in a detail page layout.

Visualforce Controllers

Visualforce technology can be used to implement both the view and the controller portion of the model-view-controller architecture. The controller portion of Visualforce comes in two varieties. The Force Platform automatically creates a standard controller for every object in your Force Platform database. These standard controllers provide the basic functionality embedded in a Force Platform tab page. The second type of controller is a custom controller, created with Apex code, which you will learn about in Chapter 10: Apex and Chapter 11: Apex and Data.

You can create extensions to a standard controller to deliver additional functionality to your Visualforce pages with Apex code. You can also create custom controllers with Apex code, which handle all the interaction between a Visualforce page and one or more Force Platform objects. Both controller extensions and custom controllers are covered in Chapter 12: Extended Visualforce Components and Controllers, after you have learned about Apex code.

Visualforce controllers run on the Force Platform servers, maintaining the Platform-as-a-Service architecture while expanding the functionality of your Force Platform applications. The actual Visualforce pages are rendered in straight HTML, which means you do not have to write extensive amounts of client-side code to implement any type of interaction you need for your applications.

Visualforce and s-controls

If you have been using the Force Platform for a while, you are probably familiar with a technology known as s-controls. S-controls use client-side browser technologies, like Javascript and Flex, to replace or augment standard Force Platform interfaces. These technologies use the Force Platform API to interact with data in Force Platform objects. An s-control uses the Force Platform API to interact with Force Platform data. S-controls can be placed on detail pages, be used to replace tabs, or the destination of standard or custom buttons or links.

Developers use s-controls to implement functionality that is beyond the scope of the standard Force Platform components, but there are a few problems:

  • An s-control runs on the client. The code for an s-control is included in the HTML page requested as part of a Force Platform application. This architecture can lead to potentially large pieces of client-side code that can impact performance, as well as being problematic to maintain.

  • An s-control lives outside of the Force Platform environment. This simple fact means that you must re-implement a lot of the standard look, feel, and functionality that is part of the standard Force Platform environment as soon as you move to an s-control.

  • This disconnected nature also means that code in the s-control is fragile and subject to failure when administrators change fields or accessibility rules for Force Platform data, or that the s-control needs to dynamically confirm data attributes and session status with lots of additional other API calls.

  • And whenever an s-control has to modify data, that data is retrieved to the client, changed and then sent back to the Force Platform servers, which could have a significant performance impact.

Visualforce is intended to completely eliminate the need for s-controls, without any of these issues. Visualforce pages automatically use the look and feel of standard Force Platform tabs, as you will see in this chapter, while still giving you the option of extending or modifying this look and feel. Visualforce pages can access standard Force Platform functionality with a simple set of tags. And Visualforce custom controllers allow you to extend the functionality of the standard environment with the productivity of Apex code, while still running on the Force Platform servers. So if you do know s-controls, you should look to Visualforce as the way to implement the same functionality. If you don’t know s-controls, you don’t really have to learn them.


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

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