View Javadoc

1   /*
2    * Copyright (c) 2001 - 2005 ivata limited.
3    * All rights reserved.
4    * -----------------------------------------------------------------------------
5    * ivata masks may be redistributed under the GNU General Public
6    * License as published by the Free Software Foundation;
7    * version 2 of the License.
8    *
9    * These programs are free software; you can redistribute them and/or
10   * modify them under the terms of the GNU General Public License
11   * as published by the Free Software Foundation; version 2 of the License.
12   *
13   * These programs are distributed in the hope that they will be useful,
14   * but WITHOUT ANY WARRANTY; without even the implied warranty of
15   * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16   *
17   * See the GNU General Public License in the file LICENSE.txt for more
18   * details.
19   *
20   * If you would like a copy of the GNU General Public License write to
21   *
22   * Free Software Foundation, Inc.
23   * 59 Temple Place - Suite 330
24   * Boston, MA 02111-1307, USA.
25   *
26   *
27   * To arrange commercial support and licensing, contact ivata at
28   *                  http://www.ivata.com/contact.jsp
29   * -----------------------------------------------------------------------------
30   * $Log: AddFormatTag.java,v $
31   * Revision 1.2  2005/04/09 18:04:19  colinmacleod
32   * Changed copyright text to GPL v2 explicitly.
33   *
34   * Revision 1.1  2005/01/19 12:58:20  colinmacleod
35   * Moved from ivata groupware.
36   *
37   * Revision 1.5  2004/07/13 19:41:15  colinmacleod
38   * Moved project to POJOs from EJBs.
39   * Applied PicoContainer to services layer (replacing session EJBs).
40   * Applied Hibernate to persistence layer (replacing entity EJBs).
41   *
42   * Revision 1.4  2004/03/21 21:16:09  colinmacleod
43   * Shortened name to ivata op.
44   *
45   * Revision 1.3  2004/02/01 22:00:34  colinmacleod
46   * Added full names to author tags
47   *
48   * Revision 1.2  2004/01/29 14:30:09  janboros
49   * fixing package declaration
50   * and imports
51   *
52   * Revision 1.1.1.1  2004/01/27 20:57:58  colinmacleod
53   * Moved ivata openportal to SourceForge..
54   *
55   * Revision 1.1.1.1  2003/10/13 20:50:13  colin
56   * Restructured portal into subprojects
57   *
58   * Revision 1.1  2003/02/25 08:16:44  colin
59   * moved to jsp category
60   *
61   * Revision 1.2  2003/02/04 17:43:51  colin
62   * copyright notice
63   *
64   * Revision 1.1  2002/06/21 12:03:55  colin
65   * new format tag library, interface to the com.ivata.groupware.web.format.*
66   * classes
67   *
68   * /**
69   * <p>Add an {@link com.ivata.groupware.web.format.HTMLFormat
70   * HTMLFormat} to the list of formats in the <code>HTMLFormatter</code>
71   * you specify.</p>
72   * <p>This class is a wrapper for
73   * {@link com.ivata.groupware.web.format.HTMLFormatter#add
74   * HTMLFormatter.add}.</p>
75   * <p><b>Tag attributes:</b><br/>
76   * <table cellpadding='2' cellspacing='5' border='0' align='center'
77   * width='85%'>
78   *   <tr class='TableHeadingColor'>
79   *     <th>attribute</th>
80   *     <th>reqd.</th>
81   *     <th>param. class</th>
82   *     <th width='100%'>description</th>
83   *   </tr>
84   *   <tr class='TableRowColor'>
85   *     <td>format</td>
86   *     <td>false</td>
87   *     <td><code>com.ivata.html.format.HTMLFormat</code></td>
88   *     <td>Sets the format to add to the <code>HTMLFormatter</code>.</td>
89   *   </tr>
90   *   <tr class='TableRowColor'>
91   *     <td>formatter</td>
92   *     <td>false</td>
93   *     <td><code>com.ivata.html.format.HTMLFormatter</code></td>
94   *     <td>Sets the formatter to which you want to add a new format.</td>
95   *   </tr>
96   * </table>
97   * </p>
98   */
99  package com.ivata.mask.web.tag.format;
100 
101 import com.ivata.mask.web.format.HTMLFormat;
102 import com.ivata.mask.web.format.HTMLFormatter;
103 
104 import javax.servlet.jsp.tagext.TagSupport;
105 
106 /***
107  * Add a format to an <code>HTMLFormatter</code>.
108  * @since ivata masks 0.5 (2002-06-20)
109  * @author Colin MacLeod
110  * <a href='mailto:colin.macleod@ivata.com'>colin.macleod@ivata.com</a>
111  * @version $Revision: 1.2 $
112  * @see com.ivata.groupware.web.format.HTMLFormatter#add
113  */
114 public class AddFormatTag extends TagSupport {
115     /***
116      * <p>The the format you want to add to the formatter specified.</p>
117      */
118     private HTMLFormat format;
119 
120     /***
121      * <p>This is the object which actually does all the hard work. We just wrap
122      * <code>HTMLFormatter.add</code> in a JSP tag.</p>
123      */
124     private HTMLFormatter formatter = null;
125 
126     /***
127      * <p>This method is called when the JSP engine encounters the start tag,
128      * after the attributes are processed.<p>
129      *
130      * <p>Scripting variables (if any) have their values set here.</p>
131      *
132      * @return <code>SKIP_BODY</code> since this tag has no body.
133      */
134     public int doStartTag() {
135         // just add the format to the formatter...
136         formatter.add(format);
137 
138         // no body for this tag
139         return SKIP_BODY;
140     }
141 
142     /***
143      * <p>Set the {@link com.ivata.groupware.web.format.HTMLFormat HTMLFormat}
144      * object which should be added to the formatter.
145      *
146      * @param formatParam <code>HTMLFormat</code> to be added to the formatter.
147      */
148     public void setFormat(final HTMLFormat formatParam) {
149         this.format = formatParam;
150     }
151 
152     /***
153      * <p>Set the {@link com.ivata.groupware.web.format.HTMLFormatter
154      * HTMLFormatter}
155      * object which actually does all the hard work. We just wrap
156      * <code>HTMLFormatter.addFormat</code> in a JSP tag.</p>
157      *
158      * @param formatterParam <code>HTMLFormatter</code> to add a new format to.
159      */
160     public void setFormatter(final HTMLFormatter formatterParam) {
161         this.formatter = formatterParam;
162     }
163 }
164 
165 // end of file AddFormatTag.