0% found this document useful (0 votes)
22 views64 pages

Visual Force2

This document discusses Visual Force (VF), a UI framework for developing graphical user interfaces (GUIs) in Salesforce. It describes how to create VF pages using tags and controllers to display data and allow user input. Standard and custom controllers are covered, as well as different types of components, controls, and actions that can be used to build the pages.

Uploaded by

cinafif873
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views64 pages

Visual Force2

This document discusses Visual Force (VF), a UI framework for developing graphical user interfaces (GUIs) in Salesforce. It describes how to create VF pages using tags and controllers to display data and allow user input. Standard and custom controllers are covered, as well as different types of components, controls, and actions that can be used to build the pages.

Uploaded by

cinafif873
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 64

Visual Force-UI Frame work

 To develop GUI
 Through VF pages
 Gui contains controls
o Text boxes
o Lists
o Menus
o Buttons & images

VF page components
1.VF Tags(mark ups)-enclosed between <>.
Strict XML format—opening tag should contain a matching closing tag
Closed in the reverse order .
Each tag contains attributes
<apex:page>
</apex:page>
2.VF Controllers
A component can be

 VF Tags
 HTML
 javaScript
 Ajax
 Jquery
 Angular js
 Backbone.js
 Node .js
 Flex
VF Controllers:
1.Standard Controller
-used to display only 1 record at time.
-Customization not possible(selecting records that meet criteria)
-Record id to be supplied
2.Standard List Controller
-used to display multiple records at time.
-Customization not possible(selecting records that meet criteria)
-Record ids need not be supplied
3.Custom Controller
-Apex code (class) to be written
-Customization is possible(selecting records that meet criteria)

4.Controller Extensions
-Apex code to be written
-Customization is possible(selecting records that meet criteria)
-can be used along with Standard Controllers/Custom Controllers
Developing VF pages:-

1.Using Standard Navigation


Setup->Platform Tools->Custom Code->Visual force pages->New
2. Using URL (Development mode to be set on)
a)My settings->Personnel ->Advanced User Details-> turn on development mode
Add /apex/vf page name after salesforce.com in URL
3.Developer Console
Name->Developer Console-File-> New->Visual Force PAGE->Enter
the name of the file
4.Using eclipce
<Apex:page > attributes-rendered true/false action=http://www.google.com
renderas=”pdf”
V1
<apex:page >
<!-- Begin Default Content REMOVE THIS -->
<h1>Congratulations.................</h1>
This is your new Page
<!-- End Default Content REMOVE THIS -->
</apex:page>
V2
apex:page >

This is my new Page: v2


</apex:page>
V4
<apex:page >
<h1>This file displays data from expressions</h1><br/>
Displays 10: {!10}<br/>
Displays results of 10+20: {!10+20}<br/>
Displays a string: {!'Sam'}<br/>
Displays two strings after concatenation: {!'Sam'+'Sunder'}
{!isnull(10)}
</apex:page>
V5
Sf global variables are prefixed with $
<apex:page >
<h1>Refering Global variables Data</h1>
User Name:{!$User.FirstName}<br/>
User Profile :{!$Profile.Name}<br/>
Organization Name:{!$Organization.Name}
</apex:page>
V6(pass parameter values for name & age through URL)
<apex:page >
Name: {!$CurrentPage.parameters.Name}<br/>
Age: {!$CurrentPage.parameters.Age}<br/>
</apex:page>
Note:- Add in URl
https://c.ap4.visual.force.com/apex/myvf6param?
name=”Ram”&age=33&salary=90000
Extra parameter values are ignored.
Less no of parameter values copied,remaining attribute values are kept empty.
V10
Objects can be refered using standard controller-record id should be passed as
parameter through Url after the page name by adding ?id=recorded.
RecordId-1st 3 chars-objid,last 5 chars-recordid
VF pages runs in user context and security rules of that user are considered.
<apex:page standardController="Account">
Account Name:{!Account.name}<br/>
Account Industry:{!Account.industry}<br/>
Account Phone:{!Account.Phone}
</apex:page>

<apex:sectionHeader title=”FP” subtitle=”Newpage”


description=”ggggg”help=”url” rendered=”true”
V11
<apex:page standardController="Position__c">
Position Name:{!Position__c.Name}<br/>
Position open date:{!Position__c.Open_Date__c}<br/>
Position Functional Area:{!Position__c.Functional_Area__c}
</apex:page>
V12
<apex:page standardController="Position__c">
<apex:detail />
</apex:page>

V13
<apex:page standardController="Position__c">
<apex:detail relatedList="false"/>
</apex:page>

V14(OutPut Controls-prints data in readableformat)


<apex:page standardController="Account">
<apex:outputLabel value="User Name"/><br/>
<apex:outputLabel value="password"/><br/>
output label:<apex:outputLabel value="{!Account.name}"/><br/>
output field: <apex:outputField value="{!Account.name}"/><br/>
output text:<apex:outputText value="{!Account.name}"/>
</apex:page>

V15
<apex:page standardController="Account">
<apex:form >
<apex:inlineEditSupport />/*supports only output field not outputtext or
outputlabel*/
<apex:outputLabel value="User Name"/><br/>
<apex:outputLabel value="password"/><br/>
output label :<apex:outputLabel value="{!Account.name}"/><br/>
output field: <apex:outputField value="{!Account.name}"/><br/>
output text:<apex:outputText value="{!Account.name}"/><br/>
<apex:commandButton value="Click to save" action="{!save}"/>
</apex:form>
</apex:page>

V16
<apex:page standardController="Account">
<apex:form >
<apex:inlineEditSupport />
<apex:outputLabel value="User Name"/><br/>
<apex:outputLabel value="password"/><br/>
output label :<apex:outputLabel value="{!Account.name}"/><br/>
output field: <apex:outputField value="{!Account.name}"/><br/>
output text:<apex:outputText value="{!Account.name}"/><br/>
<apex:commandButton value="click to save" action="{!save}"/><br/>
output link:<apex:outputLink value="http://www.google.com"
title="Google">click to open google</apex:outputLink>

