KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > lucane > webconnector > widgets > MessageWidget


1 /*
2  * Lucane - a collaborative platform
3  * Copyright (C) 2004 Vincent Fiack <vfiack@mail15.com>
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or (at your option) any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
18  */

19 package org.lucane.webconnector.widgets;
20
21 import java.io.IOException JavaDoc;
22 import java.io.Writer JavaDoc;
23 import javax.servlet.http.HttpServletRequest JavaDoc;
24
25 import org.lucane.webconnector.WebApp;
26
27 public class MessageWidget implements Widget
28 {
29     private WebApp app;
30     private HttpServletRequest JavaDoc request;
31     
32     public MessageWidget(WebApp app, HttpServletRequest JavaDoc request)
33     {
34         this.app = app;
35         this.request = request;
36     }
37     
38     public void render(Writer JavaDoc out) throws IOException JavaDoc
39     {
40         String JavaDoc error = request.getParameter("error");
41         String JavaDoc warning = request.getParameter("warning");
42         String JavaDoc info = request.getParameter("info");
43         String JavaDoc question = request.getParameter("question");
44         
45         out.write("<!-- MessageWidget start -->\n");
46         
47         if(error != null)
48         {
49             out.write("<div class='error'>\n");
50             out.write(app.tr(error));
51             out.write("\n</div>\n");
52         }
53         
54         if(warning != null)
55         {
56             out.write("<div class='warning'>\n");
57             out.write(app.tr(warning));
58             out.write("\n</div>\n");
59         }
60         
61         if(info != null)
62         {
63             out.write("<div class='info'>\n");
64             out.write(app.tr(info));
65             out.write("\n</div>\n");
66         }
67         
68         if(question != null)
69         {
70             out.write("<div class='question'>\n");
71             out.write(app.tr(question));
72             out.write("\n</div>\n");
73         }
74         
75         out.write("<!-- MessageWidget end -->");
76     }
77 }
Popular Tags