问题
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