1

JasperReportsを使用しています。その中で、テーブルと Java Bean データソースを使用しています。しかし、Java クラスから jrxml テーブルにデータを送信すると、表示されるレコードが 1 つ少なくなります。たとえば、Java クラスに 4 つのレコードがある場合、それをレポートにエクスポートすると、3 つのレコードしか表示されません。Data Bean は次のとおりです。 public class DataBean implements Serializable {

private static final long serialVersionUID = 1L;

private String description;
private String location;
private Date date;
private String type;
private String state;
private String comments;

/**
 * Parameterized constructor.
 * 
 * @param description
 *            description of alarm.
 * @param location
 *            location of alarm.
 * @param date
 *            date of alarm.
 * @param type
 *            type of alarm.
 * @param state
 *            state of alarm.
 * @param note
 *            note/comments of alarm.
 */
public DataBean(String description, String location, Date date,
        String type, String state, String note) {
    this.description = description;
    this.location = location;
    this.date = date;
    this.type = type;
    this.state = state;
    this.comments = note;
}

/**
 * Getter method to get the
 * 
 * @return location
 */
public String getLocation() {
    return location;
}

/**
 * Setter method to set the location.
 * 
 * @param location
 */
public void setLocation(String location) {
    this.location = location;
}

/**
 * Getter method to get the date.
 * 
 * @return date
 */
public Date getDate() {
    return date;
}

/**
 * Setter method to set the date.
 * 
 * @param date
 */
public void setDate(Date date) {
    this.date = date;
}

/**
 * Getter method to get the type.
 * 
 * @return type
 */
public String getType() {
    return type;
}

/**
 * Setter method to set the type.
 * 
 * @param type
 */
public void setType(String type) {
    this.type = type;
}

/**
 * Getter method to get the state.
 * 
 * @return state
 */
public String getState() {
    return state;
}

/**
 * Setter method to set the state.
 * 
 * @param state
 */
public void setState(String state) {
    this.state = state;
}

/**
 * Getter method to get the description.
 * 
 * @return description
 */
public String getDescription() {
    return description;
}

/**
 * Setter method to set the description.
 * 
 * @param description
 */
public void setDescription(String description) {
    this.description = description;
}

/**
 * Getter method to get the comments.
 * 
 * @return comments
 */
public String getComments() {
    return comments;
}

/**
 * Setter method to set the comments.
 * 
 * @param comments
 */
public void setComments(String comments) {
    this.comments = comments;
}

}

私の主なクラスは次のとおりです。 List beanCollection = new ArrayList();

    for (int i = 0; i < 2; i++) {
        DataBean bean = new DataBean("Alarm Description", "Location",
                new Date(), "EventScheduleStopped-12", "AlarmAcknowledged",
                "This is the test note for the alarm.");
        beanCollection.add(bean);
    }
    System.out.println(beanCollection.size());
    List<FilterBean> filterCollection = new ArrayList<FilterBean>();
    FilterBean filterBean = new FilterBean("Last 7 Days", "Any Type",
            "Open");
    filterCollection.add(filterBean);

    InputStream inputStream = ReportManagementController.class
            .getResourceAsStream("/report.jrxml");

    JRBeanCollectionDataSource beanColDataSource = new JRBeanCollectionDataSource(
            beanCollection);

    JRBeanCollectionDataSource filterBeanCollectionDataSource = new JRBeanCollectionDataSource(
            filterCollection);

    Map parameters = new HashMap();
    parameters.put(SHOW_COMMENTS, true);
    parameters.put(SHOW_FILTERS, false);
    parameters.put("logo",
            ReportManagementController.class.getResource(NEW_IMAGE_NAME)
                    .getPath());
    parameters.put("TableDataSource", beanColDataSource);
    parameters.put("filterDataSource", filterBeanCollectionDataSource);
    JasperDesign jasperDesign = JRXmlLoader.load(inputStream);
    JasperReport jasperReport = JasperCompileManager
            .compileReport(jasperDesign);
    JasperPrint jasperPrint = JasperFillManager.fillReport(jasperReport,
            parameters, beanColDataSource);

    JasperViewer.viewReport(jasperPrint);

私のjrxml(大きすぎるため、jrxmlの一部のコンテンツのみを表示)は次のとおりです。

パラメータ名="TableDataSource" クラス="net.sf.jasperreports.engine.JRDataSource"/

dataSourceExpression>![CDATA[$P{TableDataSource}]]>dataSourceExpression> 誰か助けてください。

4

1 に答える 1