Source Code Cross Referenced for FormTemplate.java in  » Web-Server » Brazil » sunlabs » brazil » template » 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 Server » Brazil » sunlabs.brazil.template 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * FormTemplate.java
003:         *
004:         * Brazil project web application Framework,
005:         * export version: 1.1 
006:         * Copyright (c) 1998-2000 Sun Microsystems, Inc.
007:         *
008:         * Sun Public License Notice
009:         *
010:         * The contents of this file are subject to the Sun Public License Version 
011:         * 1.0 (the "License"). You may not use this file except in compliance with 
012:         * the License. A copy of the License is included as the file "license.terms",
013:         * and also available at http://www.sun.com/
014:         * 
015:         * The Original Code is from:
016:         *    Brazil project web application Framework release 1.1.
017:         * The Initial Developer of the Original Code is: suhler.
018:         * Portions created by suhler are Copyright (C) Sun Microsystems, Inc.
019:         * All Rights Reserved.
020:         * 
021:         * Contributor(s): cstevens, rinaldo, suhler.
022:         *
023:         * Version:  1.14
024:         * Created by suhler on 98/10/26
025:         * Last modified by suhler on 00/12/11 13:29:42
026:         */
027:
028:        package sunlabs.brazil.template;
029:
030:        import sunlabs.brazil.server.Server;
031:        import java.io.Serializable;
032:
033:        /**
034:         * Template class for substituting Default values into html forms
035:         * This class is used by the TemplateHandler.
036:         * 
037:         * The default values in form tags are replaced by the server property that
038:         * matches the field name. The following field elements are processed:
039:         * <ul>
040:         * <li> &lt;input name=<i>x</i> value=<i>y</i>&gt;
041:         * <li> &lt;input type=input name=<i>x</i> value=<i>y</i>&gt;
042:         * <li> &lt;input type=radio name=<i>x</i> value=<i>y</i>&gt;
043:         * <li> &lt;option value=<i>x</i>&gt;
044:         * </ul>
045:         * In all cases, the <code>value</code> attribute must be present.
046:         * 
047:         * @author		Stephen Uhler
048:         * @version		@(#) FormTemplate.java 1.5 99/06/30 12:23:07
049:         */
050:        public class FormTemplate extends Template implements  Serializable {
051:            String selectName; // The name of the current select variable
052:            String selectValue; // The name of the current select variable value
053:            int total; // total for elements examined
054:            int changed; // elements whose initial values have been changed
055:
056:            /**
057:             * Save a reference to our request properties.
058:             */
059:
060:            public boolean init(RewriteContext hr) {
061:                // System.out.println("Form Template Started");
062:                selectName = null;
063:                total = 0;
064:                changed = 0;
065:
066:                return true;
067:            }
068:
069:            /**
070:             * Look for &lt;input name=[x] value=[v]&gt; and replace the
071:             * value with the entry in the request properties. If no value is supplied,
072:             * no substitution is done.
073:             */
074:            public void tag_input(RewriteContext hr) {
075:                total++;
076:
077:                String name = hr.get("name");
078:
079:                if (name == null) {
080:                    return;
081:                }
082:
083:                String value = hr.request.props.getProperty(name);
084:
085:                if (value == null) {
086:                    return;
087:                }
088:
089:                changed++;
090:                String type = hr.get("type");
091:                if (type != null && type.equals("radio")) {
092:                    // System.out.println("Radio button: " + value + " ? " + hr.get("value"));
093:                    if (value.equals(hr.get("value"))) {
094:                        hr.put("checked", "");
095:                    } else {
096:                        hr.remove("checked");
097:                    }
098:                } else {
099:                    hr.put("value", value);
100:                }
101:            }
102:
103:            /**
104:             * Remember the variable name for the next group of option tags.
105:             */
106:            public void tag_select(RewriteContext hr) {
107:                selectName = hr.get("name");
108:
109:                if (selectName != null) {
110:                    selectValue = hr.request.props.getProperty(selectName);
111:
112:                    log(hr, "For selection (" + selectName + ") have value :"
113:                            + selectValue);
114:                }
115:            }
116:
117:            /**
118:             * Forget the variable name for the next group of option tags
119:             */
120:            public void tag_slash_select(RewriteContext hr) {
121:                selectName = null;
122:            }
123:
124:            /**
125:             * Look at the option tag, set the "selected" attribute as needed.
126:             * In order for this to work, the VALUE tag *must* be used
127:             */
128:            public void tag_option(RewriteContext hr) {
129:                String value = hr.get("value");
130:
131:                if (selectName == null || selectValue == null || value == null) {
132:                    return;
133:                }
134:                if (value.equals(selectValue)) {
135:                    hr.put("selected", "");
136:                } else {
137:                    hr.remove("selected");
138:                }
139:            }
140:
141:            /**
142:             * This is for debugging only !!
143:             */
144:            public boolean done(RewriteContext hr) {
145:                log(hr, hr.request.url + " (form template) " + changed + "/"
146:                        + total + " changed");
147:
148:                return true;
149:            }
150:
151:            /**
152:             * simple interface to server logging
153:             */
154:            private void log(RewriteContext hr, String msg) {
155:                hr.request.log(Server.LOG_DIAGNOSTIC, hr.prefix
156:                        + "formTemplate: " + msg);
157:            }
158:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.