KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > raptus > owxv3 > libtags > ResourceFileTag


1 /*
2  * eAdmin/OWX
3  * Copyright (C) 1996-2003 OWX-Project Team <owx-team@gmx.net>
4  */

5
6 package com.raptus.owxv3.libtags;
7
8 import java.io.IOException JavaDoc;
9
10 import javax.servlet.jsp.JspException JavaDoc;
11 import javax.servlet.jsp.tagext.TagSupport JavaDoc;
12
13 import org.apache.struts.Globals;
14 import org.apache.struts.action.Action;
15 import org.apache.struts.util.RequestUtils;
16
17 import com.raptus.owxv3.LoggingManager;
18
19 /**
20  *
21  * <hr>
22  * <table width="100%" border="0">
23  * <tr>
24  * <td width="24%"><b>Filename</b></td><td width="76%">ResourceFile.java</td>
25  * </tr>
26  * <tr>
27  * <td width="24%"><b>Author</b></td><td width="76%">Guy Zürcher (gzuercher@raptus.com)</td>
28  * </tr>
29  * <tr>
30  * <td width="24%"><b>Date</b></td><td width="76%">11th of June 2001</td>
31  * </tr>
32  * </table>
33  * <hr>
34  * <table width="100%" border="0">
35  * <tr>
36  * <td width="24%"><b>Date / Author</b></td><td width="76%"><b>Changes</b></td>
37  * </tr>
38  * </table>
39  * <hr>
40  */

41 public class ResourceFileTag extends TagSupport JavaDoc {
42
43
44     // ------------------------------------------------------------- Properties
45

46     /**
47      * default message resources is app
48      */

49     protected String JavaDoc myid = Action.MESSAGES_KEY;
50
51     public String JavaDoc getId() {
52         return (this.myid);
53     }
54
55     public void setId(String JavaDoc id) {
56         this.myid = id;
57     }
58
59
60     /**
61      * required!
62      */

63     protected String JavaDoc mykey = null;
64
65     public String JavaDoc getKey() {
66         return (this.mykey);
67     }
68
69     public void setKey(String JavaDoc key) {
70         this.mykey = key;
71     }
72
73     // --------------------------------------------------------- Public Methods
74

75
76     /**
77      * Process the start tag.
78      *
79      * @exception JspException if a JSP exception has occurred
80      */

81     public int doStartTag() throws JspException JavaDoc
82     {
83         String JavaDoc fname = RequestUtils.message(pageContext, myid,
84                                             Globals.LOCALE_KEY, mykey);
85         if(fname == null)
86         {
87             JspException JavaDoc e = new JspException JavaDoc("Cannot retrieve filename!");
88             RequestUtils.saveException(pageContext, e);
89             throw e;
90         }
91         else
92         {
93             try
94             {
95                 pageContext.include(fname);
96             }
97             catch(javax.servlet.ServletException JavaDoc e) {
98                 LoggingManager.log("ServletException (" + e.getMessage() +
99                                    ") while trying to include file " + fname, this);
100             }
101             catch(IOException JavaDoc e) {
102                 LoggingManager.log("IOException (" + e.getMessage() +
103                                    ") while trying to include file " + fname, this);
104             }
105         }
106
107         // Continue processing this page
108
return (SKIP_BODY);
109     }
110
111
112     /**
113      * Release any acquired resources.
114      */

115     public void release()
116     {
117         super.release();
118     }
119
120 }
121
122 // eof
123
Popular Tags