以下保存按钮代码适用于移动设备xpage:
var checkBox31:com.ibm.xsp.component.xp.XspInputCheckbox = getComponent("checkBox31");
var customerID1:com.ibm.xsp.component.xp.XspInputText = getComponent("customerID1");
var a = checkBox31.getValue();
var b = customerID1.getValue()
if (a == "" || a == null){
if (b == ""){
sessionScope.put("ITDialog","You must enter Customer ID");
var dialog1:com.ibm.xsp.extlib.component.dialog.UIDialog = getComponent("dialog1");
dialog1.show();
}
}
但它不适用于网页xpage。我正在使用8.5.3FP6。我使用8.5.3FP1和8.5.3FP5 bu有同样的问题。
提前感谢您的帮助。
以下是无效的代码示例。
]]></xp:this.script>
</xp:executeClientScript>
</xp:this.script>
</xp:eventHandler>
</xp:button>
 
</xp:panel>
</xe:dialog>
</xp:panel>
<xp:table>
<xp:tr>
<xp:td style="background-color:rgb(226,226,226)">
<xp:label
value="Company:"
id="company_Label1"
for="company1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText
value="#{document1.Company}"
id="company1">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="background-color:rgb(226,226,226)">
<xp:label
value="Address:"
id="address_Label1"
for="address1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText
value="#{document1.Address}"
id="address1">
</xp:inputText>
</xp:td>
</xp:tr>
<xp:tr>
<xp:td style="background-color:rgb(226,226,226)">
<xp:label
value="Contact person:"
id="contactPerson_Label1"
for="contactPerson1">
</xp:label>
</xp:td>
<xp:td>
<xp:inputText
value="#{document1.ContactPerson}"
id="contactPerson1">
</xp:inputText>
</xp:td>
</xp:tr>
</xp:table>
</xp:panel>
</xp:view>
答案 0 :(得分:1)
复选框的值为&#39; false&#39;或者&#39; true&#39; (表示已经取消选择&#39;&#39;&#39;&#39;选择&#39;),它不应该返回&#34;&#34;的值。或者为null。因此,第一个if语句永远不会出现,并且您的对话框永远不会出现。
我相信你想要的是,如果取消选中该复选框,则必须在输入中输入客户ID。如果是这样,我认为这是你想要的代码:
var checkBox31:com.ibm.xsp.component.xp.XspInputCheckbox = getComponent("checkBox31");
var customerID1:com.ibm.xsp.component.xp.XspInputText = getComponent("customerID1");
var a = checkBox31.getValue();
var b = customerID1.getValue();
if (a == "false") {
if (b == "") {
sessionScope.put("ITDialog","You must enter Customer ID");
var dialog1:com.ibm.xsp.extlib.component.dialog.UIDialog = getComponent("dialog1");
dialog1.show();
}
}