Source Code Cross Referenced for HtmlFormWrapper.java in  » ERP-CRM-Financial » SourceTap-CRM » org » ofbiz » content » widget » 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 » ERP CRM Financial » SourceTap CRM » org.ofbiz.content.widget.html 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:         * $Id: HtmlFormWrapper.java,v 1.4 2004/02/28 21:03:24 jonesde Exp $
003:         *
004:         * Copyright (c) 2003 The Open For Business Project - www.ofbiz.org
005:         *
006:         * Permission is hereby granted, free of charge, to any person obtaining a
007:         * copy of this software and associated documentation files (the "Software"),
008:         * to deal in the Software without restriction, including without limitation
009:         * the rights to use, copy, modify, merge, publish, distribute, sublicense,
010:         * and/or sell copies of the Software, and to permit persons to whom the
011:         * Software is furnished to do so, subject to the following conditions:
012:         *
013:         * The above copyright notice and this permission notice shall be included
014:         * in all copies or substantial portions of the Software.
015:         *
016:         * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
017:         * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
018:         * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
019:         * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
020:         * CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT
021:         * OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
022:         * THE USE OR OTHER DEALINGS IN THE SOFTWARE.
023:         */
024:        package org.ofbiz.content.widget.html;
025:
026:        import java.io.IOException;
027:        import java.util.HashMap;
028:        import java.util.Map;
029:
030:        import javax.servlet.http.HttpServletRequest;
031:        import javax.servlet.http.HttpServletResponse;
032:        import javax.xml.parsers.ParserConfigurationException;
033:
034:        import org.ofbiz.base.util.UtilHttp;
035:        import org.ofbiz.base.util.UtilValidate;
036:        import org.ofbiz.content.widget.form.FormFactory;
037:        import org.ofbiz.content.widget.form.FormStringRenderer;
038:        import org.ofbiz.content.widget.form.ModelForm;
039:        import org.xml.sax.SAXException;
040:
041:        /**
042:         * Widget Library - HTML Form Wrapper class - makes it easy to do the setup and render of a form
043:         *
044:         * @author     <a href="mailto:jonesde@ofbiz.org">David E. Jones</a>
045:         * @version    $Revision: 1.4 $
046:         * @since      2.2
047:         */
048:        public class HtmlFormWrapper {
049:
050:            public static final String module = HtmlFormWrapper.class.getName();
051:
052:            protected String resourceName;
053:            protected String formName;
054:            protected HttpServletRequest request;
055:            protected HttpServletResponse response;
056:            protected ModelForm modelForm;
057:            protected FormStringRenderer renderer;
058:            protected Map context;
059:
060:            protected HtmlFormWrapper() {
061:            }
062:
063:            public HtmlFormWrapper(String resourceName, String formName,
064:                    HttpServletRequest request, HttpServletResponse response)
065:                    throws IOException, SAXException,
066:                    ParserConfigurationException {
067:                this .resourceName = resourceName;
068:                this .formName = formName;
069:                this .request = request;
070:                this .response = response;
071:
072:                this .modelForm = FormFactory.getFormFromWebappContext(
073:                        resourceName, formName, request);
074:
075:                this .renderer = new HtmlFormRenderer(request, response);
076:
077:                this .context = new HashMap();
078:                Map parameterMap = UtilHttp.getParameterMap(request);
079:                context.put("parameters", parameterMap);
080:
081:                //make sure the locale is in the context
082:                context.put("locale", UtilHttp.getLocale(request));
083:
084:                // if there was an error message, this is an error
085:                if (UtilValidate.isNotEmpty((String) request
086:                        .getAttribute("_ERROR_MESSAGE_"))) {
087:                    context.put("isError", Boolean.TRUE);
088:                } else {
089:                    context.put("isError", Boolean.FALSE);
090:                }
091:
092:                // if a parameter was passed saying this is an error, it is an error
093:                if ("true".equals((String) parameterMap.get("isError"))) {
094:                    context.put("isError", Boolean.TRUE);
095:                }
096:            }
097:
098:            public String renderFormString() {
099:                StringBuffer buffer = new StringBuffer();
100:                modelForm.renderFormString(buffer, context, renderer);
101:                return buffer.toString();
102:            }
103:
104:            /** 
105:             * Tells the form library whether this is a response to an error or not.
106:             * Defaults on initialization according to the presense of an errorMessage
107:             * in the request or if an isError parameter was passed to the page with 
108:             * the value "true". If true then the prefilled values will come from the
109:             * parameters Map instead of the value Map. 
110:             */
111:            public void setIsError(boolean isError) {
112:                this .context.put("isError", new Boolean(isError));
113:            }
114:
115:            public boolean getIsError() {
116:                Boolean isErrorBoolean = (Boolean) this .context.get("isError");
117:                if (isErrorBoolean == null) {
118:                    return false;
119:                } else {
120:                    return isErrorBoolean.booleanValue();
121:                }
122:            }
123:
124:            /**
125:             * The "useRequestParameters" value in the form context tells the form library
126:             * to use the request parameters to fill in values instead of the value map.
127:             * This is generally used when it is an empty form to pre-set inital values.
128:             * This is automatically set to false for list and multi forms. For related
129:             * functionality see the setIsError method.
130:             * 
131:             * @param useRequestParameters
132:             */
133:            public void setUseRequestParameters(boolean useRequestParameters) {
134:                this .context.put("useRequestParameters", new Boolean(
135:                        useRequestParameters));
136:            }
137:
138:            public boolean getUseRequestParameters() {
139:                Boolean useRequestParametersBoolean = (Boolean) this .context
140:                        .get("useRequestParameters");
141:                if (useRequestParametersBoolean == null) {
142:                    return false;
143:                } else {
144:                    return useRequestParametersBoolean.booleanValue();
145:                }
146:            }
147:
148:            public void setFormOverrideName(String formName) {
149:                this .context.put("formName", formName);
150:            }
151:
152:            public void putInContext(String name, Object value) {
153:                this .context.put(name, value);
154:            }
155:
156:            public Object getFromContext(String name) {
157:                return this .context.get(name);
158:            }
159:
160:            public ModelForm getModelForm() {
161:                return modelForm;
162:            }
163:
164:            public FormStringRenderer getRenderer() {
165:                return renderer;
166:            }
167:
168:            public void setRenderer(FormStringRenderer renderer) {
169:                this.renderer = renderer;
170:            }
171:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.