You need to sign in to do that
Don't have an account?
plz explain the following controller and VF page step by step..
hi frnds.. following PAGE and CONTROLLER are the examples given in the VisualForce Guide..
<!-- Page: -->
<apex:page controller="sampleCon">
<apex:form>
<apex:selectList value="{!countries}" multiselect="true">
<apex:selectOptions value="{!items}"/>
</apex:selectList><p/>
<apex:commandButton value="Test" action="{!test}" rerender="out" status="status"/>
</apex:form>
<apex:outputPanel id="out">
<apex:actionstatus id="status" startText="testing...">
<apex:facet name="stop">
<apex:outputPanel>
<p>You have selected:</p>
<apex:dataList value="{!countries}" var="c">{!c}</apex:dataList>
</apex:outputPanel>
</apex:facet>
</apex:actionstatus>
</apex:outputPanel>
</apex:page>
/*** Controller: ***/
public class sampleCon {
String[] countries = new String[]{};
public PageReference test() {
return null;
}
public List<SelectOption> getItems() {
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('US','US'));
options.add(new SelectOption('CANADA','Canada'));
options.add(new SelectOption('MEXICO','Mexico'));
return options;
}
public String[] getCountries() {
return countries;
}
public void setCountries(String[] countries) {
this.countries = countries;
}
}
The below code lets you display a custom multiselect picklist field onto the visualforce page.
The value countries holds the country values you select from the drop-down.
The attribute multiselect="true" allows you to select more than one values from the drop-down. If this is set to false, you can only select one
country value from the drop-down.
The <apex:selectOptions/> tag list the options in the drop-down.
The <apex:actionstatus is used to display the status of the redresh, i.e. it tells user that the page is being refreshed once you select the values from
the drop-down and click "Test" button.
Since a multi-select picklist is defined and the user can select more that once value, the <apex:datatable> is used to display the country values
selected by the user.
options.add(new SelectOption('CANADA','Canada'));
in the above statement "Canada" is the values that if displayed in the list.
Hope this helps you understand the code and its purpose.
thanks a lot ..
tc..