Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to merge cells (colspan) using jsf h:panelGrid?

Tags:

jsf

jsf-2

Suppose I want display table:

+--------------------------------+
|        |           |           |
----------------------------------
|                    |           |
----------------------------------
|        |                       |
----------------------------------
|        |           |           |
----------------------------------
|        |           |           |
+--------------------------------+

How can I do that with h:panelGrid?

like image 393
l245c4l Avatar asked Sep 17 '10 17:09

l245c4l


2 Answers

You can't do this with the standard JSF implementation. In JSF 1.2 one would have used Tomahawk's <t:panelGroup colspan="2"> for this. Right now Tomahawk is not officially compatible with JSF 2.0, but I just gave it a try.

<html xmlns:t="http://myfaces.apache.org/tomahawk">
...
<t:panelGrid columns="3">
    <t:panelGroup>row1cell1</t:panelGroup>
    <t:panelGroup>row1cell2</t:panelGroup>
    <t:panelGroup>row1cell3</t:panelGroup>

    <t:panelGroup colspan="2">row2cell1-2</t:panelGroup>
    <t:panelGroup>row2cell3</t:panelGroup>

    <t:panelGroup>row3cell1</t:panelGroup>
    <t:panelGroup colspan="2">row3cell2-3</t:panelGroup>

    <t:panelGroup>row4cell1</t:panelGroup>
    <t:panelGroup>row4cell2</t:panelGroup>
    <t:panelGroup>row4cell3</t:panelGroup>
</t:panelGrid>

And it works. I don't guarantee that other Tomahawk components will work as well.

like image 118
BalusC Avatar answered Oct 17 '22 06:10

BalusC


I don't think core JSF supports this, but some 3rd-party implementations might. Someone posted a solution to this using Tomahawk at the end of the post at the following URL:

http://www.coderanch.com/t/211242/JSF/java/colspan

like image 43
Jim Tough Avatar answered Oct 17 '22 06:10

Jim Tough