Top Visualforce Developer Interview Questions and Answers- Here are some of the following Visualforce Interview Questions and Answers that are generally asked in Salesforce interviews.
What is Visualforce?
Visualforce is tag based markup language to develop customized user interface in salesforce.
What is Visualforce controller in salesforce? What are they?
Visualforce controller is a set of instructions that specify what happens, when user interacts with components on visualforce pages, such buttons & links.
There are three types of controllers. They are.
- Standard Controller
- Custom controller
- Controller extensions
What is Standard Controller?
Standard controller provides the salesforce in built functionality to interact with visualforce pages. You can use the standard actions like Save, Edit, Cancel & delete by using standard controllers.
Syntax: <apex:page standardController=”Account”>
What is Standard List Controller?
Standard List Controller allows to display list of records in visualvalfoce page. Standard list controller provides additional pagination actions (First, Lat, Next & Previous) compared to standard controller.
Syntax: <apex:page standardController=”Account” recordSetVar=”accounts”>
What is Custom Controller?
Custom controller is an apex class that implements customized logic to visualfore pages.
We can override or create new functionality by using custom controllers.
Syntax: <apex:page controller=”Account” >
What are the tasks of standard controller?
Standard controllers provides ability to access and interact with structured business data contained in records displays in the proper user interface.
Standard controller tasks: controlling data, controlling actions and controlling navigation.
How can you create visualforce page in salesforce?
We can create visualforce pages in two ways.
- From the setup menu go to Setup-> develop -> Build->Pages-> click on new button to create a page & enter name & code for visualforce page.
- From the vsualforce editor. Enter /apex/pagename at the url & create new page in visualforce editor.
What is <apex:page> tag in visualforce markup?
This tag represents a single visualforce page. Every page must start & end with this tag.
<apex:page>
<!– Body of the page –>
</apex:page>
How can we enable visualforce editor?
We need to check the “development mode” check box at user level to enable visualforce editor.
To enable this, go to user details page check the development mode check box.
What are expressions used in pages to bind in controllers?
Using methods we can bind.
Getter: Will return value from controller to vf page
Setter: Will pass value from vf page to controller
Action: Will redirect to another page.
What is the purpose of controllers?
Controllers provide the data and actions that are available to a Visualforce page.
Which objects have associated standard controllers?
All standard and custom objects that can be accessed via the API have associated controllers.
What is included with each standard controller?
Data: the fields for the associated object record that are API accessible, including the related records (5 up/1 down). Actions: save, delete, view, edit, cancel.
When do you need to go beyond a standard controller and code custom Apex?
If you need data beyond the limits of what is available in the standard controller or actions that go beyond the provided standard actions.
What identifies a controller as being an extension?
The controller must declare a constructor which takes another controller explicitly.
For example: public myControllerExtension(ApexPages.StandardController stdController) {this.acct = (Account)stdController.getRecord(); }
What are the different AJAX action tags? What does each do?
- actionStatus: used to display start and stop statuses of AJAX requests.
- actionSupport: used to call a second component when an event happens to the first component.
- actionPoller: similar to actionSupport, but the event is based on a timer instead of a user action.
- actionFunction: provides support for invoking a controller action from JavaScript code using an AJAX request by defining a new JavaScript function.
- actionRegion: used to demarcate which parts of the page the server should reprocess.
What are the Global Key words?
We have global keywords like component,User,url,current page etc., to access various values from components on page, from user object or from url or from current page fields. To access value from each source, we have different global keywords. One such keyword is explained in above question(!$component)
Various global keywords are:
- URL
- USER
- PROFILE
- Resource
- Component
- Current page
- Page reference etc.
What are static resources?
Static resources are a new type of storage in Salesforce specifically designed for use in Visualforce pages. They are ways to store images, flash files, stylesheets, and other web resources on the Salesforce servers that can be cached for better page performance.
What is the main difference between using dataTable vs. pageBlockTable tags?
PageBlock: For default salesforce standard format.
dataTable: To design customformats
What are attributes? What is the syntax for including them?
Attributes are modifiers to the main tag that belong after the tag name in the start tag.
The syntax is attributeName=“attributeValue”
What are the Rendered, Rerendered and Renderas in Visualforce page?
Render: It’s a Boolean value, It works like “display” property of CSS. Used to show or hide element. (if it is true, it displays the block else it will be hidden)
Rerender: After Ajax which component should be refreshed. For this you need to assign id to field, sections or a block. it’s available on commandlink, commandbutton, actionsupport etc.
RenderAs: Render visualforce page as pdf, doc or excel.
What is the purpose of <script> Tags?
Script tags allow you to create JavaScript (or other types) functions that can be used within your pages
Why are properties helpful in controllers?
Properties can automatically create standard getters and setters while still allowing for their customizations. They save you from both writing the tedious code and reading the clutter when reviewing code.