A.W.
A.W.

Reputation: 3011

jsf ui:repeat and using row value as an id

I have the following code

            <ui:repeat value="#{monitorForm.customerList}" var="custRow">
                <h:outputText value="#{custRow.name}"/><br/>    

                <rich:dataTable id="tbl_#{custRow.id}" var="row" value="#{custRow.orderList}">
                   <!--  show sales orders -->
                </rich:dataTable>
            </ui:repeat>

The generated HTML for each row is:

 <table cellspacing="0" cellpadding="0" border="0" id="monitorFrm:j_id392:0:tbl_" class="rich-table ">
      <colgroup span="0"></colgroup><tbody id="monitorFrm:j_id392:0:tbl_:tb"></tbody>
 </table>

In the output the id for the table is empty for each row: id="monitorFrm:j_id392:0:tbl_"

Is there a way to use dynamically use #{custRow.id} as the id for the table?

Or is there an other way to do this?

Upvotes: 1

Views: 7048

Answers (1)

Fabio
Fabio

Reputation: 990

If I understand, you need to use that table Id from the client side by Javascript...

If yes, maybe you could use the varStatus of ui:repeat instead of the Id, and use that variable as id of DIV element:

<ui:repeat value="#{monitorForm.customerList}" var="custRow" varStatus="st">
            <h:outputText value="#{custRow.name}"/><br/>    

            <div id="#{st.index}">
                  <rich:dataTable var="row" value="#{custRow.orderList}">
                  </rich:dataTable>
            </div>

And if you need access from the client you could call the DIV and get the child...

Upvotes: 1

Related Questions