Source Code Cross Referenced for LabelBase.java in  » Library » Apache-beehive-1.0.2-src » org » apache » beehive » netui » tags » html » 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 » Library » Apache beehive 1.0.2 src » org.apache.beehive.netui.tags.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * Licensed to the Apache Software Foundation (ASF) under one or more
003:         * contributor license agreements.  See the NOTICE file distributed with
004:         * this work for additional information regarding copyright ownership.
005:         * The ASF licenses this file to You under the Apache License, Version 2.0
006:         * (the "License"); you may not use this file except in compliance with
007:         * the License.  You may obtain a copy of the License at
008:         * 
009:         *     http://www.apache.org/licenses/LICENSE-2.0
010:         * 
011:         * Unless required by applicable law or agreed to in writing, software
012:         * distributed under the License is distributed on an "AS IS" BASIS,
013:         * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014:         * See the License for the specific language governing permissions and
015:         * limitations under the License.
016:         *
017:         * $Header:$
018:         */
019:        package org.apache.beehive.netui.tags.html;
020:
021:        import org.apache.beehive.netui.util.internal.InternalStringBuilder;
022:
023:        import org.apache.beehive.netui.tags.HtmlUtils;
024:        import org.apache.beehive.netui.tags.rendering.AbstractRenderAppender;
025:
026:        import javax.servlet.jsp.JspException;
027:        import java.util.ArrayList;
028:
029:        /**
030:         * This is a base class providing implementation for both the Label and FormLabel.
031:         */
032:        public abstract class LabelBase extends HtmlBaseTag implements 
033:                IFormattable {
034:            protected static final String DEFAULT_NULL_TEXT = "";
035:
036:            protected Object _defaultValue; // The attribute value of the defaultValue attribute
037:            protected Object _value; // The text of the Label.
038:            protected boolean _escapeWhiteSpace = true; // escape white space flag
039:            protected boolean _formatterErrors = false; // The formatter has errors.
040:            protected boolean _formatDefaultValue = false; // Format the defaultValue
041:            private ArrayList _formatters; // The formatters
042:
043:            /**
044:             * Set the default value of this Label.
045:             * This can be an expression.  If the default value is an expression
046:             * all formatters will be applied, otherwise the default value will be output
047:             * without being formatted.
048:             * @param defaultValue the default value
049:             * @jsptagref.attributedescription The String literal or expression to be used as the
050:             * default output. If the default value is an expression all formatters will be applied,
051:             * otherwise the default value will be output without being formatted.
052:             * @jsptagref.databindable false
053:             * @jsptagref.attributesyntaxvalue <i>string_or_expression_defaultValue</i>
054:             * @netui:attribute required="false" rtexprvalue="true" type="java.lang.Object"
055:             * description="Set the default value of this Label or Span."
056:             */
057:            public void setDefaultValue(Object defaultValue) {
058:                _defaultValue = defaultValue;
059:            }
060:
061:            /**
062:             * Boolean indicating whether the formatter should be applied to the defaultValue.
063:             * The default is "false" meaning formatters will not be applied.
064:             * @param formatDisplay Apply formatting to the default value.
065:             * @jsptagref.attributedescription Boolean indicating whether the formatter should be applied
066:             * to the defaultValue. The default is "false" meaning formatters will not be applied.
067:             * @jsptagref.databindable false
068:             * @jsptagref.attributesyntaxvalue boolean_formatDisplay
069:             * @netui:attribute required="false" rtexprvalue="true"
070:             * description="Apply formatting to the default value of this Label or Span."
071:             */
072:            public void setFormatDefaultValue(boolean formatDisplay) {
073:                _formatDefaultValue = formatDisplay;
074:            }
075:
076:            /**
077:             * Sets the text of the Label.
078:             * @param value the Label value or expression.
079:             * @jsptagref.attributedescription The String literal or expression used as the text of the Label.
080:             * @jsptagref.databindable false
081:             * @jsptagref.attributesyntaxvalue <i>string_or_expression_output</i>
082:             * @netui:attribute required="true" rtexprvalue="true" type="java.lang.Object"
083:             * description="Sets the text of the Label or Span."
084:             */
085:            public void setValue(Object value) {
086:                _value = value;
087:            }
088:
089:            /**
090:             * Sets a <code>boolean</code> flag indicating if we will escape
091:             * white space for HTML.  If this is <code>true</code> the white space
092:             * charcters ' ' will be converted into "&nbsp;" and '\n' converted into
093:             * "<br />".  The result is that in HTML white space will be represented
094:             * correctly.  If this is <code>false</code> then white space will be
095:             * output as it is found in the value.
096:             * @param escapeWhiteSpace boolean indicating if we are escaping for white space.
097:             * @jsptagref.attributedescription Sets a boolean flag indicating if we will escape
098:             * white space for HTML.
099:             * @jsptagref.attributesyntaxvalue <i>boolean_escapeWhiteSpace</i>
100:             * @netui:attribute required="false" rtexprvalue="true"  type="boolean"
101:             * description="Sets a boolean flag indicating if we will escape
102:             * white space for HTML."
103:             */
104:            public void setEscapeWhiteSpaceForHtml(boolean escapeWhiteSpace) {
105:                _escapeWhiteSpace = escapeWhiteSpace;
106:
107:            }
108:
109:            /**
110:             * Adds a FormatTag.Formatter to the Label's set of formatters
111:             * @param formatter a FormatTag.Formatter added by a child FormatTag.
112:             */
113:            public void addFormatter(FormatTag.Formatter formatter) {
114:                if (_formatters == null)
115:                    _formatters = new ArrayList();
116:                _formatters.add(formatter);
117:            }
118:
119:            /**
120:             * Indicate that a formatter has reported an error so the formatter should output it's
121:             * body text.
122:             */
123:            public void formatterHasError() {
124:                _formatterErrors = true;
125:            }
126:
127:            /**
128:             * Filter the specified string for characters that are senstive to
129:             * HTML interpreters, returning the string with these characters replaced
130:             * by the corresponding character entities.
131:             * @param value                 The string to be filtered and returned
132:             * @param markupHTMLSpaceReturn convert space characters and return characters
133:             *                              to &amp;nbsp; and &lt;br /&gt; marketup for html.
134:             */
135:            protected void filter(String value, AbstractRenderAppender writer,
136:                    boolean markupHTMLSpaceReturn) {
137:                if (value.equals(" ")) {
138:                    writer.append("&nbsp;");
139:                    return;
140:                }
141:
142:                HtmlUtils.filter(value, writer, markupHTMLSpaceReturn);
143:            }
144:
145:            /**
146:             * Release any acquired resources.
147:             */
148:            protected void localRelease() {
149:                super .localRelease();
150:
151:                _defaultValue = null;
152:                _escapeWhiteSpace = true;
153:                _formatters = null;
154:                _formatterErrors = false;
155:                _formatDefaultValue = false;
156:                _value = null;
157:            }
158:
159:            /**
160:             *
161:             */
162:            protected String formatText(Object text) throws JspException {
163:                InternalStringBuilder errors = null;
164:                if (text == null)
165:                    return null;
166:
167:                if (_formatters == null)
168:                    return text.toString();
169:
170:                for (int i = 0; i < _formatters.size(); i++) {
171:                    FormatTag.Formatter currentFormatter = (FormatTag.Formatter) _formatters
172:                            .get(i);
173:
174:                    // if there are errors in the formatter, we need to report them
175:                    // and continue to the next one.
176:                    if (currentFormatter.hasError()) {
177:                        if (errors == null) {
178:                            errors = new InternalStringBuilder(32);
179:                        }
180:                        assert (errors != null);
181:                        errors.append(currentFormatter.getErrorMessage());
182:                        continue;
183:                    }
184:
185:                    // apply the formatter.
186:                    try {
187:                        text = currentFormatter.format(text);
188:                    } catch (JspException e) {
189:                        registerTagError(e.getMessage(), e);
190:                    }
191:                }
192:                // if there were errors we will return the errors followed by the text,
193:                // otherwise just return the text.
194:                if (errors != null) {
195:                    return errors.toString() + text.toString();
196:                }
197:                return text.toString();
198:            }
199:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.