问题描述
我已经读过,我们应该使用:(冒号)来渲染其他形式的组件.但就我而言
i have read that, we should use :(colon) to render components in other form. but in my case
<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"
i want to update messages(growl) from datatable component why i have to use colon update=":form:messages"
推荐答案
相对于实现 NamingContainer
接口.如您在链接的Javadoc中所看到的,至少是所有UIForm
和UIData
组件. <h:form>
就是这样的. <p:dataTable>
是另一个.
All relative client IDs (the ones not starting with :
) are searched relative to the parent component which implements the NamingContainer
interface. As you can see in the linked javadoc, that are at least all UIForm
and UIData
components. The <h:form>
is such one. The <p:dataTable>
is another one.
在特定情况下,<p:ajax>
包含在<p:dataTable>
中.因此,<p:ajax update="messages">
将在<p:dataTable>
的上下文中查找ID为messages
的子组件.但是,由于没有任何内容,因此找不到任何内容.实际上,您实际上需要使用绝对客户端ID,因为它在当前NamingContainer
父对象的上下文之外.
In your particular case, the <p:ajax>
is enclosed in <p:dataTable>
. So, the <p:ajax update="messages">
would look for a child component with ID messages
inside the context of <p:dataTable>
. However, since there is none, it won't find anything. You actually need to use an absolute client ID instead because it's outside the context of the current NamingContainer
parent.
这篇关于何时在jsf组件中使用:(冒号)进行渲染的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!