當我試圖通過單擊命令按鈕從picklist和inputText值中獲取選定值時,它並不真正將它們傳遞給我的控制器。爲什麼我沒有從我的控制器上的visualforce頁面獲取值?
VF:
<apex:page controller="FieldsAndTypesPicklists" >
<apex:form >
<apex:inputText value="{!newDatasetName}" />
<apex:outputlabel value="Product type: "/>
<apex:selectList value="{!selectedTypeProd}" size="1">
<apex:selectOptions value="{!TypesProduct}"/>
</apex:selectList>
<apex:commandButton value="Add new values" action="{!SaveValues}" />
</apex:form>
</apex:page>
控制器:
public with sharing class FieldsAndTypesPicklists {
public String selectedTypeProd {get; set;}
public String newDatasetName { get; set; }
public void SaveValues() {
System.debug('>>> InputText value: '+newDatasetName);
}
public Set<SelectOption> getTypesProduct(){
System.debug('>>> Select Type value: '+selectedTypeProd);
Set<SelectOption> typesProd = new Set<SelectOption>();
List<Schema.PicklistEntry> picklistEntryList = OpportunityLineItem.TypeProduct__c.getDescribe().getPicklistValues();
for(Schema.PicklistEntry plEntry : picklistEntryList){
String typeProduct = string.ValueOf(plEntry.getValue());
typesProd.add(new SelectOption(typeProduct, typeProduct));
}
return typesProd;
}
}
我已經做了相應的(1)調試看到的inputText和選擇列表選擇的值。
- selectedTypeProd是空
- 它不執行該方法SaveValues()
如果我取出一段代碼,其中爲所選列表(在VF)和在控制器中的getTypesProduct()方法對輸入文本值工作正常。看來另一部分正在影響執行。