Visualforce Interview Questions

Visualforce page is a framework specially designed for Salesforce used to create custom UI. It looks similar to a web page or any markup language such as HTML. Salesforce already has some standard pages such as detail page, related list page, reports, and dashboards. However, sometimes, we need a custom form or page to take input from the user or populate data dynamically. In those cases where Salesforce has four things: Lightning component, Lightning flow, Lightning web component, and or Visual force page (VF Page). The first UI framework for custom UI is the VF page.

Visualforce Interview Questions

 1. What is Visualforce? 

 Visualforce is tag based markup language to develop customized user interface in salesforce. 

 2. What is visualforce controller in salesforce? What are they? 

 Visualforce controller is a set of instructions that specify what happens when the user interacts with components on visual force pages, such as buttons & links. There are three types of controllers. They are. 

  • Standard Controller.
  • Custom controller.
  • Controller extensions. 

 3. What is Standard Controller? 

 The standard controller provides the salesforce in-built functionality to interact with Visualforce pages. You can use standard actions like Save, Edit, Cancel & delete by using standard controllers. 

Syntax : <apex:page standardController=”Account”> 

 4. 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”> 

Defining this controller is similar to standard controller. But need to add one more attribute recordSetVar 

 5. What is Custom Controller? 

 Custom controller is an apex class that implements customized logic to VisualForce pages. 

We can override or create new functionality by using custom controllers. 

Syntax: <apex:page controller=”Account” > 

 6. Can we use standardController & controller attributes at a time? 

 No, We cannot reference both attributes at a time. 

See below syntax to under stand 

<apex:page standardController=”ControllerName” extensions=”Class1, Class2,..”> Correct 

<apex:page Controller=”MYControllerName” extensions=”Class1, Class2,..”> Correct syntax 

<apex:page standardController=”MYControllerName” Controller=”MyController”> Wrong 

 7. 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. 

 8. How can you create VisualForce page in Salesforce? 

We can create VisualForce pages in two ways. 

1. From the setup menu go to Setup-> develop -> Build->Pages-> click on new button to create a page & enter name & code for VisualForce page. 

2. From the VisualForce editor. Enter /apex/pagename at the url & create new page in VisualForce editor. 

 9. 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> 

 10. 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. 

 11. 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. 

 12. What is the purpose of controllers? 

 Controllers provide the data and actions that are available to a Visualforce page. 

 13. Which objects have associated standard controllers? 

 All standard and custom objects that can be accessed via the API have associated controllers 

 14. 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. 

 15. 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. 

 16. Compare and contrast custom controllers and controller extensions. How are they the same? How are they different? 

 Both allow for custom code to be used, allowing for custom data sets and custom actions. Extensions leverage the existing data and actions within a standard or custom controller. 

