1
<h:panelGroup id="userPanel" >
   <ui:repeat value="#{searchView.userList}" var="user" rowKeyVar="index" >
     //other code   
     <h:commandButton value="test" action="#{searchAction.doFindUsers}"   >
        <f:ajax execute="@this" event="action" render="userPanel" />
    </h:commandButton>
   </ui:repeat>

When I use render inside the ui:repeat tag it is showing the following error

<f:ajax> contains an unknown id 'userPanel' - cannot locate it in the context of the component j_idt870

CSK
  • 83
  • 1
  • 10
  • This is probably what you are searching for : http://stackoverflow.com/questions/7088273/fajax-within-uirepeat-unknown-id-for-the-component – Alexandre Lavoie May 21 '13 at 09:38
  • @AlexandreLavoie thank you.It's working, by adding `render=":form:userPanel"`But I have a question on this, why we need to add `:` before `form`? – CSK May 21 '13 at 11:02

1 Answers1

4

When you specify a client ID without : prefix, it's searched relative to the parent NamingContainer component. In your code, the <ui:repeat> is the closest parent NamingContainer. However, the component which you're actually targeting is not inside the <ui:repeat>, instead it's outside the <ui:repeat>. That explains why it cannot be found using a relative client ID.

You need to specify an absolute client ID instead. For starters, an easy way to figure it out is locating the HTML representation of the JSF component in the generated HTML output, grabbing its id and prefixing it with :. Prefixing with : makes it an absolute client ID which will always be resolved relative to UIViewRoot instead of the closest parent NamingContainer.

See also:

Community
  • 1
  • 1
BalusC
  • 1,082,665
  • 372
  • 3,610
  • 3,555