Source Code Cross Referenced for CheckboxTag.java in  » Web-Framework » struts-1.3.8 » org » apache » struts » taglib » 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 » Web Framework » struts 1.3.8 » org.apache.struts.taglib.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: CheckboxTag.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.html;
022:
023:        import org.apache.struts.taglib.TagUtils;
024:        import org.apache.struts.util.MessageResources;
025:
026:        import javax.servlet.jsp.JspException;
027:
028:        /**
029:         * Tag for input fields of type "checkbox".
030:         *
031:         * @version $Rev: 471754 $ $Date: 2004-10-16 12:38:42 -0400 (Sat, 16 Oct 2004)
032:         *          $
033:         */
034:        public class CheckboxTag extends BaseHandlerTag {
035:            // ----------------------------------------------------- Instance Variables
036:
037:            /**
038:             * The message resources for this package.
039:             */
040:            protected static MessageResources messages = MessageResources
041:                    .getMessageResources(Constants.Package + ".LocalStrings");
042:
043:            /**
044:             * The name of the bean containing our underlying property.
045:             */
046:            protected String name = Constants.BEAN_KEY;
047:
048:            /**
049:             * The property name for this field.
050:             */
051:            protected String property = null;
052:
053:            /**
054:             * The body content of this tag (if any).
055:             */
056:            protected String text = null;
057:
058:            /**
059:             * The server value for this option.
060:             */
061:            protected String value = null;
062:
063:            public String getName() {
064:                return (this .name);
065:            }
066:
067:            public void setName(String name) {
068:                this .name = name;
069:            }
070:
071:            // ------------------------------------------------------------- Properties
072:
073:            /**
074:             * Return the property name.
075:             */
076:            public String getProperty() {
077:                return (this .property);
078:            }
079:
080:            /**
081:             * Set the property name.
082:             *
083:             * @param property The new property name
084:             */
085:            public void setProperty(String property) {
086:                this .property = property;
087:            }
088:
089:            /**
090:             * Return the server value.
091:             */
092:            public String getValue() {
093:                return (value == null) ? "on" : value;
094:            }
095:
096:            /**
097:             * Set the server value.
098:             *
099:             * @param value The new server value
100:             */
101:            public void setValue(String value) {
102:                this .value = value;
103:            }
104:
105:            // --------------------------------------------------------- Public Methods
106:
107:            /**
108:             * Generate the required input tag. <p> Support for indexed property since
109:             * Struts 1.1
110:             *
111:             * @throws JspException if a JSP exception has occurred
112:             */
113:            public int doStartTag() throws JspException {
114:                // Create an appropriate "input" element based on our parameters
115:                StringBuffer results = new StringBuffer(
116:                        "<input type=\"checkbox\"");
117:
118:                prepareAttribute(results, "name", prepareName());
119:                prepareAttribute(results, "accesskey", getAccesskey());
120:                prepareAttribute(results, "tabindex", getTabindex());
121:
122:                prepareAttribute(results, "value", getValue());
123:
124:                if (isChecked()) {
125:                    results.append(" checked=\"checked\"");
126:                }
127:
128:                results.append(prepareEventHandlers());
129:                results.append(prepareStyles());
130:                prepareOtherAttributes(results);
131:                results.append(getElementClose());
132:
133:                // Print this field to our output writer
134:                TagUtils.getInstance().write(pageContext, results.toString());
135:
136:                // Continue processing this page
137:                this .text = null;
138:
139:                return (EVAL_BODY_TAG);
140:            }
141:
142:            /**
143:             * Determines if the checkbox should be checked.
144:             *
145:             * @return true if checked="checked" should be rendered.
146:             * @throws JspException
147:             * @since Struts 1.2
148:             */
149:            protected boolean isChecked() throws JspException {
150:                Object result = TagUtils.getInstance().lookup(pageContext,
151:                        name, property, null);
152:
153:                if (result == null) {
154:                    result = "";
155:                }
156:
157:                result = result.toString();
158:
159:                String checked = (String) result;
160:
161:                return (checked.equalsIgnoreCase(this .value)
162:                        || checked.equalsIgnoreCase("true")
163:                        || checked.equalsIgnoreCase("yes") || checked
164:                        .equalsIgnoreCase("on"));
165:            }
166:
167:            /**
168:             * Save the associated label from the body content.
169:             *
170:             * @throws JspException if a JSP exception has occurred
171:             */
172:            public int doAfterBody() throws JspException {
173:                if (bodyContent != null) {
174:                    String value = bodyContent.getString().trim();
175:
176:                    if (value.length() > 0) {
177:                        text = value;
178:                    }
179:                }
180:
181:                return (SKIP_BODY);
182:            }
183:
184:            /**
185:             * Process the remainder of this page normally.
186:             *
187:             * @throws JspException if a JSP exception has occurred
188:             */
189:            public int doEndTag() throws JspException {
190:                // Render any description for this checkbox
191:                if (text != null) {
192:                    TagUtils.getInstance().write(pageContext, text);
193:                }
194:
195:                // Evaluate the remainder of this page
196:                return (EVAL_PAGE);
197:            }
198:
199:            /**
200:             * Prepare the name element
201:             *
202:             * @return The element name.
203:             */
204:            protected String prepareName() throws JspException {
205:                if (property == null) {
206:                    return null;
207:                }
208:
209:                // * @since Struts 1.1
210:                if (indexed) {
211:                    StringBuffer results = new StringBuffer();
212:
213:                    prepareIndex(results, name);
214:                    results.append(property);
215:
216:                    return results.toString();
217:                }
218:
219:                return property;
220:            }
221:
222:            /**
223:             * Release any acquired resources.
224:             */
225:            public void release() {
226:                super.release();
227:                name = Constants.BEAN_KEY;
228:                property = null;
229:                text = null;
230:                value = null;
231:            }
232:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.