Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/jsf/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jsf-2/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsf 使用<;f:ajax>;_Jsf_Jsf 2_Richfaces - Fatal编程技术网

Jsf 使用<;f:ajax>;

Jsf 使用<;f:ajax>;,jsf,jsf-2,richfaces,Jsf,Jsf 2,Richfaces,我有以下表格: <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" l

我有以下表格:

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

如果我尝试注册一个没有姓名的人,并且没有显示错误消息。取而代之的是,删除人员时会出现一条错误消息:


为什么会发生这种情况?

您还需要在
呈现中包含消息的ID

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

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

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

另见:

    • 可能有点晚了,但是

      的属性具有默认值
      true
      ,这将强制它出现在AJAX响应中

      在表单中将其设置为
      false
      ,因此必须指定哪些AJAX调用应该重新呈现它