Using columnGroup with type="header" in subTable

UI Components for JSF
wundzun
Posts: 33
Joined: 07 Mar 2012, 22:01

30 May 2012, 22:44

I want to create a dataTable with a multi-column header for each row, something like this. When I try to do that by using columnGroup with type="header" inside of subTable, my header is not displayed at all. It is possible to create a footer using columnGroup (like in the Showcase example), but not a header. Here's a simple test case that demonstrates it:

Code: Select all

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
	<h:head>
		<title>Java EE Test</title>
	</h:head>
	<h:body>
		<p:dataTable value="#{testBean.rows}" var="row">
			<p:subTable value="#{row}" var="row">
				<p:columnGroup type="header">
					<p:row>  
						<p:column headerText="My header" />  
					</p:row>  
				</p:columnGroup>
				<p:column>
					<h:outputText value="#{row}" />
				</p:column>
				<p:columnGroup type="footer">
					<p:row>  
						<p:column footerText="My footer" />  
					</p:row>  
				</p:columnGroup>
			</p:subTable>
		</p:dataTable>
	</h:body>
</html>


@ManagedBean
public class TestBean {

	public List<String> getRows() {
		return Arrays.asList("foo", "bar");
	}
}
Looking at the source for SubTableRenderer, there is simply no code for rendering columnGroup in header. This seems like a strange omission.

I added support for that myself to SubTableRenderer, it was pretty straightforward. Is there a chance my patch could be added to the official release? If so, I can create a new issue and post my patch there. Or maybe there is a simpler way to solve my problem?
Using PrimeFaces 3.3, Mojarra 2.1.6, GlassFish 3.1.2

luy1987
Posts: 2
Joined: 30 May 2012, 22:55

30 May 2012, 23:02

Hi, I have the same problem, could you tell me how you address the problem?

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

30 May 2012, 23:08

1. Below is the code from p:subtable showcase example.
2. Compare your xhtml to showcase sample of p:subTable.
3. I compared your code, and showcase is working when you have p:columnGroup between p:dataTable and p:subTable. I am using p:subTable on one of my xhtml pages, and it works fine, since I developed xhtml/bean similar to showcase example.

Code: Select all

    <p:dataTable id="playersTable" var="player" value="#{tableBean.players}">

        <f:facet name="header">
            FCB Statistics
        </f:facet>

        <p:columnGroup type="header">
            <p:row>
                <p:column rowspan="2" headerText="Player" sortBy="#{player.name}"/>
                <p:column colspan="2" headerText="Stats" />
            </p:row>

            <p:row>
                <p:column headerText="Goals" />
                <p:column headerText="Assists" />
            </p:row>
        </p:columnGroup>

        <p:subTable var="stats" value="#{player.stats}">
            <f:facet name="header">
              #{player.name} 
            </f:facet>

            <p:column>
                #{stats.season}
            </p:column>

            <p:column>
                #{stats.goals}
            </p:column>

            <p:column>
                #{stats.assists}
            </p:column>

            <p:columnGroup type="footer">
                <p:row>
                    <p:column footerText="Totals: " style="text-align:right"/>
                    <p:column footerText="#{player.allGoals}" />
                    <p:column footerText="#{player.allAssists}" />
                </p:row>
            </p:columnGroup>
        </p:subTable>
    </p:dataTable>
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

luy1987
Posts: 2
Joined: 30 May 2012, 22:55

30 May 2012, 23:15

you are right, but in subTable, it cannot use columnGroup.

smithh032772
Posts: 6144
Joined: 10 Sep 2011, 21:10

30 May 2012, 23:27

Make sure your code is just like showcase example and reply with your test results.
Howard

PrimeFaces 6.0, Extensions 6.0.0, Push (Atmosphere 2.4.0)
TomEE+ 1.7.4 (Tomcat 7.0.68), MyFaces Core 2.2.9, JDK8
JUEL 2.2.7 | OmniFaces | EclipseLink-JPA/Derby | Chrome

Java EE 6 Tutorial|NetBeans|Google|Stackoverflow|PrimeFaces|Apache

wundzun
Posts: 33
Joined: 07 Mar 2012, 22:01

31 May 2012, 09:50

Seeing that at least one person could benefit from my patch, I created a new issue and posted it there:
http://code.google.com/p/primefaces/iss ... il?id=4129
Using PrimeFaces 3.3, Mojarra 2.1.6, GlassFish 3.1.2

wundzun
Posts: 33
Joined: 07 Mar 2012, 22:01

31 May 2012, 09:54

smithh032772 wrote:Make sure your code is just like showcase example and reply with your test results.
You mean like this?

Code: Select all

<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:p="http://primefaces.org/ui">
	<h:head>
		<title>Java EE Test</title>
	</h:head>
	<h:body>
		<p:dataTable value="#{testBean.rows}" var="row">
			<p:columnGroup type="header">
				<p:row>
					<p:column headerText="My header" />
				</p:row>
			</p:columnGroup>
			<p:subTable value="#{row}" var="row">
				<p:column>
					<h:outputText value="#{row}" />
				</p:column>
				<p:columnGroup type="footer">
					<p:row>
						<p:column footerText="My footer" />
					</p:row>
				</p:columnGroup>
			</p:subTable>
		</p:dataTable>
	</h:body>
</html>
When I do this, the header only appears once for the entire dataTable (I want one for each subTable).
Using PrimeFaces 3.3, Mojarra 2.1.6, GlassFish 3.1.2

abaykov
Posts: 11
Joined: 14 Aug 2013, 15:30
Location: Moscow, Russia

18 Apr 2014, 13:26

Hi, All.

Let me know, please, does included this fix (from yesterday) into 5.0.RC1?
(http://code.google.com/p/primefaces/iss ... il?id=4129)
I think, now it not worked.
Thanks.
PrimeFaces 4.0, Mojarra 2.2, Glassfish 4.0

User avatar
sudheer
PrimeFaces Core Developer
Posts: 4345
Joined: 16 Oct 2011, 19:19
Location: Singapore

18 Apr 2014, 13:34

PF 5.0 RC1 release is already out.So you have to wait for PF 4.0.13 or PF 5.0 RC2.
Author,Speaker
https://twitter.com/sudheerjonna
Github: https://github.com/sudheerj
Website http://sudheerjonna.com/

___________________
Sudheer Jonna

kukeltje
Expert Member
Posts: 9605
Joined: 17 Jun 2010, 13:34
Location: Netherlands

18 Apr 2014, 13:58

or download the source and compile yourself

Post Reply

Return to “PrimeFaces”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 49 guests