</apex:form>
</apex:page>

V17(Input controls-needs user interaction

<apex:page standardController="Account">
<apex:form >
Empty text box:<apex:inputText /><br/>
<apex:column headervalue=”Account name” >
<apex:inputText value="{!account.name}"/>/*db->VF*/
</apex:column><br/>
Input text Name :<apex:inputText value="{!account.name}"/><br/>
Input text Indudtry<apex:inputText value="{!account.industry}"/><br/>
Input Hidden :<apex:inputHidden value="{!account.name}"/><br/>/*not
shown in UI*/
Input Secret :<apex:inputSecret value="{!account.name}"/><br/>
Input field with label :</br>/*encrypted text*/
<apex:inputField value="{!account.name}"/><br/>/*vf->db converts to its
corresponding datatype*/

Input Text area :<apex:inputTextarea rows="6" cols="150"/><br/>


Input File:-<apex:inputFile value="Asdf"></apex:inputFile>
</apex:form>
</apex:page>
Select List:- used to add options

 List values
 Check boxes
 Radio buttons
V18
<apex:page >
<apex:form >
<apex:outputLabel >List Example</apex:outputLabel><br/>
<apex:selectlist size="1"><!--size specifies number of items displayed-- >
<apex:selectOption itemlabel="--None--" itemvalue="None"/>
<apex:selectOption itemlabel="Jan" itemvalue="One"/>
<apex:selectOption itemlabel="Feb" itemvalue="Two"/>
<apex:selectOption itemlabel="March" itemvalue="Three"/>
</apex:selectList><br/><br/><br/><br/><br/>
<apex:outputLabel >Check Boxes Example</apex:outputLabel>
<apex:selectCheckboxes border="1" label="My Choices"
legendText="Mychoices-1234" borderVisible="true">
<apex:selectOption itemlabel="--None--" itemvalue="None"/>
<apex:selectOption itemlabel="Jan" itemvalue="One"/>
<apex:selectOption itemlabel="Feb" itemvalue="Two"/>
<apex:selectOption itemlabel="March" itemvalue="Three"/>
</apex:selectCheckboxes><br/>
<apex:outputLabel >radio buttons Example</apex:outputLabel>
<apex:selectRadio >
<apex:selectOption itemlabel="--None--" itemvalue="None"/>
<apex:selectOption itemlabel="Jan" itemvalue="One"/>
<apex:selectOption itemlabel="Feb" itemvalue="Two"/>
<apex:selectOption itemlabel="March" itemvalue="Three"/>
</apex:selectRadio><br/>
</apex:form>
</apex:page>
V19(Standard Actions)
<apex:page >
<apex:form >
<apex:pageblock title="PAge Block 1" helptitle="Need help?"
helpURL="http://google.com">
<apex:outputlabel value="enter Name"/>
<apex:inputText id="one"/>
<apex:commandButton value="save" action="{!save}"/>
</apex:pageBlock>
<apex:pageblock title="Page Block 2 with page block buttons" >
<apex:outputlabel value="enter Name"/>
<apex:inputText id="one"/>
<apex:pageblockButtons >
<apex:commandButton value="save" action="{!save}"/>
</apex:pageblockButtons>
</apex:pageBlock>
<apex:pageblock title="PAge Block Buttons on top" rendered="false">
<apex:outputlabel value="enter Name"/>
<apex:inputText id="one"/>
<apex:pageblockButtons location="top">
<apex:commandButton value="save" action="{!save}"/>
</apex:pageblockButtons>
</apex:pageBlock>
<apex:pageblock title="PAge Block Buttons on bottom" >
<apex:outputlabel value="enter Name"/>
<apex:inputText id="one"/>
<apex:pageblockButtons location="bottom">
<apex:commandButton value="save" action="{!save}"/>
</apex:pageblockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
V20
<apex:page StandardController="Account">
<apex:form >
<apex:pageBlock title="Account Details ">
/*PBS is child of PB-specifies the no of columns in a row default is 2*/
<apex:pageBlockSection title="Input Fields" columns="1">
<apex:inputField value="{!account.name}"/>
<apex:inputField value="{!account.industry}"/>
<apex:inputField value="{!account.phone}"/>
</apex:pageBlockSection>

<apex:pageBlockSection title="InputText and Labels" >


<apex:outputLabel value="Enter Name"/>
<apex:inputtext />
<apex:outputLabel value="Enter Industry"/>
<apex:inputText />
<apex:outputLabel value="Enter Phone"/>
<apex:inputText />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
V21
<apex:page standardController="Position__c" recordSetVar="pos" >
<apex:pageBlock title="Position Records" >
<apex:pageBlockSection title="Section1" collapsible="True">
<apex:pageblockTable value="{!pos}" var="p">
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:pageblockTable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
To display set of records
1.Page block table
2.Data table
3.Data list
4.Repeat
For any page block-
<apex:facet name=”Caption”>This is Caption</apex:facet>
<apex:facet name=”Header”>This is Heaer</apex:header>

<apex:facet name=”Footer”>This is Footer</apex:footer>


/*Adding styles*/>
<style>
.one{background:red;font-size:8px}
.two{background:yellow;}
.three{background:blue;}
.four{width:50px;}
</style>
<apex:pageBlockTable value=”{!items}” var=”a” captionClass=”one”
headerclass=”two”footerclass=”three”/>
<apex:pageBlockTable value=”{!items}” var=”a” align=”right”
styleclass=”four”rendered=”false”/>
/*inline style*/
<apex:pageBlockTable captionStyle=”color:red;” rowclasses=”one”
colclasses=”two”/>

V22
<apex:page standardController="Position__c" recordSetVar="pos" >

<apex:pageBlock title="Position Records using Page Block Table">


<apex:pageblockTable value="{!pos}" var="p">
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:pageblockTable>
</apex:pageBlock>

<apex:pageBlock title="Position Records using Data Table">


<apex:dataTable value="{!pos}" var="p" rules=”rows”>
//rules=”cols”/all,frame=”box” frame=”hsides” frame=”vsides”
Border=”2”,bgcolor=”blue” cellpadding=”10” cellspacing=”20”//
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:dataTable>
</apex:pageBlock>
<apex:pageBlock title="Position Records using Data List">
<apex:dataList value="{!pos}" var="p">
//type=”square”/”1”/<ol><li>{!a.name}</li></ol>//
"{!p.name}"
"{!p.Location__c}"
"{!p.Functional_Area__c}"
</apex:dataList>
</apex:pageBlock>
<apex:pageBlock title="Position Records using Repeat">
<apex:repeat value="{!pos}" var="p">
"{!p.name}"<br/>
"{!p.Location__c}"<br/>
"{!p.Functional_Area__c}"<br/>
</apex:repeat>
</apex:pageBlock>
</apex:page>
V23
<apex:page standardController="Position__c" recordSetVar="pos" >

<apex:pageBlock title="All Position Records using Page Block Table">


<apex:pageblockTable value="{!pos}" var="p">
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
<apex:pageBlock title="Position Records from 3 to 8">
<apex:pageblockTable value="{!pos}" var="p" first="3" rows="5">
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
<apex:pageBlock title="Position Records from 5">
<apex:pageblockTable value="{!pos}" var="p" first="5"
width="100,100,100">
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:pageblockTable>
</apex:pageBlock>
</apex:page>
V24.1
<apex:page standardController="Position__c">
<apex:pageBlock title="Position and related Lists">
<apex:pageBlockSection title="Position Detail">
<apex:detail />
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

V24.2
<apex:page standardController="Position__c">
<apex:pageBlock title="Position and related Lists">
<apex:pageBlockSection title="Position Detail">
<apex:relatedlist list="Job_Applications__r"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>
V24.3
<apex:page standardController="Account">
<apex:pageBlock title="Account and related Lists">
<apex:pageBlockSection title="Account Detail">
<apex:detail relatedlist="false"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Contacts of{!Account.name}"
collapsible="false">
<apex:relatedList list="Contacts"/>
</apex:pageBlockSection>
<apex:pageBlockSection title="Opportunities of {!Account.name}"
collapsible="true">
<apex:relatedList list="Opportunities"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

V24
// Switch type –refreshes only tab area//
<apex:page standardController="Account" >
<apex:tabPanel switchtype="Ajax">
<apex:tab label="Account" labelWidth="300">
<apex:detail relatedlist="false"/>
</apex:tab>
<apex:tab label="Contacts" labelWidth="400">
<apex:relatedlist list="Contacts"/>
</apex:tab>

<apex:tab label="opportunities" labelWidth="400">


<apex:relatedlist list="opportunities"/>
</apex:tab>
</apex:tabPanel>
</apex:page>
V25
<apex:page standardController="Account">
<apex:form >
<apex:pageBlock title="ACCount record creation">
<apex:pageBlockSection >
<apex:inputField value="{!account.name}"/>
<apex:inputField value="{!account.Industry}"/>
<apex:inputField value="{!account.Phone}"/>
</apex:pageBlockSection>
<apex:pageBlockButtons >
<apex:commandButton value="Click to save" action="{!save}"/>
<apex:commandButton value="delete" action="{!delete}"/>
<apex:commandButton value="Edit" action="{!edit}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
V26
<apex:page standardController="Opportunity" recordSetVar="oops" >
<apex:form >
<apex:pageBlock title="Opportunity records">
<apex:pageBlockTable value="{!oops}" var="o">

<apex:column value="{!o.name}"/>
<apex:column value="{!o.stagename}"/>
<apex:column value="{!o.type}"/>
<apex:column value="{!o.amount}"/>

</apex:pageBlockTable>
<apex:pageBlockButtons >
<apex:commandButton value="Next" action="{!Next}"/>
<apex:commandButton value="Previous" action="{!Previous}"/>
<apex:commandButton value="First" action="{!First}"/>
<apex:commandButton value="Last" action="{!last}"/>
</apex:pageBlockButtons>
</apex:pageBlock>
</apex:form>
</apex:page>
V26JS1
<apex:page >
<apex:outputLabel >Enter your Name</apex:outputLabel>
<script>
alert("Hello");
</script>
<apex:outputLabel >Enter your passwqord</apex:outputLabel>
</apex:page>
V25JS2
<apex:page standardController="Account" >
<apex:form id="fm">
<apex:inputHidden value="{!Account.name}" id="n1"/>
<apex:commandButton value="Click to display account name"
onClick="show()"/>
<script>
function show()
{
var myname=document.getElementById('{!$Component.fm.n1}').value;
alert(myname);
alert("hai");
}
</script>
</apex:form>
</apex:page>
V25JS3(Refering the Vf page value in the javascript
<apex:page id="pg">
<apex:form id="fm">
<apex:outputLabel value="Enter Name: "/>
<apex:inputText id="name" onchange="show()"/><br/><br/>
<script>
function show()
{
var myname=document.getElementById('{!$Component.name}').value;
var myage=document.getElementById('{!$Component.pb.age}').value;
alert(myname);
alert(myage);
}
function demo()
{
var n=document.getElementById('pg:fm:name').value;
var a=document.getElementById('pg:fm:pb:age').value;
alert(n);
alert(a)
}
</script>
<apex:pageBlock id="pb">
<apex:outputLabel value="Enter age: "/>
<apex:inputText id="age" onchange="demo()"/><br/>
</apex:pageBlock>
</apex:form>
</apex:page>

V26JS4(Reading values from one component and displaying in another


component)
<apex:page id="pg">
<apex:form id="fm">
<apex:pageBlock id="pb">
<apex:pageBlockSection id="pbs1" title="Page Block Section 1">
<apex:outputLabel value="Block1 Value "/>
<apex:inputText id="name1"/><br/>
</apex:pageBlockSection>
<apex:pageBlockSection id="pbs2" title="Page Block Section 2">
<apex:inputText id="name2"/><br/>
<apex:outputLabel id="name3" />
</apex:pageBlockSection>
</apex:pageBlock>
<apex:commandButton value="Click to display values in pb2"
onclick="show()"/>
<script>
function show()
{
var myname=document.getElementById('{!
$Component.fm.pb.pbs1.name1}').value;
document.getElementById('{!
$Component.fm.pb.pbs2.name2}').value=myname;
document.getElementById('{!
$Component.fm.pb.pbs2.name3}').innerHtml=myname;
}
</script>
</apex:form>
</apex:page>
V26JS5
<apex:page standardController="Account" >
<apex:form id="fm">
<apex:inputHidden value="{!Account.name}" id="n1"/>
<apex:commandButton value="Click to display account name"
onClick="show()"/>
<script>
function show()
{
var myname=documnet.getElementById('{!$Component.fm.n1}').value;
alert(myname);
}
</script>
</apex:form>
</apex:page>

VF28.5(Reding data from Object)


<apex:page standardController=”Account”>
<apex:form id=”fm”>
<apex:inputhidden value=”{!Account.Name}” id=”one”/>
<apex:commandButton value=”Click” onclick=”show()”/>
<script>
Function show()
{
Var myname=document.getElementByd(‘{!$componnet.one}’).value;
Alert(myname);
}
</script>
</apex:form>
</apex:page>

Static Resources
Step1:Upload The Image using Static resources
Step2:Use Static resource In VF Page
1.Refereing resource if available as direct file
{!$Resource.resourcename}
2.Refereing from a zip file
{!URLFOR($Resource.resourcename,’/filepath’)}

VF29image
<apex:page >
<h1>This image retrieved from file</h1><br/><br/>
<apex:image url="{!$Resource.CC2}" width="100" height="100"/>
<h1 align ="left">This image retrieved from folder</h1><br/><br/>
<apex:image url="{!URLFOR($Resource.Myzipfile,'Myimages/cc4.jpg')}"
width="100" height="100"/>
</apex:page>

Visual Force Components


Step1; Create VF Component
Step2:Use Component in VF Page
Ex:1
Step1:C1
<apex:component >
<apex:outputLabel >This is Commercecx Technologies
Limited</apex:outputLabel>
</apex:component>
Step2:VF31C1
<apex:page standardController="Account">
<c:Com1 ></c:Com1>
<apex:image url="{!$Resource.CC2}" width="100" height="100"/>

</apex:page>
EX2;
Step1:c2
<apex:component >
<apex:attribute name="Text" Description="Used As Input" type="String"
required="true"/>
<apex:outputText value="{!Text}"/>
</apex:component>
Step2:VF31c2
<apex:page >
<h1>This is Commercx Portal </h1><br/>
<c:Com2 text="Welcome to Hyderabad">
</c:Com2>
</apex:page>
Ex3:
Step1: C3
<apex:component >
<apex:Attribute name="Text" description="Enter text to be displayed"
type="String" required="true"/>
<apex:Attribute name="TextColor" description="Enter text color"
type="String" required="false"/>
<apex:Attribute name="BorderColor" description="Enter Border Color"
type="String" required="true"/>
<apex:Attribute name="BorderWidth" description="Enter Border Width"
type="Integer" required="true"/>
<h1 style="color:{!textcolor};border-width={!BorderWidth};Border-color:{!
BorderColor}">
<apex:outputText value="{!Text}" />
</h1>
</apex:component>
V31C3
Step2:
<apex:page >
<c:Com2 text="HELLO"></c:Com2><br/><br/>
<c:Com3 text="This is my component3 Text" TextColor="Green"
BorderColor="Red" BorderWidth="4"></c:Com3>
</apex:page>

/*Command link*/
<apex:page standardController="Account" recordSetVar="acs" sidebar="false">
<apex:form >
<apex:pageBlock title="Account List">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!acs}" var="a" >
<apex:column headerValue="Account Name" >
<apex:commandLink value="{!a.name}">
<apex:param name="accid" value="{!a.id}"/>
</apex:commandlink>
</apex:column>
<apex:column value="{!a.industry}"/>
<apex:column value="{!a.phone}"/>
</apex:pageBlockTable>
<apex:pageBlock id="RecordDetail">

