Source Code Cross Referenced for MessageTag.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » taglib » bean » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Web Framework » struts 1.3.8 » org.apache.struts.taglib.bean 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: MessageTag.java 471754 2006-11-06 14:55:09Z husted $
003:         *
004:         * Licensed to the Apache Software Foundation (ASF) under one
005:         * or more contributor license agreements.  See the NOTICE file
006:         * distributed with this work for additional information
007:         * regarding copyright ownership.  The ASF licenses this file
008:         * to you under the Apache License, Version 2.0 (the
009:         * "License"); you may not use this file except in compliance
010:         * with the License.  You may obtain a copy of the License at
011:         *
012:         *  http://www.apache.org/licenses/LICENSE-2.0
013:         *
014:         * Unless required by applicable law or agreed to in writing,
015:         * software distributed under the License is distributed on an
016:         * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
017:         * KIND, either express or implied.  See the License for the
018:         * specific language governing permissions and limitations
019:         * under the License.
020:         */
021:        package org.apache.struts.taglib.bean;
022:
023:        import org.apache.struts.Globals;
024:        import org.apache.struts.taglib.TagUtils;
025:        import org.apache.struts.util.MessageResources;
026:
027:        import javax.servlet.jsp.JspException;
028:        import javax.servlet.jsp.tagext.TagSupport;
029:
030:        import java.util.Locale;
031:
032:        /**
033:         * Custom tag that retrieves an internationalized messages string (with
034:         * optional parametric replacement) from the <code>ActionResources</code>
035:         * object stored as a context attribute by our associated
036:         * <code>ActionServlet</code> implementation.
037:         *
038:         * @version $Rev: 471754 $ $Date: 2005-09-16 09:38:33 -0400 (Fri, 16 Sep 2005)
039:         *          $
040:         */
041:        public class MessageTag extends TagSupport {
042:            /**
043:             * The message resources for this package.
044:             */
045:            protected static MessageResources messages = MessageResources
046:                    .getMessageResources("org.apache.struts.taglib.bean.LocalStrings");
047:
048:            // ------------------------------------------------------------- Properties
049:
050:            /**
051:             * The first optional argument.
052:             */
053:            protected String arg0 = null;
054:
055:            /**
056:             * The second optional argument.
057:             */
058:            protected String arg1 = null;
059:
060:            /**
061:             * The third optional argument.
062:             */
063:            protected String arg2 = null;
064:
065:            /**
066:             * The fourth optional argument.
067:             */
068:            protected String arg3 = null;
069:
070:            /**
071:             * The fifth optional argument.
072:             */
073:            protected String arg4 = null;
074:
075:            /**
076:             * The servlet context attribute key for our resources.
077:             */
078:            protected String bundle = null;
079:
080:            /**
081:             * The message key of the message to be retrieved.
082:             */
083:            protected String key = null;
084:
085:            /**
086:             * Name of the bean that contains the message key.
087:             */
088:            protected String name = null;
089:
090:            /**
091:             * Name of the property to be accessed on the specified bean.
092:             */
093:            protected String property = null;
094:
095:            /**
096:             * The scope to be searched to retrieve the specified bean.
097:             */
098:            protected String scope = null;
099:
100:            /**
101:             * The session scope key under which our Locale is stored.
102:             */
103:            protected String localeKey = Globals.LOCALE_KEY;
104:
105:            public String getArg0() {
106:                return (this .arg0);
107:            }
108:
109:            public void setArg0(String arg0) {
110:                this .arg0 = arg0;
111:            }
112:
113:            public String getArg1() {
114:                return (this .arg1);
115:            }
116:
117:            public void setArg1(String arg1) {
118:                this .arg1 = arg1;
119:            }
120:
121:            public String getArg2() {
122:                return (this .arg2);
123:            }
124:
125:            public void setArg2(String arg2) {
126:                this .arg2 = arg2;
127:            }
128:
129:            public String getArg3() {
130:                return (this .arg3);
131:            }
132:
133:            public void setArg3(String arg3) {
134:                this .arg3 = arg3;
135:            }
136:
137:            public String getArg4() {
138:                return (this .arg4);
139:            }
140:
141:            public void setArg4(String arg4) {
142:                this .arg4 = arg4;
143:            }
144:
145:            public String getBundle() {
146:                return (this .bundle);
147:            }
148:
149:            public void setBundle(String bundle) {
150:                this .bundle = bundle;
151:            }
152:
153:            public String getKey() {
154:                return (this .key);
155:            }
156:
157:            public void setKey(String key) {
158:                this .key = key;
159:            }
160:
161:            public String getName() {
162:                return (this .name);
163:            }
164:
165:            public void setName(String name) {
166:                this .name = name;
167:            }
168:
169:            public String getProperty() {
170:                return (this .property);
171:            }
172:
173:            public void setProperty(String property) {
174:                this .property = property;
175:            }
176:
177:            public String getScope() {
178:                return (this .scope);
179:            }
180:
181:            public void setScope(String scope) {
182:                this .scope = scope;
183:            }
184:
185:            public String getLocale() {
186:                return (this .localeKey);
187:            }
188:
189:            public void setLocale(String localeKey) {
190:                this .localeKey = localeKey;
191:            }
192:
193:            // --------------------------------------------------------- Public Methods
194:
195:            /**
196:             * Process the start tag.
197:             *
198:             * @throws JspException if a JSP exception has occurred
199:             */
200:            public int doStartTag() throws JspException {
201:                String key = this .key;
202:
203:                if (key == null) {
204:                    // Look up the requested property value
205:                    Object value = TagUtils.getInstance().lookup(pageContext,
206:                            name, property, scope);
207:
208:                    if ((value != null) && !(value instanceof  String)) {
209:                        JspException e = new JspException(messages.getMessage(
210:                                "message.property", key));
211:
212:                        TagUtils.getInstance().saveException(pageContext, e);
213:                        throw e;
214:                    }
215:
216:                    key = (String) value;
217:                }
218:
219:                // Construct the optional arguments array we will be using
220:                Object[] args = new Object[] { arg0, arg1, arg2, arg3, arg4 };
221:
222:                // Retrieve the message string we are looking for
223:                String message = TagUtils.getInstance().message(pageContext,
224:                        this .bundle, this .localeKey, key, args);
225:
226:                if (message == null) {
227:                    Locale locale = TagUtils.getInstance().getUserLocale(
228:                            pageContext, this .localeKey);
229:                    String localeVal = (locale == null) ? "default locale"
230:                            : locale.toString();
231:                    JspException e = new JspException(messages.getMessage(
232:                            "message.message", "\"" + key + "\"", "\""
233:                                    + ((bundle == null) ? "(default bundle)"
234:                                            : bundle) + "\"", localeVal));
235:
236:                    TagUtils.getInstance().saveException(pageContext, e);
237:                    throw e;
238:                }
239:
240:                TagUtils.getInstance().write(pageContext, message);
241:
242:                return (SKIP_BODY);
243:            }
244:
245:            /**
246:             * Release any acquired resources.
247:             */
248:            public void release() {
249:                super.release();
250:                arg0 = null;
251:                arg1 = null;
252:                arg2 = null;
253:                arg3 = null;
254:                arg4 = null;
255:                bundle = Globals.MESSAGES_KEY;
256:                key = null;
257:                name = null;
258:                property = null;
259:                scope = null;
260:                localeKey = Globals.LOCALE_KEY;
261:            }
262:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.