1
我对primefaces
对话框有问题。我有自定义验证。 我创建了javascript方法来保持自定义验证失败时打开的对话框。 虽然验证失败,但它仍然关闭。如何使用javascript保持primefaces对话框打开
这里是我的代码:
function alertMsg()
{
var str1 = document.getElementById("templateForm:resultMsg").textContent;
var str2 = "Duplicate name.";
if(str1.localeCompare(str2) == 0)
{
alert("inside same!")
PF(dlg).show(); //Although i try to keep open, this dialog always close.
}
}
.....some code
<p:dialog header="Add" widgetVar="dlg" id="add" resizable="false" modal="true" closable="false" width="600px" >
<h:panelGrid columns="4" cellpadding="5" >
<p:outputLabel value="Name" style="width:130px;"/>
<p:outputLabel value=":" style="width:15px;"/>
<h:inputText id="Name" value="#{Bean.Name}" styleClass="form-control" style="width:300px;" required="true" requiredMessage="!" >
</h:inputText>
<h:outputText id="resultMsg1" value="Duplicate name." style="color:red; width:30px;"/>
</h:panelGrid>
<p:commandButton process="@parent" ajax="true" value="Save" onstart="alertMsg()"
update= templateForm:resultMsg" action="#{Bean.save()}" styleClass="btn btn-danger">
</p:commandButton>
</p:dialog>
详细解释请尝试使用'返回false;'你的js函数。 – Apostolos
仍然无法工作,请继续关闭。 – Alice
我也认为你可能需要'actionListener'而不是'action',但我不是100%肯定的。 – Apostolos