Visualforce Flashcards
What is Visualforce?
Visualforce is a programmatic user interface framework that is used to build complex interfaces that are native to the Salesforce platform
- has it’s own markup language
- can include HTML w/in Visualforce page
- offers standard components (visualforce component library)
- uses server-side Apex controllers to interact with database
How is Visualforce framework able to interact with a database?
- the Visualforce framework makes use of server-side Apex controllers to be able to interact with the database
What static resources?
they are files that are uploaded to and stored within our orgs so that we can reference them and use them throughout the platform
What is the syntax for referencing static resource?
single file
{!$Resource.resourceName}
archived file
{!URLFOR($Resource.archiveName, ‘fileName’)}
What are custom labels?
custom labels can be used in Visualforce, Apex, and in Lightning components
- they allow us to translate a message into the language in the viewing user’s settings, provided that we’ve added support for that language
How to reference Custom Labels?
Reference in Apex by using the System.Label class:
System.Label.Custom_Label_API_Name
Reference in Visualforce by using expression syntax and the $Label global variables:
{!$Label.Custom_Label_API_Name}
What are the different types of Apex controllers?
- standard controller
- standard set controller (i.e. standard list controller)
- controller extension
- custom controller
What is expression syntax?
- expression syntax is used to notify the framework that the value we’re providing is a reference to something else and not meant to be interpreted literally
- syntax: {!referencedValue}
- used w/ action and data binding
What is action binding?
- action binding is the act of coupling a method inside a Visualforce page’s Apex controller to an event on the page through the syntax {!methodName}
What is data binding?
- data binding is act of coupling a variable in the Apex controller to a value on our Visualforce page through the format {!variableName}
What is a Standard Controller?
- a standard controller is a pre-written, Salesforce-made Apex class that provides functionality for our Visualforce pages (similar to lightning data services
- automatically created for custom objects
- same functionality as lightning record pages (save,delete… record)
How do you declare a standardController?
- declared by setting standardController attribute in the opening [apex:page] tag, passing the API name of the object that we want to use the standard controller of
[apex:page standardController=”Account”]{!account.Name}[/apex:page]
What is a Standard Set Controller
- while standard controllers only allow us to interact with one record at a time, the prebuilt standard set controllers allow us to work with groups of records at a single time
- Visualforce pages that use the standard set controller default to displaying at most 20 records per page
- contains methods for pagination
How do you declare Standard Set Controller?
- to declare the use of a standard set controller in a Visualforce page, we’ll set the standardController and recordSetVar attributes in the opening
- standardController takes the API name of the object we’re working with
- recordSetVar takes a variable name that we’ll use to reference the list of records throughout the remainder of our Visualforce page
What is pagination?
- pagination is the act of dividing records into multiple pages so that the user isn’t overwhelmed with a lengthy table
How do you declare Standard Set Controller?
- to declare the use of a standard set controller in a Visualforce page, we’ll set the standardController and recordSetVar attributes in the opening
- standardController takes the API name of the object we’re working with
- recordSetVar takes a variable name that we’ll use to reference the list of records throughout the remainder of our Visualforce page
What is Controller Extensions?
- controller extensions are custom Apex classes that provide further functionality to a Visualforce page while still allowing us to make use of a standard controller
- we can also use controller extensions to override functions from a standard or custom controller
- Visualforce evaluates our controller extensions before looking in the standard or custom controller for our page for the action bound method or data bound variable - this behavior is what allows us to override controller methods with controller extensions
- the Apex class serving as our controller extension will have to adhere to a requirement for its constructor that depends on the type of controller that we’re extending
- if we’re extending a standard controller, our controller extension class constructor must take a single parameter of the ApexPages.StandardController type
- if we’re extending a standard set controller, our controller extension class constructor must take a single parameter of the ApexPages.StandardSetController type
- if we’re extending a custom controller, our controller extension class constructor must take a single parameter of whatever class is serving as our custom controller
How do you declare a Controller Extension?
- to declare the use of a controller extension on a Visualforce page, we’ll populate the extensions attribute in the opening tag with the name of the Apex class serving as that controller extension
- we can include one standard controller, one standard set controller, or one custom controller on a Visualforce page - we can’t use combinations of the three or multiples of any of them
- we don’t have a maximum on the number of controller extensions that we can include in a Visualforce page
How do we declare custom controllers?
- we declare the use of a custom controller in our Visualforce page by setting the controller attribute in the opening tag, passing it the name of the Apex class that’s serving as our custom controller
we can create them in Apex class
Accepting Input with Standard Input Components
- can accept input using standard input components like apex:input
- every input component must be contained within an apex:form
apex: form
apex: inputField value=”{!account.Name}” /apex:inputField
/apex:form
How do you display data?
can display data with standard output components like apex:outputField
How do you display records in Visualforce?
- by using standard components apex:pageBlockTable OR apex:dataTable
- pageBlockTable includes Salesforce-like styling whereas dataTable has no default styling
How do we support inline editing in Visualforce Tables?
by making use of the apex:inlineEditSupport component
How do we support inline editing for individual records?
by including apex:detail component
set the inlineedit attribute to true to support inline editing