我有一個需要組合框「PriceList」與顯示錯誤控制相關聯。顯示錯誤控制只能工作一次
我有一個OnChange事件的「價格」字段,用於設置「價格表」所需的屬性。如果輸入價格,則「價格表」組合框要求將屬性設置爲false,否則爲空白,則啓用「價格表」。
這兩個字段和xpage都禁用了客戶端驗證。
當創建文檔時,combox會在開始時顯示錯誤消息。如果我更改並刪除了「價格」的值,則「價格表」的錯誤控制不會顯示消息,但所需的屬性爲真。
這裏有什麼問題?
價格表代碼:
<xp:comboBox
id="comboBox7"
value="#{document1.PList1}"
style="width:99.0px"
disableClientSideValidation="true">
<xp:this.validators>
<xp:validateRequired
message="Required">
</xp:validateRequired>
</xp:this.validators>
<xp:this.required><![CDATA[#{javascript:var price11:com.ibm.xsp.component.xp.XspInputText = getComponent("price11");
var a=price11.getValueAsString()
if (a == ""){
return true;
}else{
return false;
}}]]></xp:this.required>
<xp:this.disabled><![CDATA[#{javascript:var price11:com.ibm.xsp.component.xp.XspInputText = getComponent("price11");
var a=price11.getValueAsString();
if (a==""){
return false;
} else {
return true;
}}]]></xp:this.disabled>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var result = [];
var pricelist = @DbLookup("" , "Keywords","Price List", 2)
result.push("")
for (var i = 0; i < pricelist.length; i++) {
var eachName = pricelist[i];
result.push(eachName);
}
return result;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
價格代碼:
<xp:inputText
value="#{document1.Price1}"
id="price11"
style="width:80px"
required="true"
disableClientSideValidation="true">
<xp:this.validators>
<xp:validateRequired
message="Required field">
</xp:validateRequired>
</xp:this.validators>
<xp:eventHandler event="onchange" submit="true" refreshMode="complete">
<xp:this.action>
<xp:executeScript>
<xp:this.script><![CDATA[#{javascript:var comboBox7:com.ibm.xsp.component.xp.XspSelectOneMenu = getComponent("comboBox7");
var price11:com.ibm.xsp.component.xp.XspInputText = getComponent("price11");
var a=price11.getValueAsString();
if(a !==""){
//if(comboBox7.isRequired()==true){
//comboBox7.setRequired(false);
//}
//var result = [];
//var pricelist = @DbLookup("" , "Keywords","Price List", 2)
//result.push("")
//for (var i = 0; i < pricelist.length; i++) {
//var eachName = pricelist[i];
//result.push(eachName);
//}
//comboBox7.setValue(result);
comboBox7.setRequired(false);
comboBox7.setDisabled(true);
} else {
comboBox7.setDisabled(false);
comboBox7.setRequired(true);
}
}]]></xp:this.script>
</xp:executeScript>
</xp:this.action></xp:eventHandler></xp:inputText>
與數據交談!與其試圖獲取組合框並對其進行更改,不如使用任何要改變所需屬性的方法設置的範圍變量。 – stwissel 2014-10-07 00:00:58