Visual Force2
Visual Force2
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:-
V13
<apex:page standardController="Position__c">
<apex:detail relatedList="false"/>
</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>
<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*/
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>
V22
<apex:page standardController="Position__c" recordSetVar="pos" >
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: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>
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>
</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>
/*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>
}
<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>
</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>
<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>
<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 ;
}
/*default size=10*/
public with sharing class extensionforpagesize {
public static integer PageSize{get;set;}
2
**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)
{
}
}
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>
</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>
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 custable(){
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;
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>