[英]rich:autocomplete rerendering labels
I have 2 fields in a jsf form. 我在jsf表单中有2个字段。 Field 1 uses rich:autocomplete, and field 2 uses inputText. 字段1使用rich:autocomplete,而字段2使用inputText。 I type invalid data in field 2 so that the validation message appears. 我在字段2中键入无效数据,以便显示验证消息。 Next, I start typing in field 1. As soon as I do this, the validation message in field 2 disappears. 接下来,我开始在字段1中键入。一旦执行此操作,字段2中的验证消息就会消失。 How can I prevent this? 我该如何预防?
<h:outputLabel value="Field 1:" escape="false"/>
<h:panelGroup>
<rich:autocomplete id="id1" mode="ajax" showButton="false"
autocompleteMethod="#{bean.method}"
autocompleteList="#{bean.aList}"
value="#{bean.field}"
required="true"
requiredMessage="Field 1 required">
<a4j:ajax event="blur" execute="@this" bypassUpdates="#{true}" render="id1,id1Msg" />
</rich:autocomplete>
<rich:message for="id1" id="id1Msg" />
</h:panelGroup>
<h:outputLabel for="id2" value="Field 2:"/>
<h:panelGroup>
<h:inputText id="id2" value="#{bean.field2}" style="width: 175px;" required="true" requiredMessage="Field 2 required" validatorMessage="Field 2 Please enter digits only" converterMessage="Field 2 - Please enter digits only">
<f:ajax event="change" execute="@this" bypassUpdates="#{true}" render="id2Msg"/>
</h:inputText>
<rich:message for="id2" id="id2Msg"/>
</h:panelGroup>
Set execute="@form"
on id2
. 在id2
上设置execute="@form"
。 This will cause id2
to always trigger the submission of the entire form, even when it loses focus, causing the validation message to appear 即使id2
失去焦点,这也会导致id2
始终触发整个表单的提交,从而导致出现验证消息
execute="@this"
on id2
as it stands means that only the parent component will be triggered 在id2
上execute="@this"
id2
仅父组件将被触发
通过在id1上使用execute =“ @ form”获得了所需的行为。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.