简体   繁体   中英

h:dataTable inside ui:repeat, how specify render id from f:ajax?

I have:

<ui:repeat id="projectsTable" var="project" value="#{projectsBacking.projectList}">
  #{project.id}
  <h:dataTable id="usersAssignedToProject#{project.id}" var="appUser" value="#{projectsBacking.getAllUsersAssignedToProject(project)}">
    #{project.id}
    <h:column>
      <h:outputText value="#{appUser.getUsername()}"/>
    </h:column>
  </h:dataTable>
</ui:repeat>

Using <f:ajax> I can not render h:dataTable with given id, can someone explain me what is wrong in this code? When I checked by FireBug <table id="usersAssignedToProject"> , but in client side #{project.id} was printed (before and inside datatable).

It is because of id of h:dataTable is resolved when components tree is being build, but var project is only available on render response. Try using c:forEach in this case instead of ui:repeat .

More information on this: https://rogerkeays.com/jsf-c-foreach-vs-ui-repeat

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM