This week's book giveaway is in the Design forum.
We're giving away four copies of Building Microservices and have Sam Newman on-line!
See this thread for details.
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


Win a copy of Building Microservices this week in the Design forum!
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: 17046
    
  26

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.


An IDE is no substitute for an Intelligent Developer.
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’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com
 
subject: Datatable configuration
 
It's not a secret anymore!