Source Code Cross Referenced for Text.java in  » J2EE » webwork-2.2.6 » com » opensymphony » webwork » components » 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 » J2EE » webwork 2.2.6 » com.opensymphony.webwork.components 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        package com.opensymphony.webwork.components;
002:
003:        import java.io.IOException;
004:        import java.io.Writer;
005:        import java.util.ArrayList;
006:        import java.util.Collections;
007:        import java.util.Iterator;
008:        import java.util.List;
009:
010:        import org.apache.commons.logging.Log;
011:        import org.apache.commons.logging.LogFactory;
012:
013:        import com.opensymphony.util.TextUtils;
014:        import com.opensymphony.xwork.TextProvider;
015:        import com.opensymphony.xwork.util.OgnlValueStack;
016:
017:        /**
018:         * <!-- START SNIPPET: javadoc -->
019:         * Render a I18n text message. 
020:         * 
021:         * <p/>
022:         *
023:         * The message must be in a resource bundle
024:         * with the same name as the action that it is associated with. In practice
025:         * this means that you should create a properties file in the same package
026:         * as your Java class with the same name as your class, but with .properties
027:         * extension.
028:         *
029:         * <p/>
030:         *
031:         * If the named message is not found, then the body of the tag will be used as default message.
032:         * If no body is used, then the name of the message will be used.
033:         * 
034:         * <!-- END SNIPPET: javadoc -->
035:         *
036:         *
037:         *
038:         * <!-- START SNIPPET: params -->
039:         * 
040:         * <ul>
041:         *      <li>name* (String) - the i18n message key</li>
042:         * </ul>
043:         * 
044:         * <!-- END SNIPPET: params -->
045:         *
046:         * <p/>
047:         *
048:         * Example:
049:         * <pre>
050:         * <!-- START SNIPPET: exdescription -->
051:         * 
052:         * Accessing messages from a given bundle (the i18n Shop example bundle in the first example) and using bundle defined through ww in the second example.</p>
053:         * 
054:         * <!-- END SNIPPET: exdescription -->
055:         * </pre>
056:         *
057:         * <pre>
058:         * <!-- START SNIPPET: example -->
059:         * 
060:         * &lt;!-- First Example --&gt;
061:         * &lt;ww:i18n name="webwork.action.test.i18n.Shop"&gt;
062:         *     &lt;ww:text name="main.title"/&gt;
063:         * &lt;/ww:i18n&gt;
064:         *
065:         * &lt;!-- Second Example --&gt;
066:         * &lt;ww:text name="main.title" /&gt;
067:         * 
068:         * <!-- END SNIPPET: example -->
069:         * </pre>
070:         * 
071:         * 
072:         * <pre>
073:         * <!-- START SNIPPET: i18nExample -->
074:         *
075:         * &lt;-- Third Example --&gt;
076:         * &lt;ww:text name="some.key" /&gt;
077:         *
078:         * &lt;-- Fourth Example --&gt;
079:         * &lt;a:text name="some.invalid.key" &gt;
080:         *    The Default Message That Will Be Displayed
081:         * &lt;/a:text&gt;
082:         *
083:         * <!-- END SNIPPET: i18nExample -->
084:         * </pre>
085:         * 
086:         *
087:         * @author Jason Carreira
088:         * @author Patrick Lightbody
089:         * @author Rene Gielen
090:         * @author tm_jee
091:         * @version $Revision: 2586 $
092:         * @since 2.2
093:         *
094:         * @see Param
095:         *
096:         * @ww.tag name="text" tld-body-content="JSP" tld-tag-class="com.opensymphony.webwork.views.jsp.TextTag"
097:         * description="Render a I18n text message."
098:         */
099:        public class Text extends Component implements  Param.UnnamedParametric {
100:            private static final Log LOG = LogFactory.getLog(Text.class);
101:
102:            protected List values = Collections.EMPTY_LIST;
103:            protected String actualName;
104:            protected String name;
105:
106:            public Text(OgnlValueStack stack) {
107:                super (stack);
108:            }
109:
110:            /**
111:             *  Name of resource property to fetch
112:             * @ww.tagattribute required="true"
113:             */
114:            public void setName(String name) {
115:                this .name = name;
116:            }
117:
118:            public boolean usesBody() {
119:                // overriding this to true such that EVAL_BODY_BUFFERED is return and
120:                // bodyContent will be valid hence, text between start & end tag will
121:                // be honoured as default message (WW-1268)
122:                return true;
123:            }
124:
125:            public boolean end(Writer writer, String body) {
126:                actualName = findString(name, "name",
127:                        "You must specify the i18n key. Example: welcome.header");
128:                String defaultMessage;
129:                if (TextUtils.stringSet(body)) {
130:                    defaultMessage = body;
131:                } else {
132:                    defaultMessage = actualName;
133:                }
134:                String msg = null;
135:                OgnlValueStack stack = getStack();
136:
137:                for (Iterator iterator = getStack().getRoot().iterator(); iterator
138:                        .hasNext();) {
139:                    Object o = iterator.next();
140:
141:                    if (o instanceof  TextProvider) {
142:                        TextProvider tp = (TextProvider) o;
143:                        msg = tp.getText(actualName, defaultMessage, values,
144:                                stack);
145:
146:                        break;
147:                    }
148:                }
149:
150:                if (msg != null) {
151:                    try {
152:                        if (getId() == null) {
153:                            writer.write(msg);
154:                        } else {
155:                            stack.getContext().put(getId(), msg);
156:                        }
157:                    } catch (IOException e) {
158:                        LOG.error("Could not write out Text tag", e);
159:                    }
160:                }
161:
162:                return super .end(writer, "");
163:            }
164:
165:            public void addParameter(String key, Object value) {
166:                addParameter(value);
167:            }
168:
169:            public void addParameter(Object value) {
170:                if (values.isEmpty()) {
171:                    values = new ArrayList(4);
172:                }
173:
174:                values.add(value);
175:            }
176:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.