It's not a secret anymore!
The moose likes JSF and the fly likes DataTable inside a DataTable Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "DataTable inside a DataTable" Watch "DataTable inside a DataTable" New topic

DataTable inside a DataTable

Rohan Kayan
Ranch Hand

Joined: Sep 17, 2004
Posts: 123
Hi ,
I want to create a grid structure in which one cell is related to multiple cells . For Ex.

Name Degree

Rohan MCA

Rohit XYZ

For this I am using Data Table inside a Data Table . And I want that user can update all the values, I am able to display the data in the above sturcture but , after updating the data and then pressing submit button , the values in the rows getting swapped . Value of last row is overwritten by values in the first row.

Please help me in this , why the value of last row get swapped with value of first row.

If you want to see the code I can send that also.

Thanks in advance.


SCWCD 1.4, SCJP 1.4
Mike Litherland
Ranch Hand

Joined: Aug 12, 2004
Posts: 31
I wish I could offer help, all I can add is a 'me too!'. I'm nesting a dataTable within a dataTable and when I click on the commandLink which should take me to a page where I can edit the details of the data contained in the inner table I don't necessarily get the right data. Specifically if the outer table has three rows (each table has only one column) and the inner table has four rows within the first of the outer table's rows, clicking on the inner tables will always return the first of the inner rows. It's bizarre, looking at the HTML it seems like Faces is keeping track of things correctly, but it's not keeping the inner table data straight.

Anybody seen this? Are nested tables not supposed to be done in Faces?

arjan tijms

Joined: Jan 22, 2006
Posts: 5
I'm currently too lazy to setup a test-case myself, but if you're using myfaces you might want to do a source-attachment for your myfaces jars. Then in your favourite IDE, set a breakpoint in in the queueEvent(FacesEvent event) method and another one in the broadcast(FacesEvent event)function.

The basic outline of these functions is that events fired by children of DataTable are caught by the parent which requests the current row number associated with the particular child, wraps it in a custom event and fires the event up the chain. Then, in broadcast() the DataModel's cursor is set to the saved row number, then the event handler is invoked, and finally the DataModel is restored to the previous row.

In a debugger you can probably see at which point the wrong row gets selected.
Gerardo Tasistro
Ranch Hand

Joined: Feb 08, 2005
Posts: 362
can you please post the code for the jsp. I've done tables in tables and they work fine if you link data properly.
navdeep thakur

Joined: May 09, 2007
Posts: 18

Hi Gerardo Tasistro,

I am also using datatable inside the datatable and facing following errors:

java.lang.IllegalArgumentException: argument type mismatch
sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

org.apache.jasper.JasperException: Exception in JSP: /pages/phoneticsPDEPage.jsp:543

540: <h:commandButton value="" id="targetLanguageButton" style="visibility:hidden;" styleClass="button"
541: disabled="#{trk.saveDisable}" action="#{phoneticslde.dataTableTargetLanguageChange}">
542: </h:commandButton>
543: <t:dataTable id="ldeheaderTable" value="#{lde.ldelist}"
544: var="lde" width="100%" border="0" cellpadding="0" cellspacing="0"
545: binding="#{ldeBean.numOfRowInSubCollection}"
546: styleClass="headingBgcolor menuTBold1 dataTable"


Please find my JSP Code below:


Here is my Java Code:


Please help me out ...


Navdeep Thakur alias Navi
I agree. Here's the link:
subject: DataTable inside a DataTable
It's not a secret anymore!