You are on page 1of 4

Hands on Practise of Apex Code in Salesforce

Lab Guide -II


Description:
BISP is committed to provide BEST learning material to the beginners and advance learners.
In the same series, we have prepared a complete end-to end Hands-on Beginners Gide !or
Sales"orce. The docment !ocses on basic #e$words, terminolog$ and de!initions one
shold #now be!ore starting Sales"orce %oin or pro!essional training program and learn
!rom e&perts.
History:
Version Description Change Author Publish Date
0.1 Initial Draft Chandra Prakash har!a
0.1 "e#ie$%1 u!it &oyal
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1
How to Show popup in VisualForce Page by using Apex Code
!e"uire#ent$ Scenario is we want to display a popup box while clicking on a button in
visual force. For this we need to implement apex code functionality and also create a
custom controller. So in this lab guide I have demonstrated how to implement same.
Step % $
First create a new Apex Page
lick on Setup ! &e'eloper ! Apex Classes
"hen click on (ew button.
Step ) $ #rite here AP$% code for display popup popup and hide popup . "hen Save this code.
public class popup%)*
+
public boolean displaypopup+get, set,-
public 'oid hidepopup./
+
displaypopup01alse,
-
public 'oid showpopup./
+
displaypopup0true,
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page &
-
-
Step * $ After reate Apex lass then create 'isualForce page for creating 'isualForce page click
on address bar and after SalesForce Address use ( then write apex(page name see below.
It will Show error click on Create Page 2 Page na#e 2 see below.
Step * $ )ere you can write 'isualForce page code and save this code . see below.
Code $
3apex$page controller02popup%)*24
3style4
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page *
popupstyle
+
bac5ground-color$gray,
border-style$solid,
padding$67px,
position$absolute,
top$%77px,
le1t$)67px,
-
38style4
3apex$1or# 4
3apex$co##and9utton 'alue02Clic52 action02+:showpopup-284
3apex$outputPanel id02popup2 4
3apex$outputPanel rendered02+:displaypopup-2 styleClass02popupstyle24
3strong4;his is a popup <indow38strong43br 843br 84
=nbsp,=nbsp,=nbsp,=nbsp,=nbsp,=nbsp,3apex$co##and9utton 'alue02Close Popup2
action02+:hidepopup-284
38apex$outputPanel4
38apex$outputPanel4
38apex$1or#4
38apex$page4
Step > $ ;his is the final output. After clicking on +lick, button as displayed in step -*.
So when we click on +lick, button in 'isual Force page a pop will be displayed with a message and
a button at a desired location and when we click on +lose Popup, button the popup will close.
www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page .

You might also like