Visualforce is a framework that
allows developers to build sophisticated, custom user interfaces that can be
hosted natively on the Force.com platform. The Visualforce framework includes a
tag-based markup language, similar to HTML, and a set of server-side “standard
controllers” that make basic database operations, such as queries and saves,
very simple to perform.
In
the Visualforce markup language, each Visualforce tag corresponds to a coarse or
fine-grained user interface component, such as a section of a page, a related
list, or a field. The behavior of Visualforce components can either be controlled by
the same logic that is used in standard Salesforce pages, or developers can associate
their own logic with a controller class written inApex.
What is a Visualforce Page?
Developers
can use Visualforce to create a Visualforce page definition. A page definition
consists of two primary elements:
·
Visualforce markup
·
A Visualforce controller
Visualforce Markup
Visualforce markup consists of Visualforce tags, HTML, JavaScript, or any other
Web-enabled code embedded within a single<apex:page> tag. The markup defines the user
interface components that should be included on the page, and the way they
should appear.
Visualforce Controllers
A Visualforce controller is a set of
instructions that specify what happens when a user interacts with the
components specified in associated Visualforce markup, such as when a
user clicks a button or link. Controllers also provide access to the data that
should be displayed in a page, and can modify component behavior.
A
developer can either use a standard controller provided by the Force.com platform, or add custom controller
logic with a class written in Apex:
·
A standard controller consists of the same functionality and
logic that is used for a standard Salesforce page. For example, if you use the standard Accounts
controller, clicking a Save button in a Visualforce page results in the
same behavior as clicking Save on a standard Account
edit page.
If
you use a standard controller on a page and the user doesn't have access to the
object, the page will display a insufficient privileges error message. You can
avoid this by checking the user's accessibility for an object and displaying
components appropriately.
·
A standard list controller enables you to create Visualforce pages that can display or act on a set of records. Examples of
existing Salesforce pages that work with a set of records include list pages,
related lists, and mass action pages.
·
A custom controller is a class written in Apex that implements all of a page's logic, without leveraging a
standard controller. If you use a custom controller, you can define new
navigation elements or behaviors, but you must also reimplement any
functionality that was already provided in a standard controller.
Like
other Apex classes, custom controllers execute
entirely in system mode, in which the object and field-level permissions of the
current user are ignored. You can specify whether a user can execute methods in
a custom controller based on the user's profile.
·
A controller extension is a class written in Apex that adds to or overrides behavior in a standard or custom
controller. Extensions allow you to leverage the functionality of another
controller while adding your own custom logic.
Because
standard controllers execute in user mode, in which the permissions,
field-level security, and sharing rules of the current user are enforced,
extending a standard controller allows you to build a Visualforce page that respects user permissions.
Although the extension class executes in system mode, the standard controller
executes in user mode. As with custom controllers, you can specify whether a
user can execute methods in a controller extension based on the user's profile.
Although
custom controllers and controller extension classes execute in system mode and
thereby ignore user permissions and field-level security, you can choose
whether they respect a user's organization-wide defaults, role hierarchy, and
sharing rules by using the with sharing keywords
in the class definition. For information, see “Using the with sharing or without sharing Keywords” in the Force.com Apex Code Developer's Guide.
Where Can Visualforce Pages Be Used?
·
Override standard buttons, such as the New button for accounts, or the Edit button for contacts
·
Override tab overview pages, such as the Accounts tab home page
·
Define custom tabs
·
Embed components in detail page layouts
·
Create dashboard components or custom help pages
·
Customize, extend, or integrate the sidebars in the Salesforce console (custom console components)
·
Add menu items, actions, and mobile cards in Salesforce1
0 comments:
Post a Comment