1:
<apex:page>
1.apiVersion : This will specify the verion of api used in
the VF page .
if you don’t
specify any version no by default it will take latest version i.e 33.0
<apex:pageapiVersion=”29.0”
>
2.action : when ever we request the page from the server first it will perform the
action
What we have
defined in the page
Action can be a url of
the page which need to be opened or a
method from the class
3.showHeader : This is a Boolean value when we set it
as true standard salesforce look and feel of salesforce header and side bar
components of the page displayed
When
we set it as false salesforce header and sidebar components are not displayed
4.Sidebar :
This is Boolean value when we set it as true sidebar components on the page
a redisplayed.when we set it as false sidebar
components are hidden
<apex:page sidebar=”false” >
5.setUp : This will take the Boolean value if set it
as true setup admin menu will be
displayed
6.contentType : This wil specify content of the page and we can display the page in the required
format
contentType=”Vnd.ms-word#pagename.doc” for word
document format
contentType=”Vnd.msexcel#pagename.xls” for xl format
7.renderAs :
This is used to display the page pdf
renderAs=”pdf”
8.Id :This is
used to refer to the component in the page
9.rendered
Q:
How to display the data on the page
If
we want to display the data on the VF page it should be displayed as formule
expression
Syntax
: {! Expression }
{! 10}
{! 10+20}
{! 'sam'}
{! 'Sam'&'kiran'}
{! ISNULL(10)}
{! ! ISNULL(10)}
Ex: <apex:page>
{! 10} <br/>
{! 10+20}<br/>
{! 'sam'}<br/>
{! 'Sam'&'kiran'}<br/>
{! ISNULL(10)}<br/>
{! ! ISNULL(10)}
</apex:page>
Q:
How to refer to the global data using visualforce page
Global
data : Data which remains same throughout the application once’s user has
logged in is called global data
Global
data is prefixed with $
$User
$Profile
$UserRole
Synatax:
{ ! $GlobalObject.FieldName}
Ex:
{!$User.LastName}
{!$User.Firstname}
<apex:page>
{!$User.FirstName}<br/>
{!$User.LastName}<br/>
{!$Organization.Name}<br/>
{!$Profile.Name}
</apex:page>
Q:How
to pass the parameters using url
Synatx:https://ap2.salesforce.com/apex/pageName
?parameter=val
If you want to pass more than one parameter in
the url then parameters should be separated by ‘&’
Q:
How to read the data from the URL of the page
If
you want to read the data from the url
then we have the following syntax
{! $Currentpage.parameters.paramtername}
Ex:
{!$Currentpage.parameters.name}
<apex:page>
{!$Currentpage.parameters.name}<br/>
{!$Currentpage.parameters.age}
</apex:page>
Q:
How to read the data from apex class
into the VF page
If
we want to refer the data from apex class into the VF page we have define the
apex class as
Controller
in apex:page component
Ex: <apex:page controller=”ApexclassName” >
publicclass Example1
{
public String
name {set;get;}
public String
branch{set;get;}
public
Example1(){
name='Karthic';
branch='SRNagar';
}
}
VF page
<apex:pagecontroller="Example1">
Name
:{!name}<br/>
Branch:{!branch}
</apex:page>
Ex:
create a class Employee with employee
name ,salary ,exp and initialize the values using constructor and display the
data in the VF page
publicclass Employee1
{
public String
name {set;get;}
public Decimal
Salary{set;get;}
public Decimal
exp {set;get;}
public
Employee1(){
name='Rajeev';
salary=90000;
exp=3.2;
}
}
<apex:pagecontroller="Employee1">
Name :{!
name} <br/>
salary:{!salary} <br/>
Exp
:{! exp}
</apex:page>
Basics Also:
1:
<apex:page>
1.apiVersion : This will specify the verion of api used in
the VF page .
if you don’t
specify any version no by default it will take latest version i.e 33.0
<apex:page
apiVersion=”29.0” >
2.action : when ever we request the page from the server first it will perform the
action
What we have
defined in the page
Action
can be a url of the page which need to
be opened or a method from the class
3.showHeader : This is a Boolean value when we set it
as true standard salesforce look and feel of salesforce header and side bar
components of the page displayed
When
we set it as false salesforce header and sidebar components are not displayed
4.Sidebar :
This is Boolean value when we set it as true sidebar components on the page
a re displayed.when we set it as false sidebar components are hidden
<apex:page sidebar=”false” >
5.setUp : This will take the Boolean value if set it
as true setup admin menu will be
displayed
6.contentType : This wil specify content of the page and we can display the page in the required
format
contentType=”Vnd.ms-word#pagename.doc” for word
document format
contentType=”Vnd.msexcel#pagename.xls” for xl format
7.renderAs :
This is used to display the page pdf
renderAs=”pdf”
8.Id :This is
used to refer to the component in the page
9.rendered
Q:
How to display the data on the page
If
we want to display the data on the VF page it should be displayed as formule
expression
Syntax
: {! Expression }
{! 10}
{! 10+20}
{!
'sam'}
{!
'Sam'&'kiran'}
{!
ISNULL(10)}
{! ! ISNULL(10)}
Ex: <apex:page >
{! 10} <br/>
{! 10+20}<br/>
{! 'sam'}<br/>
{! 'Sam'&'kiran'}<br/>
{! ISNULL(10)}<br/>
{! ! ISNULL(10)}
</apex:page>
Q:
How to refer to the global data using visualforce page
Global
data : Data which remains same throughout the application once’s user has
logged in is called global data
Global
data is prefixed with $
$User
$Profile
$UserRole
Synatax:
{ ! $GlobalObject.FieldName}
Ex:
{!$User.LastName}
{!$User.Firstname}
<apex:page >
{!$User.FirstName}<br/>
{!$User.LastName}<br/>
{!$Organization.Name}<br/>
{!$Profile.Name}
</apex:page>
Q:How
to pass the parameters using url
Synatx:https://ap2.salesforce.com/apex/pageName
?parameter=val
If you want to pass more than one parameter in
the url then parameters should be separated by ‘&’
Q:
How to read the data from the URL of the page
If
you want to read the data from the url
then we have the following syntax
{! $Currentpage.parameters.paramtername}
Ex:
{!$Currentpage.parameters.name}
<apex:page >
{!$Currentpage.parameters.name}<br/>
{!$Currentpage.parameters.age}
</apex:page>
Q:
How to read the data from apex class
into the VF page
If
we want to refer the data from apex class into the VF page we have define the apex class as
Controller
in apex:page component
Ex: <apex:page controller=”ApexclassName” >
public class Example1
{
public String
name {set;get;}
public String
branch{set;get;}
public
Example1(){
name='Karthic';
branch='SRNagar';
}
}
VF page
<apex:page controller="Example1" >
Name
:{!name}<br/>
Branch:{!branch}
</apex:page>
Ex:
create a class Employee with employee
name ,salary ,exp and initialize the values using constructor and display the
data in the VF page
public class Employee1 {
public String
name {set;get;}
public Decimal
Salary{set;get;}
public Decimal
exp {set;get;}
public
Employee1(){
name='Rajeev';
salary=90000;
exp=3.2;
}
}
<apex:page controller="Employee1">
Name :{!
name} <br/>
salary:{!salary} <br/>
Exp
:{! exp}
</apex:page>
Section
3
<apex:inputText>
Maxlength: This
is integer value which will specify the maximum length of the input
what is allowed in the inputTextBox
Size: This is a intervalue which will specify
the length /size of the inputTextBox
Disable : This is
a Boolean value when give true this will disable the inputTextBox
Tab Index :This
is a integer value which specifies the
order of the tab flows
Example : Create
a Vf page with inputText and read the
value and displayed the modified value in the pageBlock when we click on the
button
Apex :Class
public class
InputTextExample {
public String name {set;get;}
public String branch{set;get;}
public void show(){
name='My Name :'+name;
}
}
VF Page:
<apex:page
controller="InputTextExample">
<apex:form >
<apex:inputText
value="{!name}" tabindex="1" />
<apex:commandButton
value="Submit" action="{!show}" reRender="pb2"
/>
<apex:pageBlock title="Output"
id="pb2">
{!name}
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:pageBlocksection>
This is a child
component of pageBlock which will divide
the rows into no of columns
Where in each
column once visualforce component is displayed .
àIf we don’t specify no of columns it will take default value as
two
Collapisble :
This will take Boolean value if we set it as true it will create toggle for the
pageBlockSection
Title :This will take the string value which
will be displayed as title on the sectionHeader
Columns : This is
integer value which will specify how
many columns need to be displayed in a
row
VF page :
<apex:page
>
<apex:form
>
<apex:pageBlock
title="PageBlock" tabstyle="Customer__c">
<apex:pageBlockSection
title="Section" >
<apex:outputLabel
value="Enter Name" />
<apex:inputText />
<apex:outputLabel
value="Enter Password" />
<apex:inputText />
</apex:pageBlockSection>
<apex:pageBlockSection title="Section2"
columns="4" collapsible="false">
<apex:outputLabel
value="Enter Name" />
<apex:inputText />
<apex:outputLabel
value="Enter Password" />
<apex:inputText />
</apex:pageBlockSection>
<apex:pageBlockSection
title="Section 3" columns="3"
collapsible="false">
<apex:outputLabel
value="Enter Password" />
<apex:inputText />
<apex:pageBlock >
<apex:outputLabel value="Enter
Password" /> <br/>
<apex:inputText />
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:outputLabel>
This will print
the value given as label on the VF page
<apex:outputText>
This will refer
every field as text field if we are referring any field from an object
Note: This will
not support <apex:inlineEditSupport>
<apex:outputField>
This will refer
to the field with the exact properties and data type ,
This will support
inline Edit
<apex:page
standardController="Account">
<apex:form
>
<apex:pageBlock title="Account
Record" tabStyle="Customer__c">
<apex:inlineEditSupport >
<apex:pageBlockSection
title="OutputLabel" collapsible="false" >
<apex:outputLabel
value="{!Account.Name}" />
<apex:outputLabel
value="{!Account.Industry}" />
</apex:pageBlockSection>
<apex:pageBlockSection
title="OutputText" collapsible="false">
<apex:outputText
value="{!Account.Name}" />
<apex:outputText
value="{!Account.Industry}" />
</apex:pageBlockSection>
<apex:pageBlockSection
title="OutputFields" collapsible="false">
<apex:outputField
value="{!Account.Name}" />
<apex:outputField
value="{!Account.Industry}" />
</apex:pageBlockSection>
</apex:inlineEditSupport>
</apex:pageBlock>
</apex:form>
</apex:page>
InputText and
InputField
Section 4
<apex:pageBlockSectionITem>
This is a child component of pageBlockSection
where each pageBlockSectionItem is printed in once column each.
àPageBlockSectionItem can take two child components in It
<apex:page >
<apex:form>
<apex:pageBlock
title="PageBlock">
<apeX:pageBlockSection
columns="1">
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Enter Name" />
<apex:inputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Enter Age" />
<apex:inputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Enter Salary" />
<apex:inputText />
</apex:pageBlockSectionItem>
</apeX:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:selectOption >
This component is used to create a
picklist option the VF page
itemLabel : This will take a string value
which will be displayed as optionLabel in the picklist
itemValue: This will take a string value
which will be returned by the picklist if we select this option
itemDisabled: This will take a Boolean
value when we give it as true it will disable the option from the list
itemDescription : This will take the string
value to provide the description about
the option
<apex:selectList >
This will take the group of options and
display as picklist field
Value : This will store the itemvalue which
will be returned by the option which we have selected
Size
: This is a integer value which will specify how many options has to
displayed at time in the list
<apex:selectRadio>
This will display group of radio button
from which we can select one option
<apex:selectCheckBoxes>
This will display group of checkboxes from
which we can select multiple options
<apex:page >
<apex:form>
<apex:pageBlock
title="Registration Form" >
<apex:pageBlockSection
title="Basic Informaton " collapsible="false"
columns="1">
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputText "/>
<apex:inputText />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputSecret "/>
<apex:inputSecret />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputHidden "/>
<apex:inputHidden />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputTextArea "/>
<apex:inputTextArea
rows="5" cols="20" />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputCheckBox "/>
<apex:inputCheckBox
/>
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="PickList "/>
<apex:selectList
size="1">
<apex:selectOption
itemLabel="-None-" itemvalue="none" />
<apex:selectOption
itemLabel="Java" itemValue="one" />
<apex:selectOption
itemLabel="Sfdc" itemValue="two" />
</apex:selectList>
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="RadioButtons"/>
<apex:selectRadio >
<apex:selectOption
itemLabel="-None-" itemvalue="none"/>
<apex:selectOption
itemLabel="Java" itemValue="one" />
<apex:selectOption
itemLabel="Sfdc" itemValue="two" />
</apex:selectRadio>
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel value="CheckBoxGroup
"/>
<apex:selectCheckBoxes
>
<apex:selectOption
itemLabel="-None-" itemvalue="none"/>
<apex:selectOption
itemLabel="Java" itemValue="one" />
<apex:selectOption
itemLabel="Sfdc" itemValue="two" />
</apex:selectCheckBoxes>
</apex:pageBlocksectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Scenario: Transfer the data from one
Visualforce page to another Visualforce page
Process 1: We can use the common Controller
for the both the pages so that data will be tranfered
Apex Class :
public class EmployeePage {
public String name {set;get;}
public
Integer age {Set;get;}
public Decimal salary {set;get;}
public String city{set;get;}
public PageReference navigate(){
PageReference p=new pageReference('/apex/Confirmationpage');
return p;
}
public void reset(){
name=null;
age=null;
salary=null;
city=null;
}
}
Visualforce Page: Employee Registration
<apex:page
controller="EmployeePage">
<apex:form>
<apex:pageBlock
title="Employee Registation" >
<apex:pageBlockSection
columns="1">
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Employee Name"/>
<apex:inputText
value="{!name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Age"/>
<apex:inputText
value="{!age}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Salary"/>
<apex:inputText
value="{!salary}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="City"/>
<apex:selectList value="{!city}"
size="1">
<apex:selectOption
itemLabel="-None-" itemvalue="none" />
<apex:selectOption
itemLabel="Hyd" itemValue="hyd"/>
<apex:selectOption
itemLabel="Ban" itemValue="ban" />
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:commandButton value="Next"
action="{!navigate}" />
<apex:commandButton value="Reset" action="{!reset}"
/>
</apex:pageBlock>
</apex:form>
</apex:page>
VF Page : Confiramtion Page:
<apex:page
controller="EmployeePage">
<apex:form>
<apex:pageBlock
title="Employee Registation confirmation" >
<apex:pageBlockSection
columns="1">
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Employee Name"/>
<apex:outputText
value="{!name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Age"/>
<apex:outputText
value="{!age}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Salary"/>
<apex:outputText
value="{!salary}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="City"/>
<apex:outputLabel
value="{!city}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Process : Transferring the data from one page to another using URL
Apex Classes: InputPage1,OutputPage2
public class InputPage1 {
public String name {set;get;}
public Integer age {set;get;}
public PageReference show(){
PageReference p=new
PageReference('/apex/inputpage2?name='+name+'&age='+age);
return p;
}
}
public class outputPage2 {
public String empName{Set;get;}
public String age{set;get;}
public outputPage2 (){
empName=ApexPages.currentpage().getParameters().get('name');
age=ApexPages.currentpage().getParameters().get('age');
}
}
public class outputPage2 {
public String empName{Set;get;}
public String age{set;get;}
public outputPage2 (){
empName=ApexPages.currentpage().getParameters().get('name');
age=ApexPages.currentpage().getParameters().get('age');
}
}
Visualforce pages :Inputpage1,InputPage2
<apex:page
controller="InputPage1">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem
>
<apex:outputLabel
value="Enter Name" />
<apex:inputText
value="{!name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem
>
<apex:outputLabel
value="Enter Age" />
<apex:inputText value="{!age}"
/>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:commandButton
value="Next" action="{!show}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
VF Page Session 3
VF Page Session 3
<apex:inputText>
Maxlength: This
is integer value which will specify the maximum length of the input
what is allowed in the inputTextBox
Size: This is a intervalue which will specify
the length /size of the inputTextBox
Disable : This is
a Boolean value when give true this will disable the inputTextBox
Tab Index :This
is a integer value which specifies the
order of the tab flows
Example : Create
a Vf page with inputText and read the
value and displayed the modified value in the pageBlock when we click on the
button
Apex :Class
public class
InputTextExample {
public String name {set;get;}
public String branch{set;get;}
public void show(){
name='My Name :'+name;
}
}
VF Page:
<apex:page
controller="InputTextExample">
<apex:form >
<apex:inputText
value="{!name}" tabindex="1" />
<apex:commandButton
value="Submit" action="{!show}" reRender="pb2"
/>
<apex:pageBlock
title="Output" id="pb2">
{!name}
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:pageBlocksection>
This is a child
component of pageBlock which will divide
the rows into no of columns
Where in each
column once visualforce component is displayed .
àIf we don’t specify no of columns it will take default value as
two
Collapisble :
This will take Boolean value if we set it as true it will create toggle for the
pageBlockSection
Title :This will take the string value which
will be displayed as title on the sectionHeader
Columns : This is
integer value which will specify how
many columns need to be displayed in a
row
VF page :
<apex:page
>
<apex:form
>
<apex:pageBlock
title="PageBlock" tabstyle="Customer__c">
<apex:pageBlockSection
title="Section" >
<apex:outputLabel
value="Enter Name" />
<apex:inputText />
<apex:outputLabel
value="Enter Password" />
<apex:inputText />
</apex:pageBlockSection>
<apex:pageBlockSection
title="Section2" columns="4" collapsible="false">
<apex:outputLabel
value="Enter Name" />
<apex:inputText />
<apex:outputLabel
value="Enter Password" />
<apex:inputText />
</apex:pageBlockSection>
<apex:pageBlockSection
title="Section 3" columns="3"
collapsible="false">
<apex:outputLabel
value="Enter Password" />
<apex:inputText />
<apex:pageBlock >
<apex:outputLabel
value="Enter Password" /> <br/>
<apex:inputText />
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:outputLabel>
This will print
the value given as label on the VF page
<apex:outputText>
This will refer
every field as text field if we are referring any field from an object
Note: This will
not support <apex:inlineEditSupport>
<apex:outputField>
This will refer
to the field with the exact properties and data type ,
This will support
inline Edit
<apex:page
standardController="Account">
<apex:form
>
<apex:pageBlock title="Account
Record" tabStyle="Customer__c">
<apex:inlineEditSupport >
<apex:pageBlockSection
title="OutputLabel" collapsible="false" >
<apex:outputLabel
value="{!Account.Name}" />
<apex:outputLabel
value="{!Account.Industry}" />
</apex:pageBlockSection>
<apex:pageBlockSection
title="OutputText" collapsible="false">
<apex:outputText
value="{!Account.Name}" />
<apex:outputText value="{!Account.Industry}"
/>
</apex:pageBlockSection>
<apex:pageBlockSection
title="OutputFields" collapsible="false">
<apex:outputField
value="{!Account.Name}" />
<apex:outputField
value="{!Account.Industry}" />
</apex:pageBlockSection>
</apex:inlineEditSupport>
</apex:pageBlock>
</apex:form>
</apex:page>
InputText and
InputField
VF Page Session 4:
<apex:pageBlockSectionITem>
This is a child component of
pageBlockSection where each pageBlockSectionItem is printed in once column
each.
àPageBlockSectionItem can take two child components in It
<apex:page >
<apex:form>
<apex:pageBlock
title="PageBlock">
<apeX:pageBlockSection
columns="1">
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Enter Name" />
<apex:inputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Enter Age" />
<apex:inputText />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel value="Enter
Salary" />
<apex:inputText />
</apex:pageBlockSectionItem>
</apeX:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
<apex:selectOption >
This component is used to create a picklist option the VF page
itemLabel : This will take a string value
which will be displayed as optionLabel in the picklist
itemValue: This will take a string value
which will be returned by the picklist if we select this option
itemDisabled: This will take a Boolean
value when we give it as true it will disable the option from the list
itemDescription : This will take the string
value to provide the description about
the option
<apex:selectList >
This will take the group of options and
display as picklist field
Value : This will store the itemvalue which
will be returned by the option which we have selected
Size
: This is a integer value which will specify how many options has to
displayed at time in the list
<apex:selectRadio>
This will display group of radio button
from which we can select one option
<apex:selectCheckBoxes>
This will display group of checkboxes from
which we can select multiple options
<apex:page >
<apex:form>
<apex:pageBlock
title="Registration Form" >
<apex:pageBlockSection
title="Basic Informaton " collapsible="false"
columns="1">
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputText "/>
<apex:inputText />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputSecret "/>
<apex:inputSecret />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputHidden "/>
<apex:inputHidden />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputTextArea "/>
<apex:inputTextArea
rows="5" cols="20" />
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="InputCheckBox "/>
<apex:inputCheckBox
/>
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="PickList "/>
<apex:selectList
size="1">
<apex:selectOption
itemLabel="-None-" itemvalue="none" />
<apex:selectOption
itemLabel="Java" itemValue="one" />
<apex:selectOption
itemLabel="Sfdc" itemValue="two" />
</apex:selectList>
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="RadioButtons"/>
<apex:selectRadio >
<apex:selectOption
itemLabel="-None-" itemvalue="none"/>
<apex:selectOption
itemLabel="Java" itemValue="one" />
<apex:selectOption
itemLabel="Sfdc" itemValue="two" />
</apex:selectRadio>
</apex:pageBlocksectionItem>
<apex:pageBlocksectionItem>
<apex:outputLabel
value="CheckBoxGroup "/>
<apex:selectCheckBoxes
>
<apex:selectOption
itemLabel="-None-" itemvalue="none"/>
<apex:selectOption
itemLabel="Java" itemValue="one" />
<apex:selectOption
itemLabel="Sfdc" itemValue="two" />
</apex:selectCheckBoxes>
</apex:pageBlocksectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Scenario: Transfer the data from one
Visualforce page to another Visualforce page
Process 1: We can use the common Controller
for the both the pages so that data will be tranfered
Apex Class :
public class EmployeePage {
public String name {set;get;}
public Integer age {Set;get;}
public Decimal salary {set;get;}
public String city{set;get;}
public PageReference navigate(){
PageReference p=new pageReference('/apex/Confirmationpage');
return p;
}
public void reset(){
name=null;
age=null;
salary=null;
city=null;
}
}
Visualforce Page: Employee Registration
<apex:page
controller="EmployeePage">
<apex:form>
<apex:pageBlock
title="Employee Registation" >
<apex:pageBlockSection
columns="1">
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Employee Name"/>
<apex:inputText
value="{!name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Age"/>
<apex:inputText
value="{!age}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Salary"/>
<apex:inputText
value="{!salary}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="City"/>
<apex:selectList value="{!city}"
size="1">
<apex:selectOption
itemLabel="-None-" itemvalue="none" />
<apex:selectOption
itemLabel="Hyd" itemValue="hyd"/>
<apex:selectOption
itemLabel="Ban" itemValue="ban" />
</apex:selectList>
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:commandButton value="Next"
action="{!navigate}" />
<apex:commandButton
value="Reset" action="{!reset}" />
</apex:pageBlock>
</apex:form>
</apex:page>
VF Page : Confiramtion Page:
<apex:page
controller="EmployeePage">
<apex:form>
<apex:pageBlock
title="Employee Registation confirmation" >
<apex:pageBlockSection
columns="1">
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Employee Name"/>
<apex:outputText
value="{!name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Age"/>
<apex:outputText
value="{!age}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="Salary"/>
<apex:outputText
value="{!salary}"/>
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem>
<apex:outputLabel
value="City"/>
<apex:outputLabel
value="{!city}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
Process : Transferring the data from one page to another using URL
Apex Classes: InputPage1,OutputPage2
public class InputPage1 {
public String name {set;get;}
public Integer age {set;get;}
public PageReference show(){
PageReference p=new
PageReference('/apex/inputpage2?name='+name+'&age='+age);
return p;
}
}
public class outputPage2 {
public String empName{Set;get;}
public String age{set;get;}
public outputPage2 (){
empName=ApexPages.currentpage().getParameters().get('name');
age=ApexPages.currentpage().getParameters().get('age');
}
}
public class outputPage2 {
public String empName{Set;get;}
public String age{set;get;}
public outputPage2 (){
empName=ApexPages.currentpage().getParameters().get('name');
age=ApexPages.currentpage().getParameters().get('age');
}
}
Visualforce pages :Inputpage1,InputPage2
<apex:page
controller="InputPage1">
<apex:form >
<apex:pageBlock >
<apex:pageBlockSection >
<apex:pageBlockSectionItem
>
<apex:outputLabel
value="Enter Name" />
<apex:inputText
value="{!name}" />
</apex:pageBlockSectionItem>
<apex:pageBlockSectionItem
>
<apex:outputLabel value="Enter
Age" />
<apex:inputText
value="{!age}" />
</apex:pageBlockSectionItem>
</apex:pageBlockSection>
<apex:commandButton
value="Next" action="{!show}"/>
</apex:pageBlock>
</apex:form>
</apex:page>
No comments:
Post a Comment