ApexPage:
<apex:selectList value="{!optionAcc}" size="1" style="width:230px">
<apex:selectOptions value="{!optionAccList}"></apex:selectOptions>
<apex:actionSupport event="onchange" action="{!searchAccOppList}" reRender="oppId/>
</apex:selectList>
Controller:
public with sharing class AccOppContentController {
public String optionAcc {get; set;}
public List<SelectOption> optionAccList {get; set;}
private List<Account> accList = new List<Account>();
public AccOppContentController(){
accList = [Select Id, Name
From Account Order by Name limit 10];
optionAccList = new List<SelectOption>();
if(accList != null && !accList.isEmpty()){
optionAccList.add(new SelectOption(‘‘, ‘--None--‘));
for(Account acc : accList){
optionAccList.add(new SelectOption(acc.Id, acc.Name));
}
}
}
}
下拉列表:
<apex:selectList>中的value要绑定一个String类型的变量。
<apex:actionSupport>中的value要绑定一个List。
<apex:actionSupport>对在它上面的那个控件进行一个事件绑定和一个方法绑定。
SF :Salesforce中,用apex实现下拉列表,布布扣,bubuko.com
原文:http://919637235.blog.51cto.com/7344598/1529930