Source Code Cross Referenced for FormOutput.java in  » Wiki-Engine » JSPWiki » com » ecyrd » jspwiki » forms » 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 » Wiki Engine » JSPWiki » com.ecyrd.jspwiki.forms 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


001:        /*
002:            WikiForms - a WikiPage FORM handler for JSPWiki.
003:         
004:            Copyright (C) 2003 BaseN. 
005:
006:            JSPWiki Copyright (C) 2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
007:
008:            This program is free software; you can redistribute it and/or modify
009:            it under the terms of the GNU Lesser General Public License as published
010:            by the Free Software Foundation; either version 2.1 of the License, or
011:            (at your option) any later version.
012:         
013:            This program is distributed in the hope that it will be useful,
014:            but WITHOUT ANY WARRANTY; without even the implied warranty of
015:            MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
016:            GNU Lesser General Public License for more details.
017:         
018:            You should have received a copy of the GNU Lesser General Public License
019:            along with this program; if not, write to the Free Software
020:         */
021:        package com.ecyrd.jspwiki.forms;
022:
023:        import java.text.MessageFormat;
024:        import java.util.Map;
025:        import java.util.ResourceBundle;
026:
027:        import com.ecyrd.jspwiki.WikiContext;
028:        import com.ecyrd.jspwiki.plugin.PluginException;
029:        import com.ecyrd.jspwiki.plugin.PluginManager;
030:        import com.ecyrd.jspwiki.plugin.WikiPlugin;
031:        import com.ecyrd.jspwiki.util.FormUtil;
032:
033:        /**
034:         */
035:        public class FormOutput extends FormElement {
036:            /**
037:             * Executes the FormHandler specified in a Form 'output' plugin,
038:             * using entries provided in the HttpRequest as FormHandler
039:             * parameters.
040:             * <p>
041:             * If the parameter 'populate' was given, the WikiPlugin it names
042:             * is used to get default values. (It probably makes a lot of
043:             * sense for this to be the same plugin as the handler.) 
044:             * Information for the populator can be given with the FormSet
045:             * plugin. If 'populate' is not specified, the form is not
046:             * displayed.
047:             * <p>
048:             * Should there be no HTTP request associated with this request,
049:             * the method will return immediately with an empty string.
050:             */
051:            public String execute(WikiContext ctx, Map params)
052:                    throws PluginException {
053:                //
054:                //  If there is no HTTP request, returns immediately.
055:                //
056:                if (ctx.getHttpRequest() == null) {
057:                    return "";
058:                }
059:                ResourceBundle rb = ctx
060:                        .getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
061:
062:                // If we are NOT here due to this form being submitted, we do nothing.
063:                // The submitted form MUST have parameter 'formname' equal to the name
064:                // parameter of this Form plugin.
065:
066:                String formName = (String) params.get(PARAM_FORM);
067:                String submitForm = ctx.getHttpParameter(PARAM_FORMNAMEHIDDEN);
068:                String populator = (String) params.get(PARAM_POPULATE);
069:
070:                if (submitForm == null || formName == null
071:                        || !formName.equals(submitForm)) {
072:                    // No submitForm -> this was not a submission from the
073:                    // generated form.  If populate is specified, we'll go
074:                    // ahead and let the handler (populator) put stuff into
075:                    // the context, otherwise we'll just hide.
076:                    if (populator == null || !PARAM_HANDLER.equals(populator))
077:                        return "";
078:                    // If population was allowed, we should first  
079:                }
080:
081:                String handler = (String) params.get(PARAM_HANDLER);
082:                if (handler == null || handler.length() == 0) {
083:                    Object[] args = { PARAM_HANDLER };
084:                    // Need to print out an error here as this form is misconfigured
085:                    return "<p class=\"error\">"
086:                            + MessageFormat.format(rb
087:                                    .getString("formoutput.missingargument"),
088:                                    args) + "</p>";
089:                }
090:
091:                String sourcePage = ctx.getPage().getName();
092:                String submitServlet = ctx.getURL(WikiContext.VIEW, sourcePage);
093:
094:                // If there is previous FormInfo available - say, from a
095:                // FormSet plugin - use it.
096:                FormInfo info = getFormInfo(ctx);
097:                if (info == null) {
098:                    // Reconstruct the form info from post data
099:                    info = new FormInfo();
100:                    info.setName(formName);
101:                }
102:                // Force override of handler and submit.
103:                info.setHandler(handler);
104:                info.setAction(submitServlet);
105:
106:                // Sift out all extra parameters, leaving only those submitted
107:                // in the HTML FORM.
108:                Map handlerParams = FormUtil.requestToMap(ctx.getHttpRequest(),
109:                        HANDLERPARAM_PREFIX);
110:                // Previous submission info may be available from FormSet
111:                // plugin - add, don't replace.
112:                info.addSubmission(handlerParams);
113:
114:                // Pass the _body parameter from FormOutput on to the handler
115:                info.getSubmission().put(PluginManager.PARAM_BODY,
116:                        params.get(PluginManager.PARAM_BODY));
117:
118:                String handlerOutput = null;
119:                String error = null;
120:                try {
121:                    // The plugin _can_ modify the parameters, so we make sure
122:                    // they stay with us.
123:                    handlerOutput = ctx.getEngine().getPluginManager().execute(
124:                            ctx, handler, info.getSubmission());
125:                    info.setResult(handlerOutput);
126:                    info.setStatus(FormInfo.EXECUTED);
127:                } catch (PluginException pe) {
128:                    error = "<p class=\"error\">" + pe.getMessage() + "</p>";
129:                    info.setError(error);
130:                    info.setStatus(FormInfo.ERROR);
131:                }
132:
133:                // We store the forminfo, so following Form plugin invocations on this
134:                // page can decide what to do based on its values.
135:                storeFormInfo(ctx, info);
136:
137:                if (error != null)
138:                    return error;
139:
140:                return handlerOutput != null ? handlerOutput : "";
141:            }
142:
143:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.