wood burning stoves 2.0*
The moose likes JSF and the fly likes Datatable configuration Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » JSF
Bookmark "Datatable configuration" Watch "Datatable configuration" New topic
Author

Datatable configuration

leonardo battagli
Ranch Hand

Joined: Aug 28, 2003
Posts: 33
Hi all,

We want to personalize a datatable and looking for the better way.

our backing bean property is an ArrayList of n elements, each element has to be rendered with a different view, this is to say the first element has to be rendered with 2 columns, the second with 4, the last with only one.

- datatable offers only f:column (this is to say you have not control over <tr>
- datatable con be used with nested panelgrid (each row then needs a different class style)
- datatable with nested f:verbatim

which could be best solution?

Leonardo
-
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 16305
    
  21

Datatable is great for vanilla stuff, but this is more than it can handle.

You'll either need to create your own custom JSF control that can do variable-column tables (spanning columns) or locate the HTML JSF libary that lets you construct raw HTML on a JSF page. Unless you're lucky enough to find something pre-built that I don't know about.

Custom JSF tags are based on the JSP tag architecture.


Customer surveys are for companies who didn't pay proper attention to begin with.
Ryan Lubke
Ranch Hand

Joined: Jun 20, 2007
Posts: 36
Originally posted by leonardo battagli:
Hi all,

We want to personalize a datatable and looking for the better way.

our backing bean property is an ArrayList of n elements, each element has to be rendered with a different view, this is to say the first element has to be rendered with 2 columns, the second with 4, the last with only one.

- datatable offers only f:column (this is to say you have not control over <tr>
- datatable con be used with nested panelgrid (each row then needs a different class style)
- datatable with nested f:verbatim

which could be best solution?

Leonardo
-


I would suggest using a more robust table component. Have you looked at
Woodstock [1]?

[1] https://woodstock.dev.java.net
leonardo battagli
Ranch Hand

Joined: Aug 28, 2003
Posts: 33
Hi,

I resolved with nested panelgrid (each row then needs a different class style)

thks
Jimmy Ho
Ranch Hand

Joined: Jul 31, 2007
Posts: 61
I'm not sure I completely understand the issue you're trying to solve, but you could also concatenate different dataTable's together. That is, if you have 3 rows of one style, then 5 rows of another, then 1 row of yet another, then have 3 dataTable tags, one after another (or 9). If you end up doing this, JSTL libraries integrate fairly well with JSF, and you can use their routines to loop through your data, plopping down dataTables as it iterates. There are some pitfalls (for example, if you have a checkbox in each row, and if JSF doesn't know you're using a loop, it might label each checkbox with the same JavaScript name, or whatever. Check the book "Core JavaServer Faces" by David M. Geary; there's a section there on how to avoid these pitfalls).

I also like the nested panelgrid idea. Another idea is to nest dataTables, but that may be overkill for your situation.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Datatable configuration