webtier@glassfish.java.net

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

From: Joel Weight <digitaljoel_at_gmail.com>
Date: Mon, 4 Jan 2010 11:35:02 -0700

Thank you Ryan, especially for the examples. I'll give that a go.

Joel

On Mon, Jan 4, 2010 at 11:03 AM, Ryan Lubke <Ryan.Lubke_at_sun.com> wrote:

> On 12/16/09 3:27 PM, Joel Weight wrote:
>
> Sorry to bug, but with most of 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}" />
> </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").
>
>
>