I'm getting the following error when I click on the commandbutton in my Visualforce page:
EXCEPTION_THROWN [EXTERNAL]|System.TypeException: Invalid conversion from runtime type String to System.SelectOption
From an earlier question, I've learned that the setters in the controller get called with the view state before the action method gets called.
Here's the Visualforce column with the problem. If I comment it out, I don't get the error. I don't see why there would be a string to be converted in the set, but perhaps someone else here can see what I'm missing.
<apex:pageBlockTable value="{!ScholarList}" var="sl" id="table" rows="100">
...
<apex:pageBlockSectionItem >
<apex:commandButton action="{!removeSelectedNow}" value="Remove Selected Now" rerender="tablepanel,tableblock,table,panelMsg" id="theRemoveBtn"/><p/>
</apex:pageBlockSectionItem>
...
<apex:column headervalue="Reason Removed">
<apex:selectList size="1" value="{!sl.RemoveReason}">
<apex:selectOptions value="{!RemoveOptions}"/>
</apex:selectList>
</apex:column>apex:column>
Here's the Apex side:
//list of scholars for the controller/VF page
public List<SiteScholar> ScholarList {get; set;}
public List<SelectOption> RemoveOptions {get;set;}
...
//wrapper class to hold individual scholar info
public class SiteScholar {
public Boolean forWithdrawAction{get;set;}
public SelectOption RemoveReason {get;set;}
...
// method to load the selectoptions
public List<SelectOption> RemoveOptionsLoad(){
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('None','--None--'));
Schema.DescribeFieldResult fieldResult = Scholar_Program_Application__c.Status_Change_Reason__c.getDescribe();
List<Schema.PicklistEntry> ple = fieldResult.getPicklistValues();
for(Schema.PicklistEntry p : ple)
options.add(new SelectOption(p.getValue(), p.getValue()));
return options;
}
The selectoptions appear in the VF page, but I see the conversion error listed above when I click the command button.
commandButton
.getRemoveOptions
function or aRemoveOptions
variable name.