XPages 复选框组和默认值
XPages checkboxgroup and default value
作为我关于复选框组的问题的后续,如何设置默认值?
这是测试 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>
人们可能希望选中带有标签 "First" 的复选框,但事实并非如此。对此有任何见解将不胜感激。
谢谢!
丹,
尝试两件事:
简单修复 #1:将默认值更改为 itemValue。所以这是默认值:return "1";
简单修复 #2:将代码放入 beforePageLoad 以将默认值设置为其绑定的数据。例如:如果复选框绑定了一个名为 "myCheckBox" 的 viewScope 变量。将代码放在 beforePageLoad 中以设置 viewScope.myCheckBox = "1"
作为我关于复选框组的问题的后续,如何设置默认值?
这是测试 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>
人们可能希望选中带有标签 "First" 的复选框,但事实并非如此。对此有任何见解将不胜感激。
谢谢!
丹,
尝试两件事:
简单修复 #1:将默认值更改为 itemValue。所以这是默认值:return "1";
简单修复 #2:将代码放入 beforePageLoad 以将默认值设置为其绑定的数据。例如:如果复选框绑定了一个名为 "myCheckBox" 的 viewScope 变量。将代码放在 beforePageLoad 中以设置 viewScope.myCheckBox = "1"