2011-03-22 29 views
0

我有以下問題,當我使用selectManyCheckBox:SelectManyCheckBox java.lang.Boolean中不能轉換到javax.faces.model.SelectItem

campaignInformationForm.campaignInformation.googleAnalytics(這是布爾對象)

java.lang.Boolean中不能轉換到 javax.faces.model.SelectItem

,我的代碼是:

<ice:selectManyCheckbox id="options" layout="pageDirection" > 
     <f:selectItem itemValue="#{campaignInformationForm.campaignInformation.googleMerchantAccount}" itemLabel="#{msgs['page.information.GoogleAccount']}" /> 
     <f:selectItem itemValue="#{campaignInformationForm.campaignInformation.googleMap}" itemLabel="#{msgs['page.information.GoogleMap']}" /> 
     <f:selectItem itemValue="#{campaignInformationForm.campaignInformation.googleAnalytics}" itemLabel="#{msgs['page.information.GoogleAnalytics']}" /> 
    </ice:selectManyCheckbox> 

任何想法?

編輯:

這是我的DTO

public class CampaignInformation implements Serializable{ 
.....BOILERPLAIT CODE ... 
     private boolean googleMerchantAccount; 
    private boolean googleMap; 
    private boolean googleAnalytics; 
.....GETTER/SETTER ... 

,我想一個複選框,可以與布爾合作選擇/取消根據自己的價值,能不能做到?

回答

3

您示例中的f:selectItem標籤在這裏是正確的。我幾乎可以肯定你在一個selectItem中使用了「value」而不是「itemValue」(可能你刪除了一個乾淨的例子?)。

此外,選擇將存儲在哪裏?我想你應該有一個「值」屬性(實際上,這個時間)在冰:selectManyCheckbox,像這樣:

<ice:selectManyCheckbox id="options" layout="pageDirection" value="#{campaignInformationForm.selectedItems}"> 
    <f:selectItem itemValue="#{campaignInformationForm.campaignInformation.googleMerchantAccount}" itemLabel="#{msgs['page.information.GoogleAccount']}" /> 
    <f:selectItem itemValue="#{campaignInformationForm.campaignInformation.googleMap}" itemLabel="#{msgs['page.information.GoogleMap']}" /> 
    <f:selectItem itemValue="#{campaignInformationForm.campaignInformation.googleAnalytics}" itemLabel="#{msgs['page.information.GoogleAnalytics']}" /> 
</ice:selectManyCheckbox> 

(selectedItems是一個列表或所選項目的數組)

+0

我想做的事設置#{campaignInformationForm.campaignInformation.googleMerchantAccount}所選的值...例如,如果被選中,這將是真實的,你是正確的我使用的價值,但現在我迷路了我怎麼可以將它與組件綁定 – Necronet 2011-03-22 21:45:49

+0

我只是編輯我的答案。所選值的列表由selectManyCheckBox標籤指定。 – ymajoros 2011-03-22 22:11:02

相關問題