Академический Документы
Профессиональный Документы
Культура Документы
VisualForce Components:
Each visualforce page contains two components.
1. VisualForce Markup:
It contains a set of VisualForce Tags, has been used to design the user interface.
Each VisualForce Tag is a Dependent Tag, i.e. each starting tag should require an ending tag.
VisualForce Tags are not case sensitive.
Each VisualForce Page Tag should be prefixed with the word "apex".
Ex:
<apex:page>
....
</apex:page>
Each Tag contains one or more attributes, which are used to supply the input values.
2. VisualForce Controller:
It contains the corresponding business logic, using by the visualforce page controles.
It can be implemented by using "Apex, SOQL, SOSL, DML" statements.
Note: A visualforce page can reference one or more controller classes.
3. What will happen if we set the <apex:page readonly=true
A. VisualForce allows us to display max. of 1000 records in a visualforce page by default. We
can't show more than 1000 records in a VF page.
Note: To show more number of records upto 10,000 in a VF page, we need to set the
"ReadOnly" attribute as TRUE in page tag as below.
<apex:page readonly="true">
4.Which API version we are using in the VF page?
Visualforce Version 38.0
5. How to generate page in PDF format?
RenderAs ="Pdf": This attribute is used to display the VisualForce page content interms of a
PDF File.
Syntax: <apex:page RenderAs="pdf">
....
</apex:page>
<apex:actionfunction>
By using this Tag, we can invoke the controller action methods from javascript.
Upon invoking the actions, we can show the Process status also.
We can have only one ActionFunction inside the VF page and use the ActionFunction in multiple
place in the page, by defining it as "Global - define in <form> level"
Syntax:
<apex:actionfunction
Name = "FunctionName"
Action = "<ActionMethod Name>"
Rerender = "<Components to Refresh>"
Status = "<ActionStatusControl Id>" />
<apex:actionSupport>
By using this Tag, we can enhance the features of VF tags. So that they can invoke the action
methods from the client side.
Ex:Picklist control (<apex:selectlist>) doesn't have the attribute "Action", to invoke controller
methods by default.
We can use the standard picklist control, by leveraging the features by adding the support to
invoke the action methods.
Syntax: <apex:actionsupport
event ="<Event Name(onchange, onblur)>"
Action ="<Controller Method Name>"
Rerender ="<Components to refresh>" />
RemoteAction
The remote method definition in your Apex controller class. This method definition is written in
Apex, but there are some important differences from normal actionmethods. The response
handler callback function you add to or include in your Visualforce page, written in JavaScript.
19. What are basics rules that we have to check before we invoke a method from
Visualforce page?
20. What is the difference between insert and include and define?
Insert
A template component that declares a named area that must be defined by
an <apex:define> component in another Visualforce page. Use this component with
the <apex:composition> and <apex:define> components to share data between multiple pages.
Include
A component that inserts a second Visualforce page into the current page. The entire page subtree
is injected into the Visualforce DOM at the point of reference and the scope of the included page
is maintained.
If content should be stripped from the included page, use the <apex:composition> component
instead.
Define
A template component that provides content for an <apex:insert> component defined in
a Visualforce template page. See also: <apex:composition> , <apex:insert>
21. What is <apex:actionpooler>?
This tag is used to refresh the Page / Part of the page for the specified time interval.
One the specified time interval is over, it make a request to salesforce to invoke the specified
action method and will refresh the specified component.
Syntax:
<apex:actionPoller
action="<Method Name>"
interval = "Time in Seconds"
Rerender ="<Component to Refresh>" />
22. In action interval is given in which format?
23. What is the difference between pageblockTable, datatable, dataList, repeat?
apex:dataTable
An HTML table thats defined by iterating over a set of data, displaying information about one
item of data per row. The body of the <apex:dataTable> contains one or more column
components that specify what information should be displayed for each item of data. The data set
can include up to 1,000 items, or 10,000 items when the page is executed in read-only mode.
For Visualforce pages running Salesforce.com API version 20.0 or higher, an <apex:repeat> tag
can be contained within this component to generate columns.
apex:dataList
An ordered or unordered list of values that is defined by iterating over a set of data. The body of
the <apex:dataList>component specifies how a single item should appear in the list. The data set
can include up to 1,000 items.
apex:repeat
An iteration component that allows you to output the contents of a collection according to a
structure that you specify. The collection can include up to 1,000 items.
Note that if used within an <apex:pageBlockSection> or <apex:panelGrid> component, all
content generated by a child <apex:repeat> component is placed in a
single <apex:pageBlockSection> or <apex:panelGrid> cell.
This component can't be used as a direct child of the following components:
<apex:panelBar>
<apex:selectCheckboxes>
<apex:selectList>
<apex:selectRadio>
<apex:tabPanel>
25. If you want more than 1000 records using pageBlockTable how to achive?
26. If you want to display more than 10,000 records using pageBlockTable how to
implement it?
The action method invoked when this page is requested by the server. Use expression language
to reference an action method. For example, action="{!doAction}" references the doAction()
method in the controller.
If an action isnt specified, the page loads as usual. If the action method returns null, the page
simply refreshes.
This method is called before the page is rendered, and allows you to optionally redirect the user
to another page.
Important: This action should not be used for initialization or DML.
36. What is the execution order of VF page?
We can request VF page in two ways Get Request: Whenever we click on a link or button or directly hitting the url in address bar we
can open a VF page.
Get Request Order
Postback Request: On a VF page after populating fields if you click on save button certain
action will invoke it is nothing but postback request.
Postback Request Order
37. What is the difference between rendered,reRender,RenderAs?
Rendered
This attribute is used to indicate, whether the PageBlock to be displayed inside the page or not.
Note: By default it contains the value as "TRUE".
reRender
This attribute is used to indicate the component name, to be refreshed after performing the
action.
Syntax:
<apex:commandButton value="Save" action="{!Save}" rerender="<ComponentID>"/>
<apex:commandButton value="Cancel" action="{!Cancel}"/>
<apex:commandButton value="Search" action="{!DoSearch}"/>
RenderAs
This attribute is used to display the VisualForce page content interms of a PDF File.
Syntax:
<apex:page RenderAs="pdf">
....
</apex:page>
rendered: Accepts true or false. If it is true then component will display on the page, if it is
false then it won't display on the page.
rerender: To refresh certain area of a page based on component id.
renderAs: Used in page tag, We can display VF page in PDF format if we give renderAs =
"PDF".
contentType: Used in page tag, we can download VF page in MS Word/Excel etc. based on
the input to contentType.
VIEW STATE:
- View state is an object, which persists the Form data during the postback implementations.
- It preserves the form control's data temporarily in our local system.
- View state data will be stored in the form of "hidden" fields.
- View state will convert the form data in "Base64" encoding format, in-order to provide the
security.
- We can view the view state information in "Page View Source" option from the menu, which
displays when we release the right mouse button on the form.
Note: All variable, and collections and objects defined inside the controller class will be
persisted in "ViewState" object.
Ex:
<input type="hidden" name="at" value="AF6bupNdff7BqLXCDzEkOHF8B0cotGDGtw">
Enable View State In Development Mode: (To track viewstate)
Goto Your Name --> Goto My Settings --> Goto Personal & Expand this.
1. Click on "Advanced USer Details" link
2. Click on "Edit" button
3. Select the Checkbox "Show ViewState in Development Mode"
4. click on "Save" button
Some tips to overcome viewstate limits:1. Use Transient keyword for variables which are storing temporary values.
2. Declare variables as Static wherever possible as they are not included in view state.
3. Refine Your SOQL to Retrieve Only the Data Needed by the Page.
4. Use Custom Objects or Custom Settings to Store Large Quantities of Read-Only Data.
5.Use HTML forms instead <apex:form>.
6.Use HTML components instead of <apex:commandbutton>,<apex:commandlink> ,etc to make
your page stateless which saves hitting view state limits.