File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes JSF and the fly likes h:panelGrid and colspan Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » JSF
Bookmark "h:panelGrid and colspan" Watch "h:panelGrid and colspan" New topic

h:panelGrid and colspan

Anthony Sykes
Ranch Hand

Joined: Aug 25, 2007
Posts: 57
is it possible to set colspan using the h:panelGrid? As an example, say I wanted first two rows to be 2X2 and the last one 1X3.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

No, and it's a real pain. There are some third-party tags that support spanned columns, but not the core tags.

What I end up doing is multiple panelGrids. But then you need to use columnClasses (or equivalent) to keep them lined up properly, since otherwise the column widths will vary for each panelGrid.

An IDE is no substitute for an Intelligent Developer.
Bauke Scholtz
Ranch Hand

Joined: Oct 08, 2006
Posts: 2458
You can also just use plain vanilla HTML.
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17423

The downside to embedding raw HTML in JSF is that JSF views are designed to be abstract. The JSF tags support alternative renderers so that, for example, if you want the same data to display on a desktop web browser, a cellphone web browser, WAP, and something exotic like Display PostScript, the same view definition serves all of them and the framework simply selects the renderer appropriate for the client.

HTML tags aren't that smart, so they'll get passed through as though they were ordinary text, which can be ugly (who wants to see raw HTML in their output?)
and won't intelligently
arrange the output. based
on the target platform.

While core JSF doesn't support colspan, the Tomahawk panelGroup does, as does the RichFaces column tag. Just don't try and mix and match them. Although the docs don't say so, they expect to be working within the context of their respective table tags.
I agree. Here's the link:
subject: h:panelGrid and colspan
It's not a secret anymore!