<apex:detail subject="{!$CurrentPage.parameters.accid}"
relatedlist="false"/>
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>
=================================
Public class c1
{
Integer x,y,z;
X=10;y=30;
String str1=”Hello How are you?”;
Public string getstr1()
{
Return str1;
}
Public integer getadd()
{
z=x+y;
Return z;}
VF PAGE:-
<apex:page controller=”c1”>
{!str1}
{!add}
</apex:page>
=====================================
Public class c2{
Account a=new Account(name=”Abc Ltd”,industry=”Education”);
Account b=[select name,industry,phone from account where name =’abcd’);
Public account getnewrec()
{
Return a;
}
Public account getexistingrec()
{
Return b;
}
}
VF Page:-
<apex:page controller=”c2”>
{!newrec.name}
{! newrec.industry}
{ ! newrec.phone}
{!existingrec.name}
{! existingrec.industry}
{ ! existingrec.phone}
</apex:page>

Public class c6{


List<opportunity>ops;
Public list<opportunity> getops()
{
Return ops;
}
Public pageReference openops()
{
Ops=[select name,stagename,amount,closedate from opportunity where
stagename in(‘prospecting’,’value proposition’)];
Return null;
}
Public pageReference closedops()
{
Ops=[select name,stagename,amount,closedate from opportunity where
stagename in(‘Closed Won’,’Closed Lost’)];
Return null;
}
VF PAGE:-
<apex:page controller=”c6”>
<apex:form>
<apex:pageBlock title=”List of Opportunities”>
<Apex:commandbutton value=”Open ops” action=”{!openops}”/>
<Apex:commandbutton value=”Closed ops” action=”{!closedops}”/>
<apex:pageblocktable value=”{!ops}” var =”o”>
<apex:column value=”{!o.name}”
<apex:column value=”{!o.stagename}”
</apex:pageblocktable>
</apex:pageBlock>
</apex:page>

/*Controller1 to display two types of records in 2 sections*/


public class controler1 {
public list<account> a1=[select name,industry,phone from account where
type='Customer - Direct'];
public list<account> a2=[select name,industry,phone from account where
type='Customer - Channel'];
public list<account> getdirrec()
{
return a1;
}
public list<account> getcharec()
{
return a2;
}
}
VF page
<apex:page controller="controler1">
<apex:pageBlock title="List of Direct and Channel Accounts">
<apex:pageBlockSection>
<apex:pageBlock title="Direct Accounts">
<apex:pageBlockTable value="{!dirrec}" var="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.industry}"/>
<apex:column value="{!a.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Channel Accounts">
<apex:pageBlockTable value="{!charec}" var="b">
<apex:column value="{!b.name}"/>
<apex:column value="{!b.industry}"/>
<apex:column value="{!b.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:page>

/*Controller2 to display two types of records with page block command buttons*/
public class Controller2 {
list<account> acts=new list<account>();
public list<account> getacts()
{
return acts;
}
public pageReference directacts()
{
acts=[select name,type,industry from account where type='Customer -
Direct'];
return null;
}
public pageReference channelacts()
{
acts=[select name,type,industry from account where type='Customer -
Channel'];
return null;
}
}
/*VF PAGE*/
<apex:page controller="Controller2">
<apex:form>
<apex:pageBlock>
<apex:pageBlockButtons >
<apex:commandButton value ="Direct Accounts" action="{!
directacts}"/>
<apex:commandButton value ="Channel Accounts" action="{!
channelacts}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!acts}" var ="a">
<apex:column value="{!a.name}"/>
<apex:column value="{!a.industry}"/>
<apex:column value="{!a.type}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

Public class c4{


List<account> direct-accts=[select name,type,industry,phone,fax from account
where type=’customer-direct’];
List<account> channel-accts=[select name,type,industry,phone,fax from account
where type=’channel-direct’];
Public list<account> getdirect-accts()
{
Return direct-accts;
}
Public list<account> getchannel-accts()
{
Return channel-accts;
}

}
<apex:page controller=”c4”>
<apex:pageBlock>

<apex:tabpanel switchtype=”Azax”>
<apex:tab label=”Direct Accounts” label width=”400”>
<apex:pageBlocktable value=”{!direct-accts}” var=”a”>
……..
<apex:pageBlocktable>
</apex:tab>
<apex:tab label=”Channel Accounts” label width=”400”>
<apex:pageBlocktable value=”{!channel-accts}” var=”b”>
……….
<apex:pageBlocktable>
</apex:tab>
</apex:tabpanel>

/*Setting page size*/


<apex:page standardController="Position__c" recordSetVar="Positions"
extensions="extensionforpagesize" tabStyle="Position__c">
<apex:form >
<apex:pageBlock title="Edit Positions" >
<apex:pageMessages ></apex:pageMessages>
<apex:pageBlockButtons >
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Cancel" action="{!cancel}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!Positions}" var="pos">
<apex:column value="{!pos.Name}"/>
<apex:column headerValue="CreatedDate">
<apex:inputField value="{!pos.CreatedDate}"/>
</apex:column>
<apex:column headerValue="Max Pay">
<apex:inputField value="{!pos.Max_Pay__c}"/>
</apex:column>
<apex:column headerValue="Min Pay">
<apex:inputField value="{!pos.Min_Pay__c}"/>
</apex:column>
<apex:column headerValue="Pay_Grade">
<apex:inputField value="{!pos.Pay_Grade__c}"/>
</apex:column>
<apex:column headerValue="Created Date">
<apex:inputField value="{!pos.CreatedDate}"/>
</apex:column>
<apex:column headerValue="Closing Date">
<apex:inputField value="{!pos.Date_Closed__c}"/>
</apex:column>

