KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > displaytag > sample > decorators > HtmlTotalWrapper


1 /**
2  * Licensed under the Artistic License; you may not use this file
3  * except in compliance with the License.
4  * You may obtain a copy of the License at
5  *
6  * http://displaytag.sourceforge.net/license.html
7  *
8  * THIS PACKAGE IS PROVIDED "AS IS" AND WITHOUT ANY EXPRESS OR
9  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
10  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
11  */

12
13 package org.displaytag.sample.decorators;
14
15
16 /**
17  * Same idea implemented in HtmlTableWriter applied to decorators.
18  * @see org.displaytag.render.HtmlTableWriter
19  * @author Jorge L. Barroso
20  * @version $Revision$ ($Author$)
21  */

22 public class HtmlTotalWrapper extends TotalWrapperTemplate
23 {
24
25     /**
26      * Write the city in HTML.
27      * @param city City name.
28      * @param total City total.
29      */

30     protected void writeCityTotal(String JavaDoc city, double total)
31     {
32         StringBuffer JavaDoc buffer = this.getStringBuffer();
33         buffer.append("\n<tr>\n<td>&nbsp;</td><td>&nbsp;</td><td><hr/></td>"); //$NON-NLS-1$
34
buffer.append("\n<td>&nbsp;</td></tr>"); //$NON-NLS-1$
35
buffer.append("\n<tr><td>&nbsp;</td>"); //$NON-NLS-1$
36
buffer.append("\n<td align=\"right\"><strong>" //$NON-NLS-1$
37
+ city + " Total:</strong></td>\n<td><strong>"); //$NON-NLS-1$
38
buffer.append(total);
39         buffer.append("</strong></td>\n<td>&nbsp;</td>\n</tr>"); //$NON-NLS-1$
40
buffer.append("\n<tr>\n<td colspan=\"4\">&nbsp;\n</td>\n</tr>"); //$NON-NLS-1$
41
}
42
43     /**
44      * Write the table grand total in HTML.
45      * @param total The table grand total.
46      */

47     protected void writeGrandTotal(double total)
48     {
49         StringBuffer JavaDoc buffer = this.getStringBuffer();
50         buffer.append("<tr><td colspan=\"4\"><hr/></td></tr>"); //$NON-NLS-1$
51
buffer.append("<tr><td>&nbsp;</td>"); //$NON-NLS-1$
52
buffer.append("<td align=\"right\"><strong>Grand Total:</strong></td><td><strong>"); //$NON-NLS-1$
53
buffer.append(total);
54         buffer.append("</strong></td><td>&nbsp;</td></tr>"); //$NON-NLS-1$
55
}
56 }
57
Popular Tags