【问题标题】:rich:autocomplete rerendering labels丰富:自动完成重新渲染标签
【发布时间】:2014-07-16 22:18:51
【问题描述】:

我在 jsf 表单中有 2 个字段。字段 1 使用 rich:autocomplete,字段 2 使用 inputText。我在字段 2 中输入无效数据,以显示验证消息。接下来,我开始在字段 1 中输入。一旦我这样做,字段 2 中的验证消息就会消失。我怎样才能防止这种情况发生?

<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>

【问题讨论】:

    标签: jsf richfaces jboss6.x


    【解决方案1】:

    id2 上设置execute="@form"。这将导致id2 总是触发整个表单的提交,即使它失去焦点,导致出现验证消息

    id2 上的execute="@this" 表示只有父组件会被触发

    【讨论】:

    • 已尝试:在 id2 上设置 execute="@form" 但行为相同。
    • 我通过在 id1 上使用 execute="@form" 获得了所需的行为。
    【解决方案2】:

    我通过在 id1 上使用 execute="@form" 获得了所需的行为。

    【讨论】:

      猜你喜欢
      • 2011-06-14
      • 2011-06-11
      • 2012-02-24
      • 2012-11-17
      • 1970-01-01
      • 1970-01-01
      • 2013-12-28
      • 2014-01-26
      • 2016-10-08
      相关资源
      最近更新 更多