</apex:pageBlockTable>
<apex:panelGrid cellpadding="5" cellspacing="5" columns="5" >
<apex:commandButton value="|<" action="{!first}" />
<apex:commandButton value="<" action="{!previous}" rendered="{!
HasPrevious}" />
<apex:commandButton value=">" action="{!next}" rendered="{!HasNext}" />
<apex:commandButton value=">|" action="{!last}" />
<apex:panelGroup >
<apex:outputText
value="Records/Page"></apex:outputText>&nbsp;&nbsp;
<apex:selectList value="{!PageSize}" size="1">
<apex:selectOption itemValue="5"
itemLabel="5"></apex:selectOption>
<apex:selectOption itemValue="10"
itemLabel="10"></apex:selectOption>
<apex:selectOption itemValue="15"
itemLabel="15"></apex:selectOption>
</apex:selectList>&nbsp;&nbsp;
<apex:commandButton action="{!refreshPageSize}" value="Update Page
Size"/>
</apex:panelGroup>
</apex:panelGrid>
</apex:pageBlock>
</apex:form>
</apex:page>
/*controller for page size*/
public with sharing class extensionforpagesize {
public integer noOfRecords ;
public static integer PageSize{get;set;}
ApexPages.StandardSetController setCon ;

public extensionforpagesize(ApexPages.StandardSetController controller) {


PageSize = 10;
setCon =controller;
setCon.setpagesize(PageSize);
}
//Changes the size of pagination
public PageReference refreshPageSize() {
setCon.setPageSize(PageSize);
return null;
}

}
/*default size=10*/
public with sharing class extensionforpagesize {
public static integer PageSize{get;set;}
2

3 public extensionforpagesize(ApexPages.StandardSetController controller) {


4 PageSize=10;
5 }

Accessing Visual Force pages:


1.Overriding Display:-
Select the object->Btns,Links&Actions section->View->Edit->(default Std
Sf.com page)->select the VF Page->Save.
2.Embed Vf Page in standard page
Select object->pagelayout->Select VF pages from top sidebar menu->Select the
VF page->Drag n drop into a section
3.Create a button that links to VF page
i)Setup->select the object->Btn,Links&Actions->New Button or link->Enter
Lable->Content Source->Select Vf page->save.
ii)Add btn to layout
Buttons->VF page Btn(Drag& drop intothe page layout)
4.Create hyperlink to URL/VF page
i)In the VF page->add
<apex:commandlink> or
<apex:commandbutton value=”goto page2” action=”/apex/page2”/>
ii)link to URL
<apex:outputLink value=https://developer.force.com>
Click me
</apex:outputLink>
iii)link to VF page
to reference a page
<apex:outputLink value =”{!page.AccountDisplay}”>
Click here
</Apex:outputlink>

