I have two datatables in two forms, forma and formg. Inside each form there is a p:dataTable
, groupsa and groupsg. In each datatable there is a custom column that displays an image(h:graphicImage
) called fava and favg.
我有两个数据表,有两种形式,forma和formg。在每个表单中都有一个p:dataTable,groupsa和groupsg。在每个数据表中都有一个自定义列,显示名为fava和favg的图像(h:graphicImage)。
When the image is clicked, the images from the other datatable will be updated.
单击图像时,将更新来自其他数据表的图像。
<p:ajax event="click" listener="#{agent.toogleFavorite}"
update="fava, :formg:groupsg:favg" />
Without the colon I get an exception:
没有冒号,我得到一个例外:
javax.faces.FacesException: Cannot find component with identifier "forma:agentsa:fava" referenced from "groupsg:0:favg".
What is the difference between formg:groupsg:favg and :formg:groupsg:favg?
formg:groupsg:favg和:formg:groupsg:favg有什么区别?
I am using JSF2.0 and PrimeFaces 3.4.
我使用的是JSF2.0和PrimeFaces 3.4。
2 个解决方案
#1
9
The :
prefix will make it an absolute client ID and thus it will be searched relative to the UIViewRoot
instead of the closest parent NamingContainer
. You should (must) use it when you want to refer a component which is not inside the same closest parent NamingContainer
. The <h:form>
and <h:dataTable>
(and <p:dataTable>
) are NamingContainer
components.
:前缀将使其成为绝对客户端ID,因此将相对于UIViewRoot而不是最近的父NamingContainer进行搜索。当您想要引用不在同一个最近的父NamingContainer中的组件时,您应该(必须)使用它。
)是NamingContainer组件。
See also How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar" for a detailed explaination.
另请参见如何查找ajax update / render的组件的客户端ID?无法找到具有从“bar”引用的表达式“foo”的组件以进行详细说明。
#2
5
Use the colon at the beginning when you want to search for the ID from the root of the page. It is necessary when the component that is calling for the update is not inside the same NamingContainer of the component that is being updated.
如果要从页面根目录中搜索ID,请在开头使用冒号。当正在调用更新的组件不在正在更新的组件的同一NamingContainer中时,这是必要的。
Don't use it when you want to search relatively to the same NamingContainer. You can do that when both components (the one calling the update and the one being updated) are inside the same NamingContainer.
当您想要相对搜索相同的NamingContainer时,请不要使用它。当两个组件(调用更新的组件和正在更新的组件)位于同一个NamingContainer中时,您可以这样做。
By the way, "NamingContainers" are all the components that prepend their ID to their child components, like <h:form>
, <p:dataTable>
, <p:accordionPanel>
, etc. Just look at the generated HTML to see if the parent is prepending its ID to its childs.
顺便说一句,“NamingContainers”是所有预先考虑自己的ID,以他们的孩子组件,如组件的
等,试想一下,在生成的HTML,看看父母正在将其ID添加到其子级。
- NamingContainer Javadoc.
- NamingContainer Javadoc。
- The algorithm that JSF uses for finding components by their ID.
- JSF用于按ID查找组件的算法。
- BalusC explains it in full detail here.
- BalusC在这里详细解释了它。
#1
9
The :
prefix will make it an absolute client ID and thus it will be searched relative to the UIViewRoot
instead of the closest parent NamingContainer
. You should (must) use it when you want to refer a component which is not inside the same closest parent NamingContainer
. The <h:form>
and <h:dataTable>
(and <p:dataTable>
) are NamingContainer
components.
:前缀将使其成为绝对客户端ID,因此将相对于UIViewRoot而不是最近的父NamingContainer进行搜索。当您想要引用不在同一个最近的父NamingContainer中的组件时,您应该(必须)使用它。
)是NamingContainer组件。
See also How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar" for a detailed explaination.
另请参见如何查找ajax update / render的组件的客户端ID?无法找到具有从“bar”引用的表达式“foo”的组件以进行详细说明。
#2
5
Use the colon at the beginning when you want to search for the ID from the root of the page. It is necessary when the component that is calling for the update is not inside the same NamingContainer of the component that is being updated.
如果要从页面根目录中搜索ID,请在开头使用冒号。当正在调用更新的组件不在正在更新的组件的同一NamingContainer中时,这是必要的。
Don't use it when you want to search relatively to the same NamingContainer. You can do that when both components (the one calling the update and the one being updated) are inside the same NamingContainer.
当您想要相对搜索相同的NamingContainer时,请不要使用它。当两个组件(调用更新的组件和正在更新的组件)位于同一个NamingContainer中时,您可以这样做。
By the way, "NamingContainers" are all the components that prepend their ID to their child components, like <h:form>
, <p:dataTable>
, <p:accordionPanel>
, etc. Just look at the generated HTML to see if the parent is prepending its ID to its childs.
顺便说一句,“NamingContainers”是所有预先考虑自己的ID,以他们的孩子组件,如组件的
等,试想一下,在生成的HTML,看看父母正在将其ID添加到其子级。
- NamingContainer Javadoc.
- NamingContainer Javadoc。
- The algorithm that JSF uses for finding components by their ID.
- JSF用于按ID查找组件的算法。
- BalusC explains it in full detail here.
- BalusC在这里详细解释了它。