使用< f:ajax>失去验证 [英] Losing validation with <f:ajax>

查看:137
本文介绍了使用< f:ajax>失去验证的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这个表格:

 <h:form id="form">
    <h:panelGrid columns="3" >

        <h:outputLabel for="name"   value="Name:" />
        <h:inputText   id="name"    value="#{register.person.name}"  >  
            <f:ajax    event="blur" listener="#{register.validateName}" render="m_name" />
        </h:inputText>
        <rich:message  id="m_name"  for="name"  ajaxRendered="false"/>

        <!-- other fields -->                 

        <h:commandButton value="Register" action="#{register.registerPerson}" >
            <f:ajax execute="@form" render="out" />
        </h:commandButton>

        <h:outputText value="#{register.recordStatus}" id="out" />

</h:panelGrid>

如果我尝试注册一个没有名字的人,并且不会显示错误消息.取而代之的是,删除人员时出现错误消息:<f:ajax execute="@form" render="out" />.

If I try to register some person without a name and no error message is displayed. Instead, an error message appears when removing a person : <f:ajax execute="@form" render="out" />.

为什么会这样?

推荐答案

您还需要在render中包括消息的ID.

You need to include the ID of the message in the render as well.

<f:ajax execute="@form" render="m_name out" />

如果您有多条消息,也可以只渲染整个表单.

You can also just render the entire form if you have more than one message.

<f:ajax execute="@form" render="@form" />

另请参见:

  • JSF 2.0中的通信-Ajax验证
  • See also:

    • Communication in JSF 2.0 - Ajax Validation
    • 这篇关于使用&lt; f:ajax&gt;失去验证的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