Visualforce Flashcards

1
Q

What is Visualforce?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How is Visualforce framework able to interact with a database?

A
  • the Visualforce framework makes use of server-side Apex controllers to be able to interact with the database
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What static resources?

A

they are files that are uploaded to and stored within our orgs so that we can reference them and use them throughout the platform

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is the syntax for referencing static resource?

A

single file

{!$Resource.resourceName}

archived file

{!URLFOR($Resource.archiveName, ‘fileName’)}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are custom labels?

A

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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to reference Custom Labels?

A

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}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are the different types of Apex controllers?

A
  • standard controller
  • standard set controller (i.e. standard list controller)
  • controller extension
  • custom controller
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is expression syntax?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is action binding?

A
  • 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}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is data binding?

A
  • data binding is act of coupling a variable in the Apex controller to a value on our Visualforce page through the format {!variableName}
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a Standard Controller?

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you declare a standardController?

A
  • 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]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a Standard Set Controller

A
  • 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 well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you declare Standard Set Controller?

A
  • 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
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is pagination?

A
  • pagination is the act of dividing records into multiple pages so that the user isn’t overwhelmed with a lengthy table
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How do you declare Standard Set Controller?

A
  • 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
17
Q

What is Controller Extensions?

A
  • 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
18
Q

How do you declare a Controller Extension?

A
  • 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
19
Q

How do we declare custom controllers?

A
  • 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

20
Q

Accepting Input with Standard Input Components

A
  • 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

21
Q

How do you display data?

A

can display data with standard output components like apex:outputField

22
Q

How do you display records in Visualforce?

A
  • by using standard components apex:pageBlockTable OR apex:dataTable
  • pageBlockTable includes Salesforce-like styling whereas dataTable has no default styling
23
Q

How do we support inline editing in Visualforce Tables?

A

by making use of the apex:inlineEditSupport component

24
Q

How do we support inline editing for individual records?

A

by including apex:detail component

set the inlineedit attribute to true to support inline editing

25
Q

What are Wrapper Classes?

A
  • wrapper classes are Apex classes that are used to collect multiple values in a single object to allow us to make a custom data type
  • we can use wrapper classes to display tables of data in our Visualforce pages that mix lists of records with other properties
26
Q

apex:param

A

allows us to pass a parameter to its parent

27
Q

How would we dynamically instantiate Visualforce components?

A
  • we can dynamically instantiate Visualforce components by using the apex:dynamicComponent
28
Q

What’s the advantage of Dynamic Binding?

A

to use a dynamic binding so that our expression syntax is evaluated at runtime rather than compile time

29
Q

How does Visualforce support partial page rendering?

A
  • apex:actionSupport allows us to asynchronously refresh components within certain portion of our page
  • if we’re using an [apex:commandLink] or [apex:commandButton], we can specify the reRender attribute of these components to be able to refresh select portions of our page whenever these components are clicked
30
Q

What are Visualforce wizards

A
  • Visualforce wizards are sets of pages that guide users through a process one step at a time, with a different page for each step
  • to make a Visualforce wizard, we create a page for each step and use the same custom controller for each page
  • we can include buttons to take users to the next or previous step in a process by action binding them to controller methods that return a PageReference
31
Q

What is the View State?

A
  • the view state is a hidden form field that’s included on our Visualforce pages and describes the state (i.e. size, type, name, and/or value) of components on our page, values referenced in fields on our page, and objects instantiated within standard and custom controller code
  • the server uses it as a base to then apply changes to in response to the user interaction that occurred
32
Q

Visualforce Best Practices

A

view state size limit is 170kb so we want to minimize it

  • writing selective SOQL queries so that our controller’s variables are as small as they can be
  • using the transient keyword as appropriate
    • transient variables aren’t included in view state
33
Q

How to test Visualforce Pages

A
  • to test a Visualforce page, we’ll often go through manual testing with the page itself to ensure that it looks and functions as we desire
  • for any custom Apex code that we create for the page (whether a controller or controller extension), we’ll write appropriate test coverage in an Apex test class
34
Q

How to create multiple tabs within our page?

A
  • to create multiple tabs within our page, we’ll make use of two standard Visualforce components - and
35
Q

Attributes in apex:page

A
  • to make use of a standard controller, we specify the standardController attribute in our opening [apex:page] tag, passing it the API name of the object that we want to work with
  • to make use of a standard set controller, we specify the standardController and recordSetVar attributes in our opening [apex:page], passing the API name of the object that we want to work with and a name for the variable that will hold the collection of records from the standard set controller, respectively
  • to make use of a controller extension or (extensions), we specify the extensions attribute in our opening [apex:page], passing the name(s) of the Apex class(es) that we’re using
  • to make use of a custom controller, we specify the controller attribute in our opening [apex:page], passing the name of the Apex class that we’re using

we can pass a value of pdf to the renderAs attribute to have our page rendered as a PDF