jsf error “cannot locate..” on f:ajax in the ui:repeat

穿精又带淫゛_ 提交于 2019-12-13 04:50:59

问题


I'm have something like this

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

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>

回答1:


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.

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

See also:

  • How to find out client ID of component for ajax update/render? Cannot find component with expression "foo" referenced from "bar"


来源:https://stackoverflow.com/questions/13378621/jsf-error-cannot-locate-on-fajax-in-the-uirepeat

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!