2013-05-27 25 views
1

現在看起來<apex:selectCheckboxes>的任何東西都不起作用(不管版本是什麼,因爲我嘗試在頁面和控制器上反轉)。全調試步驟參見博客條目:http://salesforcegirl.blogspot.hu/2013/05/bug-with.html頂點錯誤:Spring13版本中的selectCheckboxes

試圖用重複來填充通過地圖失敗,以及兩個<apex:selectCheckboxes><apex:selectList>的列表時。但是如果你這樣做的話,你至少可以得到<apex:selectList>,但不是<apex:selectCheckboxes>(這是我需要的)。

下面是代碼:

public class sfg_testBugWithActionButton { 

    public String fGrade {get; set;} 
    public List<SelectOption> soGrade {get; set;} 
    public String resultString {get; set;} 

    public sfg_testBugWithActionButton() { 
    createfilterMap(); 
    resultString = 'on Load of page'; 
    } 

    public PageReference preformAction() { 
    system.debug('Grade: ' + fGrade);//this wont be hit unless you use selectList 
    resultString = 'button action preformed'; 
    return null; 
    } 

    private void createfilterMap() { 
    soGrade = new List<SelectOption>(); 
    soGrade.add(new SelectOption('A', 'A')); 
    soGrade.add(new SelectOption('B', 'B')); 
    soGrade.add(new SelectOption('C', 'C')); 
    } 

}

頁:

<apex:page showHeader="true" sidebar="true" controller="sfg_testBugWithActionButton"> 
    <apex:form> 
    <apex:outputpanel id="mainWrap"> 

    <h2>Grade</h2> 
    <apex:selectCheckboxes value="{!fGrade}" layout="pageDirection"> 
     <apex:selectOptions value="{!soGrade}" /> 
    </apex:selectCheckboxes> 

    <apex:commandButton action="{!preformAction}" rerender="renderWrap" value="Submit Action" /> 
    <br /> 

    <apex:outputpanel id="renderWrap"> 
     {!resultString} 
    </apex:outputpanel> 

    </apex:outputpanel> 
    </apex:form> 
</apex:page> 

回答

1

<apex:selectCheckboxes>持有多個值,從而它的值必須是一個字符串數組:

public List<String> fGrade {get; set;} 

然後你只需要在構造函數初始化它,並在問題中所說的工作原理:

this.fGrade = new List<String>(); 
+0

即使它通過構造函數和他們的文檔中,它說調用該方法被初始化它需要一個List ? – SalesForceGirl

+0

http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=apex_pages_selectoption.htm|StartTopic=Content%2Fapex_pages_selectoption.htm|SkinName=webhelp – SalesForceGirl

+0

如果不是 那麼你會如何將它寫在頁面上? – SalesForceGirl