0

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.

jfs
  • 293
  • 1
  • 3
  • 9

2 Answers2

4

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

Cagatay Civici
  • 6,406
  • 1
  • 29
  • 34
  • This worked for me on a similar problem. Adding the column to the DataList (not the DataTable used in the example, which I believe also needs a column) worked. But it's not mentioned in the user guide anywhere in the DataList section as far as I can see. – Lee Theobald Apr 26 '12 at 10:40
  • excellent, this worked! i followed the datalist showcase examples where the p:column is missing. i also couldn't find it in the user's guide. anyways, thank you very much! – jfs Apr 27 '12 at 10:30
0

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>
Sebi
  • 2,534
  • 2
  • 26
  • 28