**CONTROLLER EXTENSIONS
1.Standard Controller
<apex:page standardController=”Account”> 1 record
<apex:page standardController=”Position__c”> 1 record
2. Standard List Controller
<apex:page standardController=”Account” recordsetvar=”accs”> many
records (page block table)
<apex:page standardController=”Position__C” recordsetvar=”pos”> many
records
3. Custom Controller
<apex:page Controller=”Acctclass” > //apex code required 1 or more
records
<apex:page Controller=”posclass” > //apex code required 1 or more records
4. Controller extension
i)<apex:page standardController=”Account” extensions=”apxextclass”>
(1 rec from Account and 1 or more records/values from apxextclass)
ii)<apex:page standardController=”Account” recordsetvar=”accs”
extensions=”apxextclass”>
(many rec from Account and 1 or more records from apxextclass)
iii)<apex:page standardController=”position” recordsetvar=”pos”
extensions=”apxextclass2,cls3”>
(more records from position and 1 or more recs from apxclass2 and 1 or
more recs from cls3)
iv)<apex:page Controller=”Acctclass” extensions=”apexclass3”>
( 1 or more records from controller and 1 or more records from
extensionclass)
Controller Extension =primary controller+extension(Custom controller)
Primary controller-standardcontroller/standardlist controller/custom
controller
i)Controller Type: Standard Controller
Extension class constructor prototype:
public extclassname(ApexPages.StandardController con)
{
}
ii) Controller Type: Stadard list Controller
Extension class constructor prototype:
public extclassname(ApexPages.StandardsetController con)
{
}
iii) Controller Type: Custom Controller
Extension class constructor prototype:
public extclassname(/Primary Customcontrollerclassname con)
{
}

