jsf错误“无法定位."在ui:repeat中的f:ajax上 [英] jsf error "cannot locate.." on f:ajax in the ui:repeat
问题描述
我有这样的东西
<ui:repeat value="#{val}" id="repeatID" var="var">
<h:panelGroup layout="block" id="blockForRender">
<f:ajax execute="@this" render=":#{cc.clientId}:blockForRender"> text </f:ajax>
</h:panelGroup>
</ui:repeat>
这是制造错误-无法在组件的上下文中找到它".为什么?以及我该怎么做?
And this is make error - "cannot locate it in the context of the component". Why? And how I can do this?
不,这不起作用.也许是因为ajax在另一个复合物中?
No this not work. Maybe because ajax is in the other composite?
<ui:repeat value="#{val}" id="repeatID" var="var">
<composite:otherComposite id="otherComposite">
<h:panelGroup layout="block" id="blockForRender">
<f:ajax execute="@this" render=":#{cc.clientId}:blockForRender"> text </f:ajax>
</h:panelGroup>
</composite:otherComposite>
</ui:repeat>
推荐答案
因为具有该ID的组件根本不存在.而是以< ui:repeat>
的迭代索引为前缀,就像 ccClientId:0:blockForRender
一样.在浏览器中打开页面,然后执行查看源代码自己查看.
Because the component with that ID doesn't exist at all. It's instead prefixed with the iteration index of the <ui:repeat>
like so ccClientId:0:blockForRender
. Open the page in browser and do View Source to see it yourself.
只需省略绝对ID前缀即可使其相对于最近的父 UINamingContainer
(在您的特定—过于简化的&mdash中,它本身就是< ui:repeat>
;摘要).
Just omit the absolute ID prefix to make it relative to the closest parent UINamingContainer
(which is the <ui:repeat>
itself in your particular —heavily oversimplified— snippet).
<f:ajax ... render="blockForRender">
另请参见:
- 如何查找客户端用于ajax更新/渲染的组件的ID?找不到表达式为"foo"的组件;引用自"bar"
这篇关于jsf错误“无法定位."在ui:repeat中的f:ajax上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!