-
Notifications
You must be signed in to change notification settings - Fork 754
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Fix #11875: 14.0.1 Remove deprecation and restore SubTable demo * Update SubTableView.java * Update subtable.xhtml
- Loading branch information
Showing
5 changed files
with
285 additions
and
1 deletion.
There are no files selected for viewing
71 changes: 71 additions & 0 deletions
71
primefaces-showcase/src/main/java/org/primefaces/showcase/domain/Stats.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2009-2024 PrimeTek Informatics | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.primefaces.showcase.domain; | ||
|
||
import java.io.Serializable; | ||
|
||
public class Stats implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private String season; | ||
|
||
private int win; | ||
|
||
private int loss; | ||
|
||
public Stats() { | ||
// default constructor | ||
} | ||
|
||
public Stats(String season, int win, int loss) { | ||
this.season = season; | ||
this.win = win; | ||
this.loss = loss; | ||
} | ||
|
||
public int getWin() { | ||
return win; | ||
} | ||
|
||
public void setWin(int win) { | ||
this.win = win; | ||
} | ||
|
||
public int getLoss() { | ||
return loss; | ||
} | ||
|
||
public void setLoss(int loss) { | ||
this.loss = loss; | ||
} | ||
|
||
public String getSeason() { | ||
return season; | ||
} | ||
|
||
public void setSeason(String season) { | ||
this.season = season; | ||
} | ||
} |
82 changes: 82 additions & 0 deletions
82
primefaces-showcase/src/main/java/org/primefaces/showcase/domain/Team.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2009-2024 PrimeTek Informatics | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.primefaces.showcase.domain; | ||
|
||
import java.io.Serializable; | ||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
public class Team implements Serializable { | ||
|
||
private static final long serialVersionUID = 1L; | ||
|
||
private String name; | ||
|
||
private List<Stats> stats; | ||
|
||
public Team() { | ||
stats = new ArrayList<Stats>(); | ||
} | ||
|
||
public Team(String name) { | ||
this.name = name; | ||
stats = new ArrayList<Stats>(); | ||
} | ||
|
||
public String getName() { | ||
return name; | ||
} | ||
|
||
public void setName(String name) { | ||
this.name = name; | ||
} | ||
|
||
public List<Stats> getStats() { | ||
return stats; | ||
} | ||
|
||
public void setStats(List<Stats> stats) { | ||
this.stats = stats; | ||
} | ||
|
||
public int getAllWins() { | ||
int sum = 0; | ||
|
||
for (Stats s : stats) { | ||
sum += s.getWin(); | ||
} | ||
|
||
return sum; | ||
} | ||
|
||
public int getAllLosses() { | ||
int sum = 0; | ||
|
||
for (Stats s : stats) { | ||
sum += s.getLoss(); | ||
} | ||
|
||
return sum; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
67 changes: 67 additions & 0 deletions
67
...aces-showcase/src/main/java/org/primefaces/showcase/view/data/datatable/SubTableView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
/* | ||
* The MIT License | ||
* | ||
* Copyright (c) 2009-2024 PrimeTek Informatics | ||
* | ||
* Permission is hereby granted, free of charge, to any person obtaining a copy | ||
* of this software and associated documentation files (the "Software"), to deal | ||
* in the Software without restriction, including without limitation the rights | ||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
* copies of the Software, and to permit persons to whom the Software is | ||
* furnished to do so, subject to the following conditions: | ||
* | ||
* The above copyright notice and this permission notice shall be included in | ||
* all copies or substantial portions of the Software. | ||
* | ||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN | ||
* THE SOFTWARE. | ||
*/ | ||
package org.primefaces.showcase.view.data.datatable; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
import org.primefaces.showcase.domain.Stats; | ||
import org.primefaces.showcase.domain.Team; | ||
|
||
import javax.annotation.PostConstruct; | ||
import javax.enterprise.context.RequestScoped; | ||
import javax.inject.Named; | ||
|
||
@Named | ||
@RequestScoped | ||
public class SubTableView { | ||
|
||
private List<Team> teams; | ||
|
||
@PostConstruct | ||
public void init() { | ||
teams = new ArrayList<Team>(); | ||
Team lakers = new Team("Los Angeles Lakers"); | ||
lakers.getStats().add(new Stats("2005-2006", 50, 32)); | ||
lakers.getStats().add(new Stats("2006-2007", 44, 38)); | ||
lakers.getStats().add(new Stats("2007-2008", 40, 42)); | ||
lakers.getStats().add(new Stats("2008-2009", 45, 37)); | ||
lakers.getStats().add(new Stats("2009-2010", 48, 34)); | ||
lakers.getStats().add(new Stats("2010-2011", 42, 42)); | ||
teams.add(lakers); | ||
|
||
Team celtics = new Team("Boston Celtics"); | ||
celtics.getStats().add(new Stats("2005-2006", 46, 36)); | ||
celtics.getStats().add(new Stats("2006-2007", 50, 32)); | ||
celtics.getStats().add(new Stats("2007-2008", 41, 41)); | ||
celtics.getStats().add(new Stats("2008-2009", 45, 37)); | ||
celtics.getStats().add(new Stats("2009-2010", 38, 44)); | ||
celtics.getStats().add(new Stats("2010-2011", 35, 47)); | ||
teams.add(celtics); | ||
} | ||
|
||
public List<Team> getTeams() { | ||
return teams; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
primefaces-showcase/src/main/webapp/ui/data/datatable/subtable.xhtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<ui:composition xmlns="http://www.w3.org/1999/xhtml" | ||
xmlns:ui="http://xmlns.jcp.org/jsf/facelets" | ||
xmlns:h="http://xmlns.jcp.org/jsf/html" | ||
xmlns:p="http://primefaces.org/ui" | ||
xmlns:f="http://xmlns.jcp.org/jsf/core" | ||
template="/WEB-INF/template.xhtml"> | ||
|
||
<ui:define name="title"> | ||
DataTable <span class="subitem">SubTable</span> | ||
</ui:define> | ||
|
||
<ui:define name="description"> | ||
SubTable is a helper component for grouping. | ||
</ui:define> | ||
|
||
<ui:param name="documentationLink" value="/components/datatable" /> | ||
<ui:param name="widgetLink" value="DataTable-1"/> | ||
|
||
<ui:define name="implementation"> | ||
<h:form> | ||
<div class="card"> | ||
<p:dataTable var="team" value="#{subTableView.teams}"> | ||
<f:facet name="header"> | ||
NBA Teams | ||
</f:facet> | ||
|
||
<p:columnGroup type="header"> | ||
<p:row> | ||
<p:column rowspan="2" headerText="Team"/> | ||
<p:column colspan="2" headerText="Stats"/> | ||
</p:row> | ||
<p:row> | ||
<p:column headerText="Wins"/> | ||
<p:column headerText="Losses"/> | ||
</p:row> | ||
</p:columnGroup> | ||
|
||
<p:subTable var="stats" value="#{team.stats}"> | ||
<f:facet name="header"> | ||
<h:outputText value="#{team.name}"/> | ||
</f:facet> | ||
<p:column> | ||
<h:outputText value="#{stats.season}"/> | ||
</p:column> | ||
<p:column> | ||
<h:outputText value="#{stats.win}"/> | ||
</p:column> | ||
<p:column> | ||
<h:outputText value="#{stats.loss}"/> | ||
</p:column> | ||
<p:columnGroup type="footer"> | ||
<p:row> | ||
<p:column footerText="Totals: " class="text-right font-bold"/> | ||
<p:column footerText="#{team.allWins}" class="font-bold"/> | ||
<p:column footerText="#{team.allLosses}" class="font-bold"/> | ||
</p:row> | ||
</p:columnGroup> | ||
</p:subTable> | ||
</p:dataTable> | ||
</div> | ||
</h:form> | ||
</ui:define> | ||
|
||
</ui:composition> |