当我尝试在控制器扩展中保存记录时,我收到“转换错误设置值”。该页面看起来像我期望的那样,但是当我选择一个或多个复选框时,它给出了我的错误。我没有看到这里的错误。谢谢您的帮助。
这页纸:
<apex:pageBlockSectionItem >
<apex:OutputLabel value="Assigned Areas of Coverage" for="books" />
<apex:selectCheckboxes value="{!selectedBooks}"
layout="pageDirection" id="books">
<apex:selectOptions value="{!options}" />
</apex:selectCheckboxes>
</apex:pageBlockSectionItem>
控制器:
public String[] selectedBooks {get; set;}
public List<SelectOption> options
{
get
{
List<SelectOption> result = new List<SelectOption>();
List<String> optionNames = bookNames(books);
optionNames.sort();
for(String n : optionNames){
if(!blacklist.contains(n)){
result.add(new SelectOption(n, n));
}
}
return result;
}
}
private List<Book__c> books
{
get
{ if (books == null){
books = [select Id, Name from Book__c];
}
return books;
}
set;
}
private List<String> bookNames(List<Coverage__c> coverage)
{
List<String> result = new List<String>();
for(Coverage__c c : coverage){
result.add(c.Book__r.Name);
}
return result;
}
private List<String> bookNames(List<Book__c> books)
{
List<String> result = new List<String>();
for(Book__c b : books){
result.add(b.Name);
}
return result;
}
private List<Id> bookIDs(List<String> bookNames)
{
List<Id> result = new List<Id>();
Set<String> bookNamesSet = new Set<String>(bookNames);
for(Book__c b : books){
if(bookNamesSet.contains(b.Name)){
result.add(b.Id);
}
}
return result;
}