我正在尝试创建一个类,该类将根据传入的 URL 参数填充多选列表。
我有麻烦。slectlist 永远不会呈现,但是,通过调试器查看,我可以看到记录已找到并且应该填充。
我错过了什么愚蠢的东西吗?
VisualForce.Page
<apex:page controller="PopUp">
<apex:form >
<apex:selectList value="{!objectType}" multiselect="true">
<apex:selectOptions value="{!SelectListOptions}"/>
</apex:selectList>
</apex:form>
控制器类:
public with sharing class PopUp {
public sObject objParameter {get;set;}
public string fldParameter {get;set;}
public string queryType {get;set;}
public static string objName{get;set;}
public list<SelectOption> selectListOptions {get;set;}
public static list<string> TEST {get;set;}
public String[] objectType= new String[]{};
public PopUp(){
objName = ApexPages.currentPage().getParameters().get('obj');
sObject dynObject = Schema.getGlobalDescribe().get(objName).newSObject() ;
objParameter = dynObject;
fldParameter = ApexPages.currentPage().getParameters().get('fld');
String queryType = ApexPages.currentPage().getParameters().get('qt');
system.debug('***objParameter: ' + objParameter);
system.debug('***fldParameter: ' + fldParameter);
//List<selectOption> L = getPicklistValues(objParameter, fldParameter, queryType);
}
public static list<SelectOption> getPicklistValues(SObject obj, String fld, String queryType)
{
list<SelectOption> options = new list<SelectOption>();
if(queryType == 'soql'){
string query = 'select ' + fld + ' from ' + objName;
system.debug('***query: ' + query);
List<sObject> dynList = Database.query(query);
system.debug('***dynList: ' + dynList);
for(integer i=0;i< dynList.size();i++){
string fldValue = string.valueof(dynList[i].get(fld));
system.debug('***fldValue: ' + fldValue);
options.add(new SelectOption(fldValue,fldValue));
TEST.add(fldValue);
}
}
system.debug('***options: ' + options);
return options;
}
public List<selectOption> getSelectListOptions() {
return getPicklistValues(objParameter, fldParameter, queryType);
}
public String[] getObjectType()
{
return objectType;
}
public void setObjectType(String[] objectType)
{
this.objectType= objectType;
}