01: /**
02: * Copyright 2006 Webmedia Group Ltd.
03: *
04: * Licensed under the Apache License, Version 2.0 (the "License");
05: * you may not use this file except in compliance with the License.
06: * You may obtain a copy of the License at
07: *
08: * http://www.apache.org/licenses/LICENSE-2.0
09: *
10: * Unless required by applicable law or agreed to in writing, software
11: * distributed under the License is distributed on an "AS IS" BASIS,
12: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13: * See the License for the specific language governing permissions and
14: * limitations under the License.
15: **/package org.araneaframework.jsp.tag.form;
16:
17: import java.io.Writer;
18: import java.util.Iterator;
19: import java.util.Map;
20: import javax.servlet.jsp.JspException;
21: import org.araneaframework.core.ApplicationWidget;
22: import org.araneaframework.framework.OverlayContext;
23: import org.araneaframework.framework.SystemFormContext;
24: import org.araneaframework.framework.OverlayContext.OverlayActivityMarkerContext;
25: import org.araneaframework.http.HttpInputData;
26: import org.araneaframework.http.JspContext;
27: import org.araneaframework.jsp.util.JspUtil;
28:
29: /**
30: * System form tag. System form maps into HTML form.
31: * Canonical use in Aranea - surrounding all body elements.
32: *
33: * @author Oleg Mürk
34: *
35: * @jsp.tag
36: * name = "systemForm"
37: * description = "Puts an HTML <i>form</i> tag with parameters needed by Aranea."
38: */
39: public class AraneaSystemFormHtmlTag extends BaseSystemFormHtmlTag {
40: private JspContext config;
41:
42: protected int doStartTag(Writer out) throws Exception {
43: config = (JspContext) getEnvironment().requireEntry(
44: JspContext.class);
45:
46: super .doStartTag(out);
47:
48: // Hidden fields: preset
49: SystemFormContext systemFormContext = (SystemFormContext) getEnvironment()
50: .requireEntry(SystemFormContext.class);
51: for (Iterator i = systemFormContext.getFields().entrySet()
52: .iterator(); i.hasNext();) {
53: Map.Entry entry = (Map.Entry) i.next();
54: JspUtil.writeHiddenInputElement(out, (String) entry
55: .getKey(), (String) entry.getValue());
56: }
57:
58: // Hidden fields: to be set
59: JspUtil.writeHiddenInputElement(out,
60: ApplicationWidget.EVENT_HANDLER_ID_KEY, "");
61: JspUtil.writeHiddenInputElement(out,
62: ApplicationWidget.EVENT_PATH_KEY, "");
63: JspUtil.writeHiddenInputElement(out,
64: ApplicationWidget.EVENT_PARAMETER_KEY, "");
65:
66: // if overlay is active, set the empty field which denotes that systemform is running in overlay
67: OverlayActivityMarkerContext oCtx = (OverlayActivityMarkerContext) getEnvironment()
68: .getEntry(OverlayActivityMarkerContext.class);
69: if (oCtx != null) {
70: JspUtil.writeHiddenInputElement(out,
71: OverlayContext.OVERLAY_REQUEST_KEY, "");
72: }
73:
74: // Continue
75: return EVAL_BODY_INCLUDE;
76: }
77:
78: /* ***********************************************************************************
79: * Implementation of SystemForm abstract methods
80: * ***********************************************************************************/
81:
82: protected String getAcceptCharset() {
83: return config.getSubmitCharset();
84: }
85:
86: protected String getFormAction() throws JspException {
87: return ((HttpInputData) getOutputData().getInputData())
88: .getContainerURL();
89: }
90: }
|