Beruflich Dokumente
Kultur Dokumente
com
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 Beginner s !"ide #or SalesForce. The doc"ment #oc"ses on case st"d$ based learning #or Force.com site and Site.com.%oin o"r pro#essional training program and learn #rom e&perts.
History:
Version Description Change 0.1 Initial Draft 0.1 %e&ie'(1 Author Chandra Prakash har!a A!it har!a Publish Date 10th "an #01$ 1#th "an #01$
www.bispsolutions.com
www.bisptrainigs.com
www.hyperionguru.com
Page 1
Question 1: How can I create a page in site.com to search data dynamically and display it in table?
Solution: Step 1: Firstly create Apex code for search data.
Code :
public with sharing class accsearchvalue { public list <account> acc {get;set;} public string searchstring {get;set;} public accsearchvalue(ApexPages.StandardController controller { } public void search( { string search!uer"#$select na%e&id 'ro% account where na%e li(e )$*$+searchs tring+$*)$ ,i%it -.$; acc# /atabase.!uer"(search!uer" ; } public void clear( { acc.clear( ; } }
www.bispsolutions.com
www.bisptrainigs.com
www.hyperionguru.com
Page 2
Code : <apex:page standardController !account! extensions !accsearch"alue!# <apex:for$ # <apex:inputText "alue !%&searchstring'! label !(nput!)# <apex:co$$and*utton "alue !+earch records! action !%&search'!)# <apex:co$$and*utton "alue !Clear records! action !%&search'!)# <apex:page*loc, title !+earch -esult!# <apex:pagebloc,Table "alue !%&acc'! "ar !a!# <apex:colu$n # <apex:outputlin, "alue !https:))ap1.salesforce.co$)%&a.id'!#%&a..a$e'<)apex:outputlin,# <)apex:colu$n# <apex:colu$n "alue !%&a.id'!)# <)apex:page*loc,Table# <)apex:page*loc,# <)apex:for$# <)apex:page# Step 3 : Then go to Setup # e!elop # Sites/ Clic, on .ew button for add new site .
(n VisualForce page ( ha"e 2 input texts/ if ( write anything in input text1/ auto$atically inputtext2 co$es "isible/ ( need pic,list functionality in1between fields in VisualForce page how can ( get this. Solution :
Code : <apex:page controller !2artial2age-efreshController!# <apex:for$ id !for$!# <apex:page*loc, title !3ser (nput! id !the2age*loc,!# <apex:page*loc,section colu$ns !2!# <apex:inputText "alue !%&inputValue1'! id !theText(nput1! label !(nput 1! tabindex !1!# <&11 action support allows you to add e"ent handlers onto VF co$ponents that don4t nor$ally support the$ the !re-ender! attribute can point to any VF co$ponent on the page 11# <apex:action+upport re-ender !refresh! e"ent !on,eyup! )# <)apex:inputText# <&11 the !rendered! attribute tells the VF page renderer whether or not to generate the 5T67 for this co$ponent 11# www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 8
<apex:output2anel id !refresh!# <apex:pagebloc,section rendered !%&79.:inputValue1;#<'!# <apex:inputText "alue !%&inputValue2'! id !theText(nput2! label !(nput 2! rendered !true! tabindex !2!)# <)apex:pagebloc,section# <)apex:output2anel# <)apex:page*loc,section# <)apex:page*loc,# <)apex:for$# <)apex:page# %pe" Code :
public class PartialPage0e'reshController{ public String input1alue2 {get;set;} public String input1alue- {get;set;} public String get3nput1alue2( { return null; } public String get3nput1alue-( { return null; } }
www.bispsolutions.com
www.bisptrainigs.com
www.hyperionguru.com
Page B
#isual$orce Code : <apex:page controller !i$agepassValue!# <apex:for$ id !-(C!# <br )#<br )#<br )# <h1#2ass para$eters while clic, i$age<)h1# <hr )# <apex:co$$and7in, action !%&Test@'! rerender !-(C! # Aut put Value :<apex:para$ na$e !@! "alue !%&@ D 1'! )# <apex:outputText "alue !%&@'!)#<br)# <apex:i$age id !the($age! "alue !)i$g)logo.gif! width !22<! height !BB!)#<)apex:co$$and7in,# <hr )# <)apex:for$# <)apex:page#
www.bispsolutions.com
www.bisptrainigs.com
www.hyperionguru.com
Page E
%pe" Class: public class +o$eClass% public static "oid setTi$e:-eser"ationIIcJK sos;% for:-eser"ationIIc so : sos;% if:so.*oo,ingITi$eICateIIc null ;% continue? ' if:so.*oo,ingITi$eICateIIc.$inute:; # 0< ;% so.*oo,ingITi$eICateIIc so.*oo,ingITi$eICateIIc.add6inutes:E< 1 so.*oo,ingITi$eICateIIc.$inute:;;.add+econds:11 L so.*oo,ingITi$eICateIIc.second:; ;? ' else % so.*oo,ingITi$eICateIIc so.*oo,ingITi$eICateIIc.add6inutes:0< 1 so.*oo,ingITi$eICateIIc.$inute:;;.add+econds:11 L so.*oo,ingITi$eICateIIc.second:; ;? ' ' '' %pe" *rigger : www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page M
#isual$orce Code : <apex:page standardController !account! extensions !accsearch"alue!# <apex:for$ # <apex:inputText "alue !%&searchstring'! label !(nput!)# <apex:co$$and*utton "alue !-eset! onclic, !this.for$.reset:;?return false?! )# <apex:co$$and*utton "alue !Nuote 7ist! rerender !redrawArea! )# <)apex:for$# <apex:page*loc, id !redrawArea!# %&searchstring' <)apex:page*loc,# <)apex:page#
public with sharing class update4b5ect{ public ,ist<60Products77c> values; public Page0e'erence update4b5ect( { values#8S9,9C: 0e'reshed7/ate77c ;04< 60Products77c =; 'or (60Products77c s >values { s.0e'reshed7/ate77c #/ate.toda"( ; } update values; return null; } }
#isual$orce &age: <apex:page showheader !false! controller !updateAbHect! sidebar !false!# <apex:for$ # <apex:page*loc, title !3pdate Cate Field!# <apex:page*loc,+ection # <apex:co$$and*utton action !%&updateAbHect'! "alue !Clic, here to 3pdate Cate !)# <)apex:page*loc,+ection# <)apex:page*loc,# <)apex:for$# <)apex:page#
ynamically.
&roblem : Ge want to add Cyna$ically pic,list "alue in VisualForce page. Solution : Step 1: Create custo$ pic,list "alue in custo$ obHect. Step 2: Grite class controller . you can see below. public class dyna$icpic,list % public +tring city%get? set?' public 7ist<+electAption# getcityna$es:; % 7ist<+electAption# options new 7ist<+electAption#:;? 7ist<Cyna$ic2ic,listIIc# citylist new 7ist<Cyna$ic2ic,listIIc#:;? citylist J+elect (d/ 2ic,listValueIIc F-A6 Cyna$ic2ic,listIIc K? options.add:new +electAption:411.one114/411.one114;;? for :(nteger H <?H<citylist.siPe:;?HDD; % options.add:new +electAption:citylistJHK.2ic,listValueIIc/citylistJHK.2ic,listValueIIc;;? ' return options? ' public +tring newpic,list"alue%get? set?' public "oid sa"erec:; % Cyna$ic2ic,listIIc newrec new Cyna$ic2ic,listIIc:2ic,listValueIIc newpic,list"alue;? insert newrec? www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page Q
newpic,list"alue .377? ' ' Step 3 : Create VisualForce page . see below.
#isual$orce &age Code: <apex:page controller !dyna$icpic,list! sidebar !false! # <apex:for$ # <apex:section5eader title !Cyna$ic 2ic,list! subtitle !-eusable code!)# <apex:pagebloc, # <apex:page*loc,+ection title !Cyna$ic pic,list! colu$ns !1!# <apex:pagebloc,section(te$ # www.bispsolutions.com www.bisptrainigs.com www.hyperionguru.com Page 1<
<apex:outputlabel "alue !City! for !"alues! )# <apex:select7ist "alue !%&city'! siPe !1! id !"alues!# <apex:action+upport e"ent !onchange! re-ender !new"alue! )# <apex:selectAptions "alue !%&cityna$es'!)# <)apex:select7ist# <)apex:pagebloc,section(te$# <apex:outputpanel id !new"alue!# <apex:outputpanel rendered !%&city 411Ather114'!# <di" style !position:relati"e?left:MBpx?!# <apex:outputlabel "alue !.ew "alue! for !new"al! )# <)di"# <)apex:outputpanel# <strong#9nter City .a$e Rnbsp?Rnbsp?<)strong#<apex:inputText "alue !%& newpic,list"alue'! id !new"al1!)# <apex:co$$and*utton action !%&sa"erec'! "alue !Clic, 5ere +a"e City!)# <)apex:outputpanel# <)apex:pagebloc,section# <)apex:pagebloc,# <)apex:for$# <)apex:page#
www.bispsolutions.com
www.bisptrainigs.com
www.hyperionguru.com
Page 11
www.bispsolutions.com
www.bisptrainigs.com
www.hyperionguru.com
Page 12