KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > roller > ui > core > tags > StatusMessageTag


1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one or more
3 * contributor license agreements. The ASF licenses this file to You
4 * under the Apache License, Version 2.0 (the "License"); you may not
5 * use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License. For additional information regarding
15 * copyright in this work, please see the NOTICE file in the top level
16 * directory of this distribution.
17 */

18 package org.apache.roller.ui.core.tags;
19
20 import org.apache.commons.logging.Log;
21 import org.apache.commons.logging.LogFactory;
22 import org.apache.roller.ui.core.RollerSession;
23
24 import java.io.IOException JavaDoc;
25
26 import javax.servlet.http.HttpServletRequest JavaDoc;
27 import javax.servlet.jsp.JspException JavaDoc;
28 import javax.servlet.jsp.JspWriter JavaDoc;
29 import javax.servlet.jsp.tagext.Tag JavaDoc;
30 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
31
32
33 /**
34  * If there is an status message, then print it in red.
35  * @jsp.tag name="StatusMessage"
36  */

37 public class StatusMessageTag extends TagSupport JavaDoc
38 {
39     static final long serialVersionUID = -1086963203859216226L;
40     
41     private static Log mLogger =
42        LogFactory.getFactory().getInstance(StatusMessageTag.class);
43
44     public int doStartTag() throws JspException JavaDoc
45     {
46         try
47         {
48             JspWriter JavaDoc pw = pageContext.getOut();
49             HttpServletRequest JavaDoc req =
50                 (HttpServletRequest JavaDoc)pageContext.getRequest();
51
52             String JavaDoc msg = null;
53
54             msg = (String JavaDoc)req.getSession().getAttribute(
55                 RollerSession.ERROR_MESSAGE);
56             if (msg != null)
57             {
58                 pw.println("<span class=\"error\">");
59                 pw.println(msg);
60                 pw.println("</span>");
61                 req.getSession().removeAttribute(RollerSession.ERROR_MESSAGE);
62             }
63
64             msg = (String JavaDoc)req.getSession().getAttribute(
65                 RollerSession.STATUS_MESSAGE);
66             if (msg != null)
67             {
68                 pw.println("<span class=\"statusMsg\">");
69                 pw.println(msg);
70                 pw.println("</span>");
71                 req.getSession().removeAttribute(RollerSession.STATUS_MESSAGE);
72             }
73         }
74         catch (IOException JavaDoc e)
75         {
76             mLogger.error("Exception",e);
77             throw new JspException JavaDoc(e);
78         }
79         return Tag.SKIP_BODY;
80     }
81 }
82
83
Popular Tags