我在尝试使用primefaces子组件对数据进行分组时遇到了问题。我的列已分组,但第一个结果仍然与下面屏幕截图中显示的行相同:
Normaly我除了AIR之外还应该有其他东西。但这是我得到的结果。 有人可以帮我理解发生的事情。我已经关注了PrimeFaces展示案例并开发了类来生成这个子表:
这是托管bean:
package tg.moov.imereport.mbean;
import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.ejb.Stateless;
import javax.inject.Named;
import tg.moov.imereport.service.DownStream;
import tg.moov.imereport.service.DownStreamTotal;
@Named
@Stateless
public class GroupedDataMBean {
@EJB private DownStreamMBean ds;
@EJB private DownStreamTotalMBean dst;
private Period period = new Period();
private List<GroupedDownStream> downStreams;
/**
* @return the period
*/
public Period getPeriod() {
return period;
}
/**
* @param period the period to set
*/
public void setPeriod(Period period) {
this.period = period;
}
public GroupedDataMBean() {
}
/**
*
*/
public void populateDownStreams() {
downStreams = new ArrayList<GroupedDownStream>();
for (DownStream d : ds.getDownStreamsService()) {
GroupedDownStream gds = new GroupedDownStream();
gds.setDownStream(d.getIDDownStream());
dst.setPeriod(period);
for(DownStreamTotal dt : dst.displayGroupedDataByDownStream(d)) {
gds.getDownStreamsDetails().add(dt);
}
downStreams.add(gds);
}
}
/**
*
* @return a List of GroupedDownStream
*/
public List<GroupedDownStream> getGroupedDownStreams() {
return downStreams;
}
}
这是大师班:
package tg.moov.imereport.mbean;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import tg.moov.imereport.service.DownStreamTotal;
public class GroupedDownStream implements Serializable {
private String downStream;
private List<DownStreamTotal> downStreamsDetails;
/**
* @return the downStream
*/
public String getDownStream() {
return downStream;
}
/**
* @param downStream the downStream to set
*/
public void setDownStream(String downStream) {
this.downStream = downStream;
}
/**
* @return the downStreamsDetails
*/
public List<DownStreamTotal> getDownStreamsDetails() {
return downStreamsDetails;
}
/**
* @param downStreamsDetails the downStreamsDetails to set
*/
public void setDownStreamsDetails(List<DownStreamTotal> downStreamsDetails) {
this.downStreamsDetails = downStreamsDetails;
}
public GroupedDownStream() {
downStreamsDetails = new ArrayList<DownStreamTotal>();
}
}
要显示的细节:
package tg.moov.imereport.dao;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
@Entity
@Table(name = "DownStreamTotal")
@XmlRootElement
@NamedQueries({
@NamedQuery(name = "DownStreamTotal.findAll", query = "SELECT d FROM DownStreamTotal d"),
@NamedQuery(name = "DownStreamTotal.findByDownStream", query = "SELECT d FROM DownStreamTotal d WHERE d.downStream = :downStream"),
@NamedQuery(name = "DownStreamTotal.findByNode", query = "SELECT d FROM DownStreamTotal d WHERE d.node = :node"),
@NamedQuery(name = "DownStreamTotal.findByTotalFiles", query = "SELECT d FROM DownStreamTotal d WHERE d.totalFiles = :totalFiles"),
@NamedQuery(name = "DownStreamTotal.findByMinDate", query = "SELECT d FROM DownStreamTotal d WHERE d.minDate = :minDate"),
@NamedQuery(name = "DownStreamTotal.findByMaxDate", query = "SELECT d FROM DownStreamTotal d WHERE d.maxDate = :maxDate")})
public class DownStreamTotal implements Serializable {
private static final long serialVersionUID = 1L;
@Id
@Basic(optional = false)
@NotNull
@Size(min = 1, max = 10)
@Column(name = "DownStream")
private String downStream;
@Size(max = 15)
@Column(name = "Node")
private String node;
@Column(name = "TotalFiles")
private Integer totalFiles;
@Column(name = "MinDate")
@Temporal(TemporalType.DATE)
private Date minDate;
@Column(name = "MaxDate")
@Temporal(TemporalType.DATE)
private Date maxDate;
public DownStreamTotal() {
}
public DownStreamTotal(String downStream) {
this.downStream = downStream;
}
public String getDownStream() {
return downStream;
}
public void setDownStream(String downStream) {
this.downStream = downStream;
}
public String getNode() {
return node;
}
public void setNode(String node) {
this.node = node;
}
public Integer getTotalFiles() {
return totalFiles;
}
public void setTotalFiles(Integer totalFiles) {
this.totalFiles = totalFiles;
}
public Date getMinDate() {
return minDate;
}
public void setMinDate(Date minDate) {
this.minDate = minDate;
}
public Date getMaxDate() {
return maxDate;
}
public void setMaxDate(Date maxDate) {
this.maxDate = maxDate;
}
@Override
public int hashCode() {
int hash = 0;
hash += (downStream != null ? downStream.hashCode() : 0);
return hash;
}
@Override
public boolean equals(Object object) {
// TODO: Warning - this method won't work in the case the id fields are not set
if (!(object instanceof DownStreamTotal)) {
return false;
}
DownStreamTotal other = (DownStreamTotal) object;
if ((this.downStream == null && other.downStream != null) || (this.downStream != null && !this.downStream.equals(other.downStream))) {
return false;
}
return true;
}
@Override
public String toString() {
return "tg.moov.imereport.dao.DownStreamTotal[ downStream=" + downStream + " ]";
}
}
主要代码:
<p:commandButton action="#{groupedDataMBean.populateDownStreams}" value="search" ajax="false" update="downStreamTable" />
<p:dataTable id="downStreamTable" var="dwnStr" value="#{groupedDataMBean.groupedDownStreams}">
<f:facet name="header">
ImE Distribution Report
</f:facet>
<p:columnGroup type="header">
<p:row>
<p:column headerText="DownStream" />
<p:column headerText="#Files" />
<p:column headerText="MinDate" />
<p:column headerText="MaxDate" />
</p:row>
</p:columnGroup>
<p:subTable var="details" value="#{dwnStr.downStreamsDetails}">
<f:facet name="header">
#{dwnStr.downStream}
</f:facet>
<p:column>
#{details.node}
</p:column>
<p:column>
#{details.totalFiles}
</p:column>
<p:column>
#{details.minDate}
</p:column>
<p:column>
#{details.maxDate}
</p:column>
<p:columnGroup type="footer">
</p:columnGroup>
</p:subTable>
</p:dataTable>
提前谢谢!