01: /*
02: WikiForms - a WikiPage FORM handler for JSPWiki.
03:
04: Copyright (C) 2003 BaseN.
05:
06: JSPWiki Copyright (C) 2002 Janne Jalkanen (Janne.Jalkanen@iki.fi)
07:
08: This program is free software; you can redistribute it and/or modify
09: it under the terms of the GNU Lesser General Public License as published
10: by the Free Software Foundation; either version 2.1 of the License, or
11: (at your option) any later version.
12:
13: This program is distributed in the hope that it will be useful,
14: but WITHOUT ANY WARRANTY; without even the implied warranty of
15: MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16: GNU Lesser General Public License for more details.
17:
18: You should have received a copy of the GNU Lesser General Public License
19: along with this program; if not, write to the Free Software
20: */
21: package com.ecyrd.jspwiki.forms;
22:
23: import com.ecyrd.jspwiki.*;
24: import com.ecyrd.jspwiki.plugin.PluginException;
25: import com.ecyrd.jspwiki.plugin.WikiPlugin;
26:
27: import java.util.*;
28:
29: /**
30: * Closes a WikiForm.
31: *
32: * @author ebu
33: */
34: public class FormClose extends FormElement {
35: /**
36: * Builds a Form close tag. Removes any information on the form from
37: * the WikiContext.
38: */
39: public String execute(WikiContext ctx, Map params)
40: throws PluginException {
41: StringBuffer tags = new StringBuffer();
42: tags.append("</form>\n");
43: tags.append("</div>");
44:
45: // Don't render if no error and error-only-rendering is on.
46: FormInfo info = getFormInfo(ctx);
47: if (info != null) {
48: if (info.hide()) {
49: ResourceBundle rb = ctx
50: .getBundle(WikiPlugin.CORE_PLUGINS_RESOURCEBUNDLE);
51: return ("<p>" + rb.getString("formclose.noneedtoshow") + "</p>");
52: }
53: }
54:
55: // Get rid of remaining form data, so it doesn't mess up other forms.
56: // After this, it is safe to add other Forms.
57: storeFormInfo(ctx, null);
58:
59: return tags.toString();
60:
61: }
62: }
|