Thursday, 19 July 2012

Pick List in VF

Simple Pick List without using controller:
<apex:page >
<apex:form >
  <apex:selectList size="1">
      <apex:selectoption Itemlabel="India" Itemvalue="India"/>
      <apex:selectoption Itemlabel="India" Itemvalue="USA"/>
      <apex:selectoption Itemlabel="India" Itemvalue="UK"/>
  </apex:selectList>
</apex:form>
</apex:page>
*******************
Simple Pick List by using controller:

<apex:page controller="actionregionInterview">
<apex:form >
  <apex:selectList size="1">
      <apex:selectoptions value="{!items}"/>
  </apex:selectList>
</apex:form>
</apex:page>
-------------------------------
public class actionregionInterview {   
    public List<SelectOption> getItems() {
        List<SelectOption> options = new List<SelectOption>();
        options.add(new selectoption('India', 'India'));
        options.add(new selectoption('Us', 'Us'));
        options.add(new selectoption('Australia', 'Australia'));
        return options;
    }

    /*String[] Countries = new String[] {};
    public String[] getCountries() {
       
        return countries;
    }
        public void setCountries(String[] countries) {
       
        this.countries = countries;
    }*/

}
*************************

No comments:

Post a Comment

Labels