如何检查RichFaces组件rich:messages是否有Javascript中的消息?
我需要检查呈现的如何检查RichFaces组件rich:messages是否有Javascript中的消息?,javascript,jsf-2,richfaces,Javascript,Jsf 2,Richfaces,我需要检查呈现的rich:messages组件是否附加了来自JavaScript的任何消息 在执行AJAX调用后,我将通过a4j:jsFunction重新发布rich:messages组件,我想检查Javascript是否附加了任何消息(这意味着验证没有通过) a4j:jsf函数的代码如下: <a4j:jsFunction name="validateSomething" render="erroFinaliza" execute="@form" action="#{som
rich:messages
组件是否附加了来自JavaScript的任何消息
在执行AJAX调用后,我将通过a4j:jsFunction
重新发布rich:messages
组件,我想检查Javascript是否附加了任何消息(这意味着验证没有通过)
a4j:jsf函数的代码如下:
<a4j:jsFunction name="validateSomething" render="erroFinaliza"
execute="@form" action="#{someMB.preview}">
</a4j:jsFunction>
<h:commandButton onclick="validateSomething(); return false;" value="Do Something" />
<h:form id="id_form">
<rich:messages id="errors" />
...
<script>
function submitIfEmpty(noMessages){
if (noMessages){
document.getElementById('id_form:hiddenButton').click();
}
};
</script>
...
<a4j:commandButton value="Do Something" render="errors" execute="@form"
oncomplete="submitIfEmpty(#{empty facesContext.maximumSeverity});" />
<h:commandButton id="hiddenButton" action="#{someMB.doSomething}"
value="Do Something (not visible)" style="visibility: hidden" />
</h:form>
我需要一种通过JavaScript检查验证结果的方法,然后真正提交表单
我检查了一下是否有办法检查它是否附加了任何消息,但它没有Javascript API
有人有更好的主意吗?我在网上找到了一个黑客解决方案 我将
a4j:jsFunction
替换为仅用于执行验证的a4j:commandButton
然后在这个a4j:commandButton
的oncomplete
上,我放了一个JS,检查验证是否通过,然后“单击”另一个不可见的h:commandButton
,它提交表单进行实际操作
所以,它是这样的:
<a4j:jsFunction name="validateSomething" render="erroFinaliza"
execute="@form" action="#{someMB.preview}">
</a4j:jsFunction>
<h:commandButton onclick="validateSomething(); return false;" value="Do Something" />
<h:form id="id_form">
<rich:messages id="errors" />
...
<script>
function submitIfEmpty(noMessages){
if (noMessages){
document.getElementById('id_form:hiddenButton').click();
}
};
</script>
...
<a4j:commandButton value="Do Something" render="errors" execute="@form"
oncomplete="submitIfEmpty(#{empty facesContext.maximumSeverity});" />
<h:commandButton id="hiddenButton" action="#{someMB.doSomething}"
value="Do Something (not visible)" style="visibility: hidden" />
</h:form>
...
函数submitIfEmpty(noMessages){
如果(名称信息){
document.getElementById('id_form:hiddenButton')。单击();
}
};
...