更新时间:2023-11-28 09:10:40
如果您使用的是JSF 2,则可以通过ajax提交并更新表单.这样可以部分更新视图.
If you're using JSF 2, then you could just submit and update the form by ajax. This allows for partially updating the view.
<h:form>
<h:messages />
...
<h:commandButton ...>
<f:ajax execute="@form" render="@form" />
</h:commandButton>
</h:form>
<h:form>
<h:messages />
...
<h:commandButton ...>
<f:ajax execute="@form" render="@form" />
</h:commandButton>
</h:form>
或者如果您出于某些显而易见的原因而不想/不想使用ajax,或者仍在使用旧版JSF 1.x,那么请检查<h:messages>
的rendered
属性,如果所需的形式是已提交或不是.
Or if you can't/don't want to use ajax for some unobvious reason, or are still using the legacy JSF 1.x, then check in the rendered
attribute of <h:messages>
if the desired form is been submitted or not.
<h:form binding="#{form1}">
<h:messages rendered="#{form1.submitted}" />
...
<h:commandButton ... />
</h:form>
<h:form binding="#{form2}">
<h:messages rendered="#{form2.submitted}" />
...
<h:commandButton ... />
</h:form>
与您在问题中暗示的相反,<h:message>
不应出现此问题.
The <h:message>
shouldn't have this problem by the way, in contrary to what you're implying in your question.