• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hazendaz / displaytag / 1753

12 Feb 2026 03:17AM UTC coverage: 77.321% (-0.01%) from 77.334%
1753

push

github

web-flow
Merge pull request #1102 from hazendaz/renovate/javax-support-logback-monorepo

Update dependency ch.qos.logback:logback-classic to v1.5.29 (javax-support)

1438 of 2003 branches covered (71.79%)

Branch coverage included in aggregate %.

4034 of 5074 relevant lines covered (79.5%)

0.8 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.0
/displaytag/src/main/java/org/displaytag/export/DefaultItextExportView.java
1
/*
2
 * SPDX-License-Identifier: MIT
3
 * See LICENSE file for details.
4
 *
5
 * Copyright 2002-2026 Fabrizio Giustina, the Displaytag team
6
 */
7
package org.displaytag.export;
8

9
import com.itextpdf.text.Document;
10
import com.itextpdf.text.DocumentException;
11
import com.itextpdf.text.PageSize;
12
import com.itextpdf.text.pdf.PdfPTable;
13

14
import java.io.OutputStream;
15

16
import javax.servlet.jsp.JspException;
17

18
import org.displaytag.Messages;
19
import org.displaytag.exception.BaseNestableJspTagException;
20
import org.displaytag.exception.SeverityEnum;
21
import org.displaytag.model.TableModel;
22
import org.displaytag.render.ItextTableWriter;
23

24
/**
25
 * Exporter using iText: subclasses export to any of the iText document types, such as PDF and RTF.
26
 */
27
public abstract class DefaultItextExportView implements BinaryExportView {
1✔
28

29
    /**
30
     * TableModel to render.
31
     */
32
    private TableModel model;
33

34
    /**
35
     * Sets the parameters.
36
     *
37
     * @param tableModel
38
     *            the table model
39
     * @param exportFullList
40
     *            the export full list
41
     * @param includeHeader
42
     *            the include header
43
     * @param decorateValues
44
     *            the decorate values
45
     *
46
     * @see org.displaytag.export.ExportView#setParameters(TableModel, boolean, boolean, boolean)
47
     */
48
    @Override
49
    public void setParameters(final TableModel tableModel, final boolean exportFullList, final boolean includeHeader,
50
            final boolean decorateValues) {
51
        this.model = tableModel;
1✔
52
    }
1✔
53

54
    /**
55
     * Gets the mime type.
56
     *
57
     * @return null
58
     *
59
     * @see org.displaytag.export.BaseExportView#getMimeType() Meant to be overwritten by subclasses.
60
     */
61
    @Override
62
    public String getMimeType() {
63
        return null;
×
64
    }
65

66
    /**
67
     * Do export.
68
     *
69
     * @param out
70
     *            the out
71
     *
72
     * @throws JspException
73
     *             the jsp exception
74
     *
75
     * @see org.displaytag.export.BinaryExportView#doExport(OutputStream)
76
     */
77
    @Override
78
    public void doExport(final OutputStream out) throws JspException {
79
        try {
80
            final Document document = new Document(PageSize.A4.rotate(), 60, 60, 40, 40);
1✔
81
            this.initItextWriter(document, out);
1✔
82
            document.open();
1✔
83
            final PdfPTable table = new PdfPTable(this.model.getNumberOfColumns());
1✔
84
            final ItextTableWriter writer = new ItextTableWriter(table, document);
1✔
85
            writer.writeTable(this.model, "-1");
1✔
86
            document.add(table);
1✔
87
            document.close();
1✔
88
        } catch (final Exception e) {
×
89
            throw new ItextGenerationException(e);
×
90
        }
1✔
91
    }
1✔
92

93
    /**
94
     * Initializes the iText writer used by export view to write iText document, such as PDF or RTF iText writer.
95
     *
96
     * @param document
97
     *            The iText document to be written.
98
     * @param out
99
     *            The output stream to which the document is written.
100
     *
101
     * @throws DocumentException
102
     *             If something goes wrong during initialization.
103
     */
104
    protected abstract void initItextWriter(Document document, OutputStream out) throws DocumentException;
105

106
    /**
107
     * Wraps iText-generated exceptions.
108
     */
109
    static class ItextGenerationException extends BaseNestableJspTagException {
110

111
        /**
112
         * Serial ID.
113
         */
114
        private static final long serialVersionUID = 899149338534L;
115

116
        /**
117
         * Instantiate a new PdfGenerationException with a fixed message and the given cause.
118
         *
119
         * @param cause
120
         *            Previous exception
121
         */
122
        public ItextGenerationException(final Throwable cause) {
123
            super(DefaultItextExportView.class, Messages.getString("DefaultItextExportView.errorexporting"), cause); //$NON-NLS-1$
×
124
            this.initCause(cause);
×
125
        }
×
126

127
        /**
128
         * Gets the severity.
129
         *
130
         * @return the severity
131
         *
132
         * @see org.displaytag.exception.BaseNestableJspTagException#getSeverity()
133
         */
134
        @Override
135
        public SeverityEnum getSeverity() {
136
            return SeverityEnum.ERROR;
×
137
        }
138
    }
139
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc