Source Code Cross Referenced for FormClientTemplate.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:         * FormClientTemplate.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.11
024:         * Created by suhler on 98/10/27
025:         * Last modified by suhler on 00/12/11 20:25:48
026:         */
027:
028:        package sunlabs.brazil.template;
029:
030:        import java.util.Hashtable;
031:        import sunlabs.brazil.server.Server;
032:
033:        /**
034:         * [<i>Deprecated, use the FormTemplate and ConfigFileHandler instead</i>]<br>
035:         * SAMPLE Template class for substituting Default values into html forms
036:         * The data is retrieved from the client, and sent back to
037:         * the client later on.  This will be used for e-business cards
038:         * stored on java rings/cards.  This template also incorporates the functionallity
039:         * of the PropsTemplate, as the current scheme doesn't allow composition of
040:         * template handler classes (at least for now).
041:         *
042:         * If a URL contains query data, and the value of the server
043:         * property "uploadContains" occurs in the URL, then all of the query data
044:         * is saved in the server on behalf of the client.  IF no "uploadContains"
045:         * string is set, all query data is saved on the server.
046:         *
047:         * The following Html entities processed by this class:
048:         * <dl class=tags>
049:         * <dt> input
050:         * <dd> if the "name" attribute has saved data, the value attribute is
051:         *	replaced by the caved value.  This allows default form values to be
052:         *	replaced by previous data submitted to the server by the client.
053:         * <dt> property
054:         * <dd> This tag is replaced by the value of a server property.
055:         * <dt> subst
056:         * <dd> This tag is replaced by the value previously uploaded to the the
057:         *	server from the client for this value.
058:         * <dt> tag, /tag
059:         * <dd> Inserts a "<" or ">" respectively, allowing parameters to
060:         *	be substituted inside of other entities.  For example, suppose
061:         *	the client uploaded the value <b>HOME</b> as
062:         *	<code>http://my.home.com/</code>, and the server withes to create a
063:         *	link to that page.  The template fragment:
064:         *	"&lt;a href=&lt;subst HOME&gt;gt;
065:         *	won't work, as nested entities are not allowed.  Instead, try:
066:         *	"&lt;tag&gt;a href=&lt;subst HOME&gt;lt;tag&gt;
067:         * </dl>
068:         *
069:         * @author		Stephen Uhler
070:         * @version           @(#) FormClientTemplate.java 1.5 99/05/24 10:14:07
071:         */
072:
073:        public class FormClientTemplate extends Template {
074:            Hashtable data; // data sent from client, to be stored on server
075:            String uploadUrl; // url's to upload data must contain this string
076:            static final String UPLOAD = "uploadContains";
077:
078:            public FormClientTemplate() {
079:                data = new Hashtable();
080:            }
081:
082:            /**
083:             * Save a reference to our request properties.
084:             * If the URL contains the upload string, save all of the query
085:             * parameters on behalf of the user.
086:             */
087:
088:            public boolean init(RewriteContext hr) {
089:                uploadUrl = hr.request.props
090:                        .getProperty(hr.prefix + UPLOAD, "");
091:                log(hr, "Upload url: " + uploadUrl);
092:
093:                /*
094:                 * If this is an "upload" url, save the data, and ignore the rest
095:                 * of the request. I'm not sure how to identify upload url's yet.
096:                 * For now, anything that has query data??
097:                 */
098:
099:                if (hr.request.url.indexOf(uploadUrl) != -1) {
100:                    data = hr.request.getQueryData(data);
101:                    log(hr, "saving data for: " + hr.request.url);
102:                }
103:                log(hr, "data for: " + hr.request.url + ": " + data);
104:                return true;
105:            }
106:
107:            /**
108:             * Look for <input name=[x] value=[v]>, and replace the
109:             * value with the entry in the previously saved client data.
110:             * @param h		The attribute/value pairs for this entity.
111:             */
112:
113:            public void tag_input(RewriteContext hr) {
114:                String name = hr.get("name");
115:                if (name == null) {
116:                    return;
117:                }
118:
119:                String value = (String) data.get(name);
120:                if (value == null) {
121:                    return;
122:                }
123:
124:                hr.put("value", value);
125:            }
126:
127:            /**
128:             * Convert the html tag "property" in to the request's property.
129:             * @param h		Hashtable containing tag parameters
130:             *			"name"	The property name
131:             *			"default" a default value, if no name available
132:             */
133:
134:            public void tag_property(RewriteContext hr) {
135:                String name = hr.getArgs();
136:                String value = null;
137:
138:                if (name.indexOf('=') >= 0) {
139:                    name = hr.get("name");
140:                    value = hr.get("default");
141:                }
142:                hr.append(hr.request.props.getProperty(name, value));
143:            }
144:
145:            /**
146:             * Tag to do substitution of previously uploaded data.
147:             * @param name	The name of the token to replace with client data.
148:             */
149:
150:            public void tag_subst(RewriteContext hr) {
151:                String name = hr.getArgs();
152:                String value = null;
153:                if (name.indexOf('=') >= 0) {
154:                    name = hr.get("name");
155:                    value = hr.get("default");
156:                }
157:                String result = (String) data.get(name);
158:                if (result == null) {
159:                    result = value;
160:                }
161:                hr.append(result);
162:            }
163:
164:            /**
165:             * Using the current scheme, there is no easy way to substitute into
166:             * a tag parameter.  So we'll invent a "magic" tag (called tag)
167:             * that will allow us to create entities dynamically
168:             */
169:
170:            public void tag_tag(RewriteContext hr) {
171:                hr.append("<");
172:            }
173:
174:            public void tag_slash_tag(RewriteContext hr) {
175:                hr.append(">");
176:            }
177:
178:            /**
179:             * simple interface to server logging
180:             */
181:
182:            private void log(RewriteContext hr, String msg) {
183:                hr.request.log(Server.LOG_DIAGNOSTIC, hr.prefix
184:                        + "formClientTemplate: " + msg);
185:            }
186:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.