/*Program using Controller extension*/


public class ext1 {
public ext1(ApexPages.StandardSetController con)
{

}
string hello='Hello how are you?';
public string gethello()
{
return hello;
}
}
public class ext3 {
public ext3(ApexPages.StandardSetController con)
{

}
string hello2='Welcome';
public string gethello2()
{
return hello2;
}
}
<apex:page standardController="Position__c" recordSetVar="pos"
extensions="ext1,ext3">
<apex:form>
{!hello}<br/>
{!hello2}
<apex:pageBlock title="Position Records">
<apex:pageblockTable value="{!pos}" var="p">
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:pageblockTable>

</apex:pageBlock>
</apex:form>

</apex:page>

public class ext2{


public ext2(ApexPages.StandardController con){}
string hello='Welcome';
list<campaign> camps=[select name,startdate,enddate from campaign];
public list<campaign> getcamps()
{
return camps;
}
public string gethello()
{
return hello;
}
}
<apex:page standardController="Account" extensions="ext2">
{!hello}
<apex:pageBlock title="Account with related list as Tabs">
<apex:tabPanel switchType="Ajax">
<apex:tab label="Account Details" labelWidth="150">
<apex:detail relatedList="false" title="FAlse"/>
</apex:tab>
<apex:tab label="Contacts" labelWidth="150">
<apex:relatedList list="Contacts"/>
</apex:tab>
<apex:tab label="Opportunities" labelWidth="150">
<apex:relatedList list="Opportunities"/>
</apex:tab>
<apex:tab label="Cases" labelWidth="150">
<apex:relatedList list="Cases"/>
</apex:tab>
<apex:tab label="Campaigns" labelWidth="150">
<apex:pageBlockTable value="{!camps}" var ="c">
<apex:column value ="{!c.name}"/>
<apex:column value ="{!c.startdate}"/>
<apex:column value ="{!c.enddate}"/>
</apex:pageBlockTable>
</apex:tab>
</apex:tabPanel>
</apex:pageBlock>
</apex:page>
/*Custom controller with extension*/
Example 1:
<apex:page standardController="Position__c" extensions="Ext2,Ext3" >
<apex:form >
<apex:pageBlock title="Data from Extension2">
<apex:pageBlockSection >
Data from str1 Extension2 :{!str1}<br/>
Data from str2 Extension2 :{!str2}<br/>
</apex:pageBlockSection>
</apex:pageBlock>
<apex:pageBlock title="Data from Standrad Controller">
Position name:{!Position__c.name}<br/>
Position status:{!Position__c.Status__c}<br/>
Position location:{!Position__c.Location__c}<br/>
</apex:pageBlock>
<apex:pageBlock title="Data from Ext3">
<apex:pageBlockTable value="{!japps}" var="ja">
<apex:column value="{!ja.name}"/><br/>
<apex:column value="{!ja.Candidate__c}"/><br/>
<apex:column value="{!ja.Position__c}"/><br/>
<apex:column value="{!ja.Total_Rating__c}"/><br/>

</apex:pageBlockTable>

</apex:pageBlock>

</apex:form>

