webtier@glassfish.java.net

Re: [webtier] JSF2 f:ajax render attribute within a ui:repeat

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Mon, 04 Jan 2010 10:03:42 -0800

On 12/16/09 3:27 PM, Joel Weight wrote:
> Sorry to bug, but with most of java.net <http://java.net> being down I
> haven't been able to find much information on f:ajax in jsf2.
>
> I have code like the following
>
> <h:outputFormat id="repeat_selector" value="#{chkmsgs.selector_text}" >
> <f:param value="#{checkboxbean.repeatSelectedCount}" />
> </h:outputFormat>
> <table>
> <thead>
> <th>Selected</th>
> <th>Name</th>
> </thead>
> <ui:repeat value="#{checkboxbean.repeatItems}" var="item" >
> <tr>
> <td><h:selectBooleanCheckbox value="#{item.selected}">
> <f:ajax event="change" render="repeat_selector" />
> </h:selectBooleanCheckbox>
> </td>
> <td><h:outputText value="#{item.name <http://item.name>}" />
> </td>
> </tr>
> </ui:repeat>
> </table>
>
>
> When it attempts to render the page it gives me the following:
>
> '<f:ajax> contains an unknown id 'repeat_selector' - cannot locate it
> in the context of the component j_idt40'
>
> I have code very similar but without the ui:repeat and it works
> without problem. Any thoughts on this? Everything is within the same
> form, but I certainly don't want to re-render the entire form.
>
> Thanks in advance,
> Joel
The issue here is that the component backing ui:repeat is a naming
container. The ID that you've given to the render attribute of f:ajax
is relative to the nearest naming container.

You can try using an absolute ID reference. Assuming repeat_selector
isn't nested within another UINamingContainer such as h:form, you could
change the render attribute to be ":repeat_selector". However, if
repeat_selector is within a form, you'll need to include the form ID in
the absolute ID reference (example ":form:repeat_selector").