Custom controllers must contain all data and actions that need to be executed by the page. Extensions that extend standard controller allow for the pages which use those extensions to be used in custom buttons, standard button overrides, and over declarative features. 

 17. 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(); } 

 18. 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. 

 19. In what order do methods fire within a controller? 

 The only rule is that setters fire before action methods. Aside from that, there is no guaranteed order. 

 20. What are some Apex classes that are commonly used within controllers? 

 StandardController, SelectOption, PageReference, Message, etc. 

 21. How are wizard controllers different from other controllers? 

 The two main issues is that they must handle multiple pages and they must maintain the state across those pages. 

 22. What are the effects of using the transient key word? 

 The transient key word prevents the data from being saved into the view state. This should be used for very temporary variables. 

 23. When is a component controller required for custom components? 

 A component controller is required when business logic is required to decide how to render the component. 

 24. What kind of content can be included in a Visualforce page? 

 Any content that can be rendered in a browser (HTML, JavaScript, etc.). 

 25. What do {!expressions} refer to when used in Visualforce components? 

 Expressions refer to either data or actions that are made available to the page from the controller 

 26. What are the ways that Visualpages can be incorporated into the rest of your user interface? 

 Basically, via links, buttons, tabs, and inline frames. 

 27. Is it always necessary to know Apex to create Visualforce pages? When does it become necessary? 

 No, it is not always necessary. You can use standard controllers and VF component tags to accomplish quite a bit. Apex becomes necessary when you need either a custom set of data or custom actions to be available from the page. 

 28. 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” 

 29. What are three types of bindings used in Visualforce? What does each refer to? 

 Data bindings refer to the data set in the controller. Action bindings refer to action methods in the controller. Component bindings refer to other Visualforce components 

 30. What is the main difference between using dataTable vs. pageBlockTable tags? 

 PageBlock: For default salesforce standard format. dataTable:To design customformats 

 31. Which tag is used with both radio buttons and picklists to create the selectable values? 

 <Apex:selectoption> tag 

 32. How many controllers can a page have? Where is the controller for a page assigned? 

 One main controller (of course, it could have extensions or custom components could have controllers, etc.). The controller is assigned in the <apex:page> tag. 

 33. There are a series of layout components that all help recreate the traditional Salesforce page layout style very easily. What name do they share? 

 pageBlock. 

 34. Which tags should be used to automatically bring in the Salesforce label and default widget for a field? 

 pageblock 

 35. 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. 

 36. What are some examples of JavaScript Events? 

 Onmouseover, onclick etc. 

 37. What is AJAX typically used for in Visualforce 

 AJAX is primarily used for partial page updates in Visualforce. In s-controls, the AJAX toolkit was the soap (XML over HTTP) client that gave you access to the force.com Web Services API. 

 38. 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 

 39. 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. 

 40. How can you create partial page refreshes? 

 Basically, you need to define the section of the page that is going to refresh (typically with a panel of sorts), and then define the event that will cause the refresh. The method changes depending on if the area being refreshed is the same as the one handling the event. It also depends on if you are just processing something on the server, or if you need the UI to change. 

 41. Which tag is used with both radio buttons and picklists to create the selectable values? 

 <apex:selectOption> 

 42. What is the purpose of creating attributes on components? 

 By allowing the component to take parameters via an attribute, you can make the component more flexible and reusable 

 43.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: i. URL ii. USER iii. PROFILE iv. Resource v. Component vi. Current page vii. Page reference etc. 

 44.How can you access VisualForce components values into a JavaScript? 

 Using Component global variable, we can access VisualForce components in JavaScript. Let us suppose, we want to use id of an apex field with id=”afield”. 

So, we can use the {!$Component. Afield} syntax to use properties of the field in JavaScript. Let us suppose, we want to store the field’s value in java script, then we can use like below: 

<script> Var a =’ document.getElementById(‘{!$component.afield}’).value’; </script> 

 45.What are the Governor Limits in Salesforce.com? 

 Because Apex runs in a multitenant environment, the Apex runtime engine strictly enforces a number of limits to ensure that runaway scripts do not monopolize shared resources. 

These limits, or governors, track and enforce the statistics outlined in the following table. If a script ever exceeds a limit, the associated governor issues a runtime exception that cannot be handled. 

Visualforce Interview Questions

  1. What is the view state in Visualforce?
  2. Which API used to design the Visualforce page?
  3. What is the difference between actionsupport and actionFunction
  4. What is the actionRegion?
  5. What is the difference between insert and include?
  6. How do you use the static resources on the VF page?
  7. What is remote action?
  8. How many records we can print  a pageBlock
  9. What is the difference between related List, enhanced List, detail
  10. What is the difference between controller and extension?
  11. What is Ajax? Have you used it? if so tell the scenario?
  12. What is Jquery? Where you have used it?
  13. What are S-Controls?
  14. What is the use of Static Resource in Visual force?
  15. Can I pass parameters from the VF page to the apex method?
  16. How do you refer to the current page id
  17. Tell me something $Action
  18. How do you embed Google map in visual force?
  19. How do you pass the parameters from page to page?
  20. What are custom components?
  21. How do you make a VF page available for Salesforce1?
  22. How to use Sforce connection?
  23. What is a custom component?
  24. How to implement autoLookup and query from VF pages?