when I try to get the selected values from picklist and the inputText value by clicking the command button, it's not really passing them to my controller.
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>
Controller:
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;
}
}
I've made the corresponding debugs to see the inputText and the picklist selected value.
If I take out the piece of code where is the selected list (on the VF) and the getTypesProduct() method in the controller it works fine for the inputText value. It seems like the other part is affecting the execution.
答案 0 :(得分:0)
您可以将TypesProduct设为一组字符串。所以它会奏效。
答案 1 :(得分:-1)
我遇到了同样的问题,并通过添加multiselect="false"
从
更改您的代码<apex:selectList value="{!selectedTypeProd}" size="1">
到
<apex:selectList value="{!selectedTypeProd}" size="1" multiselect="false">