KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > de > jwi > jgallery > tags > TextTag


1 package de.jwi.jgallery.tags;
2
3 /*
4  * jGallery - Java web application to display image galleries
5  *
6  * Copyright (C) 2004 Juergen Weber
7  *
8  * This file is part of jGallery.
9  *
10  * jGallery is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU General Public License as published by
12  * the Free Software Foundation; either version 2 of the License, or
13  * (at your option) any later version.
14  *
15  * jGallery is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with jGallery; if not, write to the Free Software
22  * Foundation, Inc., 59 Temple Place, Suite 330, Boston
23  */

24
25
26 import java.io.IOException JavaDoc;
27
28 import javax.servlet.jsp.JspTagException JavaDoc;
29 import javax.servlet.jsp.JspWriter JavaDoc;
30 import javax.servlet.jsp.tagext.BodyContent JavaDoc;
31 import javax.servlet.jsp.tagext.BodyTagSupport JavaDoc;
32
33 /**
34  * @author Juergen Weber
35  * Source file created on 18.02.2004
36  *
37  */

38 public class TextTag extends BodyTagSupport JavaDoc
39 {
40
41     public int doAfterBody()
42     throws JspTagException JavaDoc
43     {
44         BodyContent JavaDoc body = getBodyContent();
45         String JavaDoc s = body.getString();
46         if (!s.matches("\\w*"))
47         {
48             throw new JspTagException JavaDoc("TextTag may not contain whitespace");
49         }
50         
51         // TODO: get I18n from Property
52

53         try
54         {
55             JspWriter JavaDoc out = body.getEnclosingWriter();
56             out.print(s);
57         }
58         catch (IOException JavaDoc ioe)
59         {
60             System.out.println("Error in TextTag: " + ioe);
61         }
62         return (SKIP_BODY);
63     }
64
65 }
66
Popular Tags