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.basic;
16:
17: import java.io.Writer;
18: import org.araneaframework.framework.OverlayContext;
19: import org.araneaframework.http.util.JsonObject;
20: import org.araneaframework.jsp.tag.BaseTag;
21: import org.araneaframework.jsp.util.JspUtil;
22:
23: /**
24: * @author Alar Kvell (alar@araneaframework.org)
25: * @since 1.1
26: *
27: * @jsp.tag
28: * name = "registerOverlay"
29: * body-content = "empty"
30: * description = "TODO"
31: */
32: public class OverlayRegistrationHtmlTag extends BaseTag {
33: protected int doEndTag(Writer out) throws Exception {
34: OverlayContext overlayCtx = (OverlayContext) getEnvironment()
35: .requireEntry(OverlayContext.class);
36:
37: if (overlayCtx.isOverlayActive()) {
38: JspUtil.writeOpenStartTag(out, "script");
39: JspUtil.writeAttribute(out, "type", "text/javascript");
40: JspUtil.writeCloseStartTag(out);
41: out.write("Aranea.ModalBox.Options = "
42: + getOverlayOptions(overlayCtx) + ";");
43: out
44: .write("_ap.addClientLoadEvent(function() { Aranea.ModalBox.show(Aranea.ModalBox.Options);});\n");
45: JspUtil.writeEndTag(out, "script");
46: }
47:
48: return super .doEndTag(out);
49: }
50:
51: protected JsonObject getOverlayOptions(OverlayContext overlayContext) {
52: return new JsonObject(overlayContext.getOverlayOptions());
53: }
54: }
|