我有一個Xpage字段連接到文檔上下文,其中用戶輸入值並將其提交給數據庫。如何在沒有文檔上下文的對話框中顯示來自驗證的錯誤?
此外還有一個按鈕,顯示來自擴展庫的對話框。該對話框包含所需的附加字段和其他驗證器(正則表達式)。關閉這個對話框的按鈕是一個Button類型,事件上的SSJS只將對話框的值傳遞給下面的表單。
我現在面臨的問題是,在字段中的驗證被執行,但在對話框中顯示沒有錯誤。我可以告訴他們執行,因爲對話框不能關閉。當沒有顯示錯誤信息時,這會讓用戶感到困惑。我已經測試了錯誤消息控件,錯誤消息控件,並且還啓用了客戶端驗證。
我怎樣才能在對話框中的對話/錯誤信息控制顯示驗證?
對話框:
<xe:dialog
id="dialogNewSec"
title="New Security Request"
>
<xe:dialogContent id="dialogContent1">
<xe:formTable
id="formTable2"
labelPosition="above"
formDescription="Fields marked with * are mandatory"
>
<xp:this.facets></xp:this.facets>
<xp:messages id="messages1"></xp:messages>
<xe:formRow
id="formRow1"
label="ISIN:"
for="inputText1"
>
<xp:inputText
id="inputText1"
required="true"
disableClientSideValidation="false"
maxlength="12"
>
<xp:this.validators>
<xp:validateRequired message="ISIN is required"></xp:validateRequired>
<xp:validateLength
maximum="12"
message="ISIN must not be more than 12 characters"
>
</xp:validateLength>
<xp:validateConstraint message="ISIN is incorrect">
<xp:this.regex><![CDATA[/^[A-Z]{2}/]]></xp:this.regex>
</xp:validateConstraint>
</xp:this.validators>
<xp:eventHandler
event="onchange"
submit="false"
>
<xp:this.script><![CDATA[var e = window.document.getElementById("#{id:inputText1}");
e.value = e.value.toUpperCase();]]></xp:this.script>
</xp:eventHandler>
</xp:inputText><xp:message id="message1" for="inputText1"></xp:message>
<xp:this.facets></xp:this.facets>
</xe:formRow>
<xe:formRow
id="formRow3"
label="Exchange:"
for="comboBox1"
>
<xp:comboBox
id="comboBox1"
disableClientSideValidation="false"
required="true"
>
<xp:this.validators>
<xp:validateRequired message="Exchange is required"></xp:validateRequired>
</xp:this.validators>
<xp:selectItem
itemValue=""
itemLabel="*Select an Exchange*"
>
</xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:var values = DbColumnArray("", "", "cache", "unique", "", "vExchangeLookup", 3)+"|"+DbColumnArray("", "", "cache", "unique", "", "vExchangeLookup", 2);
return values;}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xe:formRow>
<xe:formRow
id="formRow4"
label="Currency:"
for="comboBox2"
>
<xp:comboBox
id="comboBox2"
disableClientSideValidation="false"
>
<xp:this.validators>
<xp:validateRequired message="Currency must have a value"></xp:validateRequired>
</xp:this.validators>
<xp:selectItem
itemLabel="* Select a currency *"
itemValue=""
>
</xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:@DbColumn("","vCurrLookup",1);
}]]></xp:this.value>
</xp:selectItems>
<xp:eventHandler
event="onchange"
submit="false"
>
<xp:this.script><![CDATA[var curr = document.getElementById("#{id:comboBox2}").value;
var qc = document.getElementById("#{id:Currency}")
qc.value = curr]]></xp:this.script>
</xp:eventHandler>
</xp:comboBox>
</xe:formRow>
<xe:formRow
id="formRow2"
for="inputText2"
label="PSET:"
>
<xp:inputText
id="inputText2"
required="true"
>
<xp:this.validators>
<xp:validateRequired message="PSET is required"></xp:validateRequired>
</xp:this.validators>
</xp:inputText>
</xe:formRow>
<xe:formRow
id="formRow5"
label="Quoted Currency:"
rendered="false"
for="comboBox3"
>
<xp:comboBox id="comboBox3">
<xp:selectItem
itemLabel="* Select a Currency *"
itemValue=""
>
</xp:selectItem>
<xp:selectItems>
<xp:this.value><![CDATA[#{javascript:@DbColumn("","vCurrLookup",1);
}]]></xp:this.value>
</xp:selectItems>
</xp:comboBox>
</xe:formRow>
</xe:formTable>
</xe:dialogContent>
<xe:dialogButtonBar id="dialogButtonBar1">
<xp:panel>
<xp:button
value="Submit"
id="button4"
>
<i class="fa fa-large fa-fw fa-save"></i>
<xp:eventHandler
event="onclick"
submit="true"
refreshMode="partial"
refreshId="InstrumentDealPanel"
immediate="false" save="false">
<xp:this.action><![CDATA[#{javascript:sessionScope.SDR = null;
sessionScope.SDR = (sessionScope.SDR || new java.util.HashMap());
sessionScope.SDR.put("Form", compositeData.sdrForm);
sessionScope.SDR.put("PortfolioSystem", getComponentValue("PortfolioSystem"));
sessionScope.SDR.put("Request", "Y");
sessionScope.SDR.put("StaticRequested", "Yes");
sessionScope.SDR.put("Status",0);
sessionScope.SDR.put("StaticReqStatus", "New");
sessionScope.SDR.put("InstrumentType", compositeData.InstrumentType);
sessionScope.SDR.put("ISIN", getComponentValue("inputText1"));
sessionScope.SDR.put("Exchange", getComponentValue("comboBox1"));
sessionScope.SDR.put("Currency", getComponentValue("comboBox2"));
sessionScope.SDR.put("QuotationCurrency", getComponentValue("comboBox3"));
sessionScope.SDR.put("PSET", getComponentValue("inputText2"));
try {
getComponent("ISIN").setValue(sessionScope.SDR.ISIN);
} catch(e) {}
try {
getComponent("InstrumentShort").setValue("");
} catch(e) {}
try {
getComponent("InstrumentName").setValue("");
} catch(e) {}
try {
getComponent("RIC").setValue("");
} catch(e) {}
try {
getComponent("CUSIP").setValue("");
} catch(e) {}
try {
getComponent("SEDOL").setValue("");
} catch(e) {}
try {
getComponent("BloombergID").setValue("");
} catch(e) {}
try {
getComponent("MaturityDate").setValue("");
} catch(e) {}
try {
getComponent("InstrumentType").setValue(sessionScope.SDR.InstrumentType);
} catch(e) {}
try {
getComponent("Exchange").setValue(sessionScope.SDR.Exchange);
} catch(e) {}
try {
getComponent("QuotationCurrency").setValue(sessionScope.SDR.QuotationCurrency);
} catch(e) {}
try {
getComponent("Currency").setValue(sessionScope.SDR.Currency);
} catch(e) {}
try {
getComponent("PSET").setValue(sessionScope.SDR.PSET);
} catch(e) {}
try {
getComponent("PSETFull").setValue("");
} catch(e) {}
getComponent("dialogNewSec").hide();}]]></xp:this.action>
</xp:eventHandler>
</xp:button>
<xp:button
value="Cancel"
id="button5"
>
<i
class="fa fa-lg fa-fw fa-times"
style="color:red;"
>
</i>
<xp:eventHandler
event="onclick"
submit="false"
>
<xp:this.script><![CDATA[XSP.closeDialog('#{id:dialogNewSec}')]]></xp:this.script>
</xp:eventHandler>
</xp:button>
</xp:panel>
</xe:dialogButtonBar>
</xe:dialog>
按鈕顯示對話框:
<xp:button
value="New Security..."
id="NewSecurityButton"
title="Create a new Security Request"
>
<i
class="fa-external-link"
></i>
<xp:this.rendered><![CDATA[#{javascript:@IsNewDoc() && compositeData.enableSDR && sessionScope.userRoles.contains("[STATICREQ]");}]]></xp:this.rendered>
<xp:eventHandler
event="onclick"
submit="false"
id="eventHandler4"
>
<xp:this.script><![CDATA[XSP.openDialog("#{id:dialogNewSec}");]]></xp:this.script>
</xp:eventHandler>
</xp:button>
謝謝,保羅!我遵循到目前爲止,我的refreshID必須與對話框相關,但如何更新「下面」表單中的字段我無法弄清楚...... – 2014-10-02 14:17:47
沒關係,我只是閱讀你的回答更徹底,並找出它!謝謝一堆! – 2014-10-02 15:50:01