Source Code Cross Referenced for FormOpen.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.WikiPlugin;
030:
031:        /**
032:         *  Opens a WikiForm.
033:         *
034:         * Builds the HTML code for opening a FORM.
035:         *
036:         * <p>Since we're only providing an opening FORM tag, we can't use
037:         * the ECS utilities.
038:         *
039:         * A Form plugin line that produces one looks like this:
040:         * <p><pre>
041:         *   [{FormOpen name='formname' handler='pluginname'
042:         *          submit='submitservlet'
043:         *          show='always'
044:         *   }]
045:         * </pre>
046:         *
047:         * <p>Mandatory parameters:
048:         * <br>The <i>name</i> field identifies this particular form to the
049:         * Form plugin across pages.
050:         * <br>The <i>handler</i> field is a WikiPlugin name; it will be
051:         * invoked with the form field values.
052:         *
053:         * <p>Optional parameters:
054:         * <p>The submitservlet is the name of a JSP/servlet capable of
055:         * handling the input from this form. It is optional; the default
056:         * value is the current page (which can handle the input by using
057:         * this Plugin.)
058:         *
059:         * <p>The <i>hide</i> parameter affects the visibility of this
060:         * form. If left out, the form is always shown. If set to
061:         * 'onsuccess', the form is not shown if it was submitted
062:         * successfully. (Note that a reload of the page would cause the
063:         * context to reset, and the form would be shown again. This may
064:         * be a useless option.)
065:         *
066:         *  @author ebu
067:         */
068:        public class FormOpen extends FormElement {
069:            private static org.apache.log4j.Logger log = org.apache.log4j.Logger
070:                    .getLogger(FormOpen.class);
071:
072:            public static final String PARAM_METHOD = "method";
073:
074:            /**
075:             */
076:            public String execute(WikiContext ctx, Map params)
077:                    throws PluginException {
078:                ResourceBundle rb = ctx
079:                        .getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
080:                String formName = (String) params.get(PARAM_FORM);
081:                if (formName == null) {
082:                    Object[] args = { PARAM_FORM };
083:                    throw new PluginException(MessageFormat.format(rb
084:                            .getString("formopen.missingparam"), args));
085:                }
086:                String hide = (String) params.get(PARAM_HIDEFORM);
087:                String sourcePage = ctx.getPage().getName();
088:                String submitServlet = (String) params.get(PARAM_SUBMITHANDLER);
089:                if (submitServlet == null)
090:                    submitServlet = ctx.getURL(WikiContext.VIEW, sourcePage);
091:
092:                String method = (String) params.get(PARAM_METHOD);
093:                if (method == null)
094:                    method = "post";
095:
096:                if (!(method.equalsIgnoreCase("get") || method
097:                        .equalsIgnoreCase("post"))) {
098:                    throw new PluginException(rb
099:                            .getString("formopen.postorgetonly"));
100:                }
101:
102:                FormInfo info = getFormInfo(ctx);
103:                if (info != null) {
104:                    // Previous information may be the result of submitting
105:                    // this form, or of a FormSet plugin, or both. If it
106:                    // exists and is for this form, fine.
107:                    if (formName.equals(info.getName())) {
108:                        log
109:                                .debug("Previous FormInfo for this form was found in context.");
110:                        // If the FormInfo exists, and if we're supposed to display on
111:                        // error only, we need to exit now.
112:                        if (hide != null && HIDE_SUCCESS.equals(hide)
113:                                && info.getStatus() == FormInfo.EXECUTED) {
114:                            info.setHide(true);
115:                            return ("<p>"
116:                                    + rb.getString("formopen.noneedtoshow") + "</p>");
117:                        }
118:                    } else {
119:                        // This would mean that a new form was started without
120:                        // closing an old one.  Get rid of the garbage.
121:                        info = new FormInfo();
122:                    }
123:                } else {
124:                    // No previous FormInfo available; store now, so it'll be
125:                    // available for upcoming Form input elements.
126:                    info = new FormInfo();
127:                    storeFormInfo(ctx, info);
128:                }
129:
130:                info.setName(formName);
131:                info.setAction(submitServlet);
132:
133:                StringBuffer tag = new StringBuffer(40);
134:                tag.append("<div class=\"wikiform\">\n");
135:                tag.append("<form action=\"" + submitServlet);
136:                tag.append("\" name=\"" + formName);
137:                tag.append("\" accept-charset=\""
138:                        + ctx.getEngine().getContentEncoding());
139:                tag
140:                        .append("\" method=\""
141:                                + method
142:                                + "\" enctype=\"application/x-www-form-urlencoded\">\n");
143:                tag.append("  <input type=\"hidden\" name=\""
144:                        + PARAM_FORMNAMEHIDDEN);
145:                tag.append("\" value=\"" + formName + "\"/>\n");
146:
147:                return tag.toString();
148:            }
149:
150:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.