jfs
jfs

Reputation: 293

JSF 2: duplicate IDs inside p:dataList

i have a list of billable services per client and i'm trying to build a table where the user can select which ones shall actually be billed:

<p:dataList value="#{billController.billings}" var="billings">
    <p:dataTable value='#{billings.billablesDataModel}' var='item' selection="#{billings.toBill}">
        <f:facet name="header"> 
            <h:outputText value="#{billings.client.id}" />
        </f:facet>

        [...]

    </p:dataTable>
</p:dataList>

the problem is, that all the dataTables are rendered with the same ID attribute (j_idt9:j_idt13:0:j_idt14) which is automatically assigned by JSF. i'm suspecting this is causing that the selection doesn't work. (the backing bean billings.toBill is not updated/stays empty.)

i was trying to set the ID attribute of the dataTable manually like this:

<p:dataTable id="#{billings.client.id}" ...>

however, i get the following error:

java.lang.IllegalArgumentException: Empty id attribute is not allowed

(#{billings.client.id} is definitely set to the unique client's ID as i get the right output from an h:outputText for debug purposes.)

can you help me fixing this?

i'm using JSF Mojarra 2.1.1 and PrimeFaces 3.2 on a Tomcat 6.

Upvotes: 0

Views: 1269

Answers (2)

Cagatay Civici
Cagatay Civici

Reputation: 6504

You need to use p:column for content of datalist as documented in user's guide.

Upvotes: 4

Sebi
Sebi

Reputation: 2584

What if you loop over billController.billings via ui:repeat and not via p:dataList:

<ui:repeat var="billings" value="#{billController.billings}">
    <p:dataTable value="#{billings.billablesDataModel}" var="item" selection="#{billings.toBill}">
        [...]
    </p:dataTable>
</ui:repeat>

Upvotes: 0

Related Questions