KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > tonbeller > wcf > statusline > StatusLineTag


1 /*
2  * ====================================================================
3  * This software is subject to the terms of the Common Public License
4  * Agreement, available at the following URL:
5  * http://www.opensource.org/licenses/cpl.html .
6  * Copyright (C) 2003-2004 TONBELLER AG.
7  * All Rights Reserved.
8  * You must accept the terms of that agreement to use this software.
9  * ====================================================================
10  *
11  *
12  */

13 package com.tonbeller.wcf.statusline;
14
15 import java.io.IOException JavaDoc;
16
17 import javax.servlet.jsp.JspException JavaDoc;
18 import javax.servlet.jsp.tagext.Tag JavaDoc;
19 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
20
21 import org.apache.log4j.Logger;
22
23 /**
24  * @author av
25  * @since 01.07.2004
26  */

27 public class StatusLineTag extends TagSupport JavaDoc {
28   static final String JavaDoc HTML = "html";
29   static final String JavaDoc TEXT = "text";
30   private static Logger logger = Logger.getLogger(StatusLineTag.class);
31   String JavaDoc format = "html";
32   boolean clear = true;
33
34   public int doStartTag() throws JspException JavaDoc {
35     try {
36       StatusLine sl = StatusLine.instance(pageContext.getSession());
37       if (sl.isEmpty())
38         return Tag.EVAL_BODY_INCLUDE;
39       if (HTML.equals(format))
40         pageContext.getOut().print(sl.getStatusHTML());
41       else if (TEXT.equals(format))
42         pageContext.getOut().print(sl.getStatusText());
43       else
44         throw new JspException JavaDoc("unknown format: " + format + " (expected \"html\" or \"text\")");
45       if (clear)
46         sl.clear();
47       return Tag.SKIP_BODY;
48     } catch (IOException JavaDoc e) {
49       logger.error(null, e);
50       return Tag.SKIP_BODY;
51     }
52   }
53
54   public void setClear(boolean clear) {
55     this.clear = clear;
56   }
57
58   public void setFormat(String JavaDoc format) {
59     this.format = format;
60   }
61 }
Popular Tags