Source Code Cross Referenced for Property.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 com.opensymphony.xwork.util.OgnlValueStack;
004:        import com.opensymphony.util.TextUtils;
005:
006:        import java.io.Writer;
007:        import java.io.IOException;
008:
009:        import org.apache.commons.logging.Log;
010:        import org.apache.commons.logging.LogFactory;
011:
012:        /**
013:         * <!-- START SNIPPET: javadoc -->
014:         * 
015:         * Used to get the property of a <i>value</i>, which will default to the top of
016:         * the stack if none is specified.
017:         * 
018:         * <!-- END SNIPPET: javadoc -->
019:         * 
020:         * <p/>
021:         * 
022:         *
023:         * <!-- START SNIPPET: params -->
024:         * 
025:         * <ul>
026:         *      <li>default (String) - The default value to be used if <u>value</u> attribute is null</li>
027:         *      <li>escape (Boolean) - Escape HTML. Default to true</li>
028:         *      <li>value (Object) - value to be displayed</li>
029:         * </ul>
030:         * 
031:         * <!-- END SNIPPET: params -->
032:         *
033:         *
034:         * <pre>
035:         * <!-- START SNIPPET: example -->
036:         * 
037:         * <ww:push value="myBean">
038:         *     <!-- Example 1: -->
039:         *     <ww:property value="myBeanProperty" />
040:         *
041:         *     <!-- Example 2: -->
042:         *     <ww:property value="myBeanProperty" default="a default value" />
043:         * </ww:push>
044:         * 
045:         * <!-- END SNIPPET: example -->
046:         * </pre>
047:         * 
048:         * <pre>
049:         * <!-- START SNIPPET: exampledescription -->
050:         * 
051:         * Example 1 prints the result of myBean's getMyBeanProperty() method.
052:         * Example 2 prints the result of myBean's getMyBeanProperty() method and if it is null, print 'a default value' instead.
053:         * 
054:         * <!-- END SNIPPET: exampledescription -->
055:         * </pre>
056:         * 
057:         * 
058:         * <pre>
059:         * <!-- START SNIPPET: i18nExample -->
060:         * 
061:         * &lt;ww:property value="getText('some.key')" /&gt;
062:         * 
063:         * <!-- END SNIPPET: i18nExample -->
064:         * </pre>
065:         *
066:         *
067:         * @author Patrick Lightbody
068:         * @author Cameron Braid
069:         * @author Mathias Bogaert
070:         * @author tm_jee
071:         * @author Rene Gielen
072:         * @version $Revision: 2468 $
073:         *
074:         * @ww.tag name="property" tld-body-content="empty" tld-tag-class="com.opensymphony.webwork.views.jsp.PropertyTag"
075:         * description="Print out expression which evaluates against the stack"
076:         */
077:        public class Property extends Component {
078:            private static final Log LOG = LogFactory.getLog(Property.class);
079:
080:            public Property(OgnlValueStack stack) {
081:                super (stack);
082:            }
083:
084:            private String defaultValue;
085:            private String value;
086:            private boolean escape = true;
087:
088:            /**
089:             * The default value to be used if <u>value</u> attribute is null
090:             * @ww.tagattribute required="false" type="String"
091:             */
092:            public void setDefault(String defaultValue) {
093:                this .defaultValue = defaultValue;
094:            }
095:
096:            /**
097:             * Whether to escape HTML
098:             * @ww.tagattribute required="false" type="Boolean" default="true"
099:             */
100:            public void setEscape(boolean escape) {
101:                this .escape = escape;
102:            }
103:
104:            /**
105:             * value to be displayed
106:             * @ww.tagattribute required="false" type="Object" default="&lt;top of stack&gt;"
107:             */
108:            public void setValue(String value) {
109:                this .value = value;
110:            }
111:
112:            public boolean start(Writer writer) {
113:                boolean result = super .start(writer);
114:
115:                String actualValue = null;
116:
117:                if (value == null) {
118:                    value = "top";
119:                } else if (altSyntax()) {
120:                    // the same logic as with findValue(String)
121:                    // if value start with %{ and end with }, just cut it off!
122:                    if (value.startsWith("%{") && value.endsWith("}")) {
123:                        value = value.substring(2, value.length() - 1);
124:                    }
125:                }
126:
127:                // exception: don't call findString(), since we don't want the
128:                //            expression parsed in this one case. it really
129:                //            doesn't make sense, in fact.
130:                actualValue = (String) getStack()
131:                        .findValue(value, String.class);
132:
133:                try {
134:                    if (actualValue != null) {
135:                        writer.write(prepare(actualValue));
136:                    } else if (defaultValue != null) {
137:                        writer.write(prepare(defaultValue));
138:                    }
139:                } catch (IOException e) {
140:                    LOG.info("Could not print out value '" + value + "'", e);
141:                }
142:
143:                return result;
144:            }
145:
146:            private String prepare(String value) {
147:                if (escape) {
148:                    return TextUtils.htmlEncode(value);
149:                } else {
150:                    return value;
151:                }
152:            }
153:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.