</apex:page>
Apex classes:
public class Ext2 {
public string s1='Hello how are you?';
public string s2='I am good';
public Ext2(ApexPages.StandardController scon)
{

}
public string getstr1()
{
return s1;
}
public string getstr2()
{
return s2;
}

}
Apex class ext3
public class Ext3 {
public list<job_application__c> jas=[select
name,position__C,candidate__c,total_rating__c from job_application__C where
total_rating__c>4];
public Ext3(ApexPages.StandardController scon)
{

}
public list<job_application__C> getjapps()
{
return jas;
}
}
------------------------------------------------------------
public class ext3 {
public ext3(Indpos con ) //controller class name
{
}
public string x='Welcome to custom controller with extension';
public string getx()
{
return x;
}

}
<apex:page Controller="indpos" extensions="ext3">
<apex:form >
<center>
<font size="10">
{!x}<br/>
</font>
</center>
<apex:pageBlock title="Position Details">
<apex:pageBlockTable value="{!pos}" var="p">
<apex:column value="{!p.name}"/>
<apex:column value="{!p.Location__c}"/>
<apex:column value="{!p.Functional_Area__c}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>

/*CREATING WIZARD*/
public class Wizardclass {
Account a=new Account();
Contact c=new Contact();
Opportunity o=new Opportunity();
public Account geta()
{
return a;
}
public Contact getc()
{
return c;
}
public Opportunity geto()
{
return o;
}
public pageReference gotopage1()
{
return Page.page1;
}
public pageReference gotopage2()
{
return Page.page2;
}
public pageReference gotopage3()
{
return Page.page3;
}
public pageReference gotopage4()
{
return Page.page4;
}
public pageReference savenow()
{
insert a;
c.AccountId=a.id;
insert c;
O.AccountId=a.id;
insert o;
return Page.page5;
}
}
Page1:

<apex:page controller="Wizardclass">
<apex:form>
<apex:pageBlock title="Enter Account Details">
<apex:pageBlockButtons>
<apex:commandButton value="Next page" action="{!gotopage2}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!a.name}"/>
<apex:inputField value="{!a.type}"/>
<apex:inputField value="{!a.industry}"/>
<apex:inputField value="{!a.phone}"/>
<apex:inputField value="{!a.fax}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Page2:
<apex:page controller="Wizardclass">
<apex:form>
<apex:pageBlock title="Enter Contact Details">
<apex:pageBlockButtons>
<apex:commandButton value="Previous page" action="{!gotopage1}"/>
<apex:commandButton value="Next page" action="{!gotopage3}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!c.firstname}"/>
<apex:inputField value="{!c.lastname}"/>
<apex:inputField value="{!c.email}"/>
<apex:inputField value="{!c.phone}"/>
<apex:inputField value="{!c.fax}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Page3:
<apex:page controller="Wizardclass">
<apex:form>
<apex:pageBlock title="Enter Opportunity Details">
<apex:pageBlockButtons>
<apex:commandButton value="Previous page" action="{!gotopage2}"/>
<apex:commandButton value="Next page" action="{!gotopage4}"/>
</apex:pageBlockButtons>
<apex:pageBlockSection columns="1">
<apex:inputField value="{!o.name}"/>
<apex:inputField value="{!o.stagename}"/>
<apex:inputField value="{!o.amount}"/>
<apex:inputField value="{!o.closedate}"/>
<apex:inputField value="{!o.type}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Page 4:
<apex:page controller="Wizardclass">
<apex:form>
<apex:pageBlock title="Riview Page" tabStyle="opportunity">
<apex:pageBlockButtons>
<apex:commandButton value="Edit Account" action="{!gotopage1}"/>
<apex:commandButton value="Edit Contact" action="{!gotopage2}"/>
<apex:commandButton value="Edit Opportunity" action="{!
gotopage3}"/>
<apex:commandButton value="Save" action="{!savenow}"/>

</apex:pageBlockButtons>
<apex:pageBlockSection title= "Account Details" collapsible="false"
columns="1">
<apex:outputField value="{!a.name}"/>
<apex:outputField value="{!a.type}"/>
<apex:outputField value="{!a.industry}"/>
<apex:outputField value="{!a.phone}"/>
<apex:outputField value="{!a.fax}"/>
</apex:pageBlockSection>
<apex:pageBlockSection title= "Contact Details" collapsible="false"
columns="1">
<apex:outputField value="{!c.firstname}"/>
<apex:outputField value="{!c.lastname}"/>
<apex:outputField value="{!c.email}"/>
<apex:outputField value="{!c.phone}"/>
<apex:outputField value="{!c.fax}"/>
</apex:pageBlockSection>

<apex:pageBlockSection title= "opportunity Details" collapsible="false"


columns="1">
<apex:outputField value="{!o.name}"/>
<apex:outputField value="{!o.stagename}"/>
<apex:outputField value="{!o.amount}"/>
<apex:outputField value="{!o.closedate}"/>
<apex:outputField value="{!o.type}"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

Page 5:
<apex:page >
Congrats Records created successfully
</apex:page>

/*SEARCH INTERFACE*/
public class searchclass {
String SearchString;
List<Lead> lds;
public String getSearchString ()
{
return SearchString;
}
public void setSearchString(String s)
{
SearchString = s;
}
public List<Lead> getlds()
{
return lds;
}
public pageReference doSearch()
{
lds = (list<lead>)[FIND :SearchString in all fields returning
lead(firstname,email,phone)][0];
return null;
}
}
<apex:page controller="searchclass">
<apex:form >
<apex:pageBlock >
Enter Search String:
<apex:inputText id="SearchString" value="{!SearchString}"/>
<apex:commandButton value="Go" action="{!doSearch}" />
<apex:pageBlockSection title="Leads" columns="1">
<apex:pageblocktable value="{!lds}" var="l">
<apex:column value="{!l.firstname}"/>
<apex:column value="{!l.email}"/>
<apex:column value="{!l.phone}"/>
</apex:pageblocktable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

/SEARCH 2*/
public class searchclass2 {
public String SearchString;
List<Lead> lds;

public String getSearchString ()


{
return SearchString;
}
public void setSearchString(String s)
{
SearchString = s;
}
public List<Lead> getlds()
{
return lds;
}
public pageReference doSearch()
{
lds = [Select firstname,email,phone from lead where
firstname=:SearchString];
return null;
}
}
<apex:page controller="searchclass2">
<apex:form >
<apex:pageBlock >
Enter Search String:
<apex:inputText id="SearchString" value="{!SearchString}"/>
<apex:commandButton value="Go" action="{!doSearch}" />
<apex:pageBlockSection title="Leads" columns="1">
<apex:pageblocktable value="{!lds}" var="l" rendered="{!
Not(ISNULL(lds))}">
<apex:column value="{!l.firstname}"/>
<apex:column value="{!l.email}"/>
<apex:column value="{!l.phone}"/>
</apex:pageblocktable>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

<apex:page controller="custable" sidebar="false">


<apex:form >
<apex:pageBlock title="AccountTable">
<apex:pageBlockTable value="{!Acclst}" var="A">

<apex:column headerValue="NAME OF THE ACCOUNT" >


<apex:commandLink value="{!A.Name}" action="{!setupContacts}"
rerender="conttable" >
<apex:param value="{!A.Id}" name="idForConts" assignTo="{!
recid}"/>
</apex:commandLink>
</apex:column>
<apex:column value="{!A.industry}"/>
<apex:column value="{!A.phone}"/>
</apex:pageBlockTable>
</apex:pageBlock>
<apex:pageBlock title="Contacts">
<apex:pageBlockTable value="{!contacts}" var="contact" id="conttable">
<apex:column headerValue="ID" >
<apex:commandLink value="{!contact.id}" onclick="window.open('/{!
contact.Id}','_blank');">
</apex:commandLink>
</apex:column>
<apex:column value="{!contact.FirstName}"/>
<apex:column value="{!contact.LastName}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
public with sharing class custable {

public string recid{get;set;}

public string row{ get; set;}


public list<Account> Acclst{get;set;}
Public Account A;

public List<Contact> contacts {get; set;}

public custable(){

Acclst = [select Id,Name,Industry,Phone from Account ];


contacts=null;
}

public void setupContacts()


{
contacts=[select id, FirstName, LastName from Contact where
AccountId=:recId];
}
}

SOSL
List<List<SObject>> searchList = [FIND 'Pencil*' IN ALL FIELDS
RETURNING Merchandise__c (Id, Name), Invoice_Statement__c];
Merchandise__c[] merList = ((List<Merchandise__c>)searchList[0]);
Invoice_Statement__c[] invList = ((List<Invoice_Statement__c>)searchList[1]);
System.debug('Found ' + merList.size() + ' merchandise items.');
System.debug('Found ' + invList.size() + ' invoice statements.'

<apex:page standardController="Contact"
extensions="ContactExtn" id="pgContact">

<script type="text/javascript">
function copyAddress() {
// Variables for Billing Address
var copy_BillingPostalCode =
document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBP
ostalCode').value;
var copy_BillingAddress1
=document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifB
Add1').value;
var copy_BillingAddress2 =
document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBA
dd2').value;
var copy_BillingAddress3 =
document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBA
dd3').value;
var copy_BillingCity =
document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBC
ity').value;
var copy_BillingState =
document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBS
tate').value;
var copy_BillingCountry =
document.getElementById('pgContact:fmContact:pbContact:pbsBillingAdd:ifBC
ountry').value;

// Copying the Billing Address to the Shipping Address


if(copy_BillingPostalCode != null)
{

document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifS
PostalCode').value = copy_BillingPostalCode;
}
if(copy_BillingAddress1 != null) {

document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifS
Add1').value = copy_BillingAddress1;
}
if(copy_BillingAddress2 != null) {
document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifS
Add2').value = copy_BillingAddress2;
}
if(copy_BillingAddress3 != null) {

document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifS
Add3').value = copy_BillingAddress3;
}
if(copy_BillingCity != null) {

document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifS
City').value = copy_BillingCity;
}
if(copy_BillingState != null) {

document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifS
State').value = copy_BillingState;
}
if(copy_BillingCountry != null) {

document.getElementById('pgContact:fmContact:pbContact:pbsShippingAdd:ifS
Country').value = copy_BillingCountry;
}
}
</script>
<apex:form id="fmContact">
<apex:sectionHeader title="Contact Information" subtitle="{!
Contact.Name}"/>
<apex:pageBlock mode="Edit" id="pbContact">
<apex:pageBlockSection showHeader="true" collapsible="false"
columns="2" title="Billing Address Information" id="pbsBillingAdd">
<apex:inputField value="{!Contact.Billing_Postal_Code__c}"
id="ifBPostalCode"/>
<apex:inputField value="{!Contact.Billing_City__c}" id="ifBCity"/>
<apex:inputField value="{!Contact.Billing_Address_Line_1__c}"
id="ifBAdd1"/>
<apex:inputField value="{!Contact.Billing_State__c}" id="ifBState"/>
<apex:inputField value="{!Contact.Billing_Address_Line_2__c}"
id="ifBAdd2"/>
<apex:inputField value="{!Contact.Billing_Country__c}"
id="ifBCountry"/>
<apex:inputField value="{!Contact.Billing_Address_Line_3__c}"
id="ifBAdd3"/>
</apex:pageBlockSection>
<apex:pageBlockSection showHeader="true" collapsible="false"
columns="2" title="Shipping Address Information" id="pbsShippingAdd">
<apex:inputField value="{!Contact.Shipping_Postal_Code__c}"
id="ifSPostalCode"/>
<a HREF="#" onClick="return copyAddress();">Copy Billing Address
to Shipping Address</a>
<apex:inputField value="{!Contact.Shipping_Address_Line_1__c}"
id="ifSAdd1"/>
<apex:inputField value="{!Contact.Shipping_City__c}" id="ifSCity"/>
<apex:inputField value="{!Contact.Shipping_Address_Line_2__c}"
id="ifSAdd2"/>
<apex:inputField value="{!Contact.Shipping_State__c}"
id="ifSState"/>
<apex:inputField value="{!Contact.Shipping_Address_Line_3__c}"
id="ifSAdd3"/>
<apex:inputField value="{!Contact.Shipping_Country__c}"
id="ifSCountry"/>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>
</apex:page>

You might also like