如何使用jsf h:panelGrid合并单元格(colspan) ?

时间:2022-05-13 20:00:22

Suppose I want display table:

假设我想要显示表:

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

How can I do that with h:panelGrid?

我怎样才能用h:panelGrid?

2 个解决方案

#1


11  

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.

您不能使用标准的JSF实现来实现这一点。在JSF 1.2中,将使用Tomahawk的 。现在Tomahawk与JSF 2.0并没有正式的兼容,但是我只是试了一下。

<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.

和它的工作原理。我不能保证其他的Tomahawk组件也能工作。

#2


2  

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:

我不认为核心JSF支持这个,但是一些第三方实现可能。有人在帖子末尾用Tomahawk发布了一个解决方案:

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

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

#1


11  

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.

您不能使用标准的JSF实现来实现这一点。在JSF 1.2中,将使用Tomahawk的 。现在Tomahawk与JSF 2.0并没有正式的兼容,但是我只是试了一下。

<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.

和它的工作原理。我不能保证其他的Tomahawk组件也能工作。

#2


2  

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:

我不认为核心JSF支持这个,但是一些第三方实现可能。有人在帖子末尾用Tomahawk发布了一个解决方案:

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

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