2015-06-02 114 views
0

作爲對複選框組問題的跟進,如何設置默認值?XPages複選框組和默認值

下面是測試的XPage源代碼:

<?xml version="1.0" encoding="UTF-8"?> 
<xp:view xmlns:xp="http://www.ibm.com/xsp/core"> 
<xp:checkBoxGroup id="checkBoxGroup1" defaultValue="First"> 
    <xp:selectItem itemLabel="First" itemValue="1"></xp:selectItem> 
    <xp:selectItem itemLabel="Second" itemValue="2"></xp:selectItem> 
    <xp:selectItem itemLabel="Third" itemValue="3"></xp:selectItem> 
</xp:checkBoxGroup> 
</xp:view> 

有人也許會期待與標籤「第一」要檢查的複選框,但並非如此。任何深入瞭解這一點將不勝感激。

謝謝!

回答

1

丹,

兩件事情嘗試:

簡易修復#1:更改默認值的項目值。所以這個在默認值中:return "1";

簡單修復#2:將代碼放入beforePageLoad中,將默認值設置爲綁定的數據。例如:如果複選框被綁定了一個名爲「myCheckBox」的viewScope變量。將代碼放在beforePageLoad中設置viewScope.myCheckBox = "1"

+1

謝謝史蒂夫。易於修復1工作:) –