jsf-2 - 何时使用 :(colon) in rendering in jsf components

标签 jsf-2 primefaces

我读过,我们应该使用 :(colon) 以其他形式呈现组件。但就我而言

<h:form id="form">
    <p:growl id="messages"></p:growl>
    <p:dataTable var="e" value="#{employees.eList}" id="elist1"
        editable="true">
        <f:facet name="header">
        In-Cell Editing
    </f:facet>
        <p:ajax event="rowEdit" listener="#{employees.onEdit}" update=":form:messages"/>

        <p:ajax event="rowEditCancel" listener="#{employees.onCancel}" />

        <p:column headerText="name" style="width:30%">
            <p:cellEditor>
                <f:facet name="output">
                    <h:outputText value="#{e.name}" />
                </f:facet>
                <f:facet name="input">
                    <h:inputText value="#{e.name}" style="width:100%" />
                </f:facet>
            </p:cellEditor>
        </p:column>
..........   ...........
</p:datatable>

我想从数据表组件更新消息(咆哮)为什么我必须使用冒号 update=":form:messages"

最佳答案

相对于实现 the : interface 的父组件搜索所有相关客户端 ID(不以 NamingContainer 开头的那些)。正如您在链接的 javadoc 中看到的那样,至少是所有 UIFormUIData 组件。 <h:form> 就是这样一个。 <p:dataTable> 是另一个。
在您的特定情况下, <p:ajax> 包含在 <p:dataTable> 中。因此, <p:ajax update="messages"> 将在 messages 的上下文中查找 ID 为 <p:dataTable> 的子组件。但是,由于没有,它不会找到任何东西。您实际上需要使用绝对客户端 ID,因为它超出了当前 NamingContainer 父级的上下文。
也可以看看:

  • How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"
  • 关于jsf-2 - 何时使用 :(colon) in rendering in jsf components,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18907770/

    相关文章:

    jsf - 访问传递给扩展 PrimeFaces 组件的属性

    java - jsf 在表单重新渲染后焦点输入文本字段,值 onblur

    JSF 2.0 中的国际化

    java - JSF/RichFaces 4 问题 : initiating component while rendering is false

    java - 单击运行 JS 函数清除表单的按钮后, View 无法恢复

    datatable - Primefaces 数据表问题

    primefaces - 如何隐藏 "agendaWeek"FullCalendar/Primefaces View 中的时间段 <p :schedule>?

    java - 如何从数据表中移交行对象

    jquery - 单击按钮时过滤 Primefaces 数据表

    java - JSF 2 : How build components correctly?