Visualforce Page:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
| < apex:page controller = "customPickListInVFDemoController" tabStyle = "Account" > < apex:form > < apex:pageBlock title = "Custom PickList Demo" id = "out" > < apex:pageBlockButtons > < apex:commandButton value = "Save" action = "{!save}" rerender = "out" status = "actStatusId" /> < apex:actionStatus id = "actStatusId" > < apex:facet name = "start" > < img src = "/img/loading.gif" /> </ apex:facet > </ apex:actionStatus > </ apex:pageBlockButtons > < apex:pageBlockSection title = "Custom Picklist Using selectList and selectOption" collapsible = "false" > < apex:selectList value = "{!selectedCountry1}" multiselect = "false" size = "1" > < apex:selectOption itemValue = "INDIA" itemLabel = "India" /> < apex:selectOption itemValue = "USA" itemLabel = "USA" /> < apex:selectOption itemValue = "United Kingdom" itemLabel = "UK" /> </ apex:selectList > < apex:outputText value = "{!selectedCountry1}" label = "You have selected:" /> </ apex:pageBlockSection > < apex:pageBlockSection title = "Custom Picklist Using selectList and selectOptions" collapsible = "false" > < apex:selectList value = "{!selectedCountry2}" multiselect = "false" size = "1" > < apex:selectOptions value = "{!countriesOptions}" /> </ apex:selectList > < apex:outputText value = "{!selectedCountry2}" label = "You have selected:" /> </ apex:pageBlockSection > </ apex:pageblock > </ apex:form > </ apex:page > |
Apex Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| public class customPickListInVFDemoController { public String selectedCountry1{get;set;} public String selectedCountry2{get;set;} public customPickListInVFDemoController(){ } public List<SelectOption> getCountriesOptions() { List<SelectOption> countryOptions = new List<SelectOption>(); countryOptions.add( new SelectOption( '' , '-None-' )); countryOptions.add( new SelectOption( 'INDIA' , 'India' )); countryOptions.add( new SelectOption( 'USA' , 'USA' )); countryOptions.add( new SelectOption( 'United Kingdom' , 'UK' )); countryOptions.add( new SelectOption( 'Germany' , 'Germany' )); countryOptions.add( new SelectOption( 'Ireland' , 'Ireland' )); return countryOptions; } public PageReference save(){ return null ; } }
|
No comments:
Post a Comment