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.updateregion;
16:
17: import java.io.Writer;
18: import javax.servlet.jsp.JspException;
19: import org.araneaframework.core.ApplicationWidget;
20: import org.araneaframework.http.UpdateRegionContext;
21: import org.araneaframework.http.util.ServletUtil;
22: import org.araneaframework.jsp.exception.AraneaJspException;
23: import org.araneaframework.jsp.tag.BaseTag;
24: import org.araneaframework.jsp.util.JspUtil;
25:
26: /**
27: * Base tag for tags that allow defining updatable regions within HTML page.
28: *
29: * @see org.araneaframework.jsp.tag.updateregion.UpdateRegionHtmlTag
30: * @see org.araneaframework.jsp.tag.updateregion.UpdateRegionRowsHtmlTag
31: *
32: * @author Jevgeni Kabanov (ekabanov <i>at</i> araneaframework <i>dot</i> org)
33: */
34: public class BaseUpdateRegionTag extends BaseTag {
35: protected String id;
36: protected String globalId;
37:
38: protected String fullId;
39:
40: protected int doStartTag(Writer out) throws Exception {
41: super .doStartTag(out);
42:
43: if (id == null && globalId == null)
44: throw new AraneaJspException(
45: "'id' or 'globalId' is required!");
46:
47: String contextWidgetId = getContextWidgetFullId();
48:
49: fullId = globalId;
50:
51: if (fullId == null)
52: fullId = contextWidgetId.length() > 0 ? (contextWidgetId
53: + "." + id) : id;
54:
55: String uiWidgetId = ((ApplicationWidget) JspUtil
56: .requireContextEntry(pageContext,
57: ServletUtil.UIWIDGET_KEY)).getScope()
58: .toString();
59: UpdateRegionContext updateRegionContext = (UpdateRegionContext) getEnvironment()
60: .requireEntry(UpdateRegionContext.class);
61: updateRegionContext.addDocumentRegion(fullId, uiWidgetId);
62:
63: return EVAL_BODY_INCLUDE;
64: }
65:
66: /**
67: * @jsp.attribute
68: * type = "java.lang.String"
69: * required = "false"
70: * description = "Local id of the update region."
71: */
72: public void setId(String id) throws JspException {
73: this .id = (String) evaluate("id", id, String.class);
74: }
75:
76: /**
77: * @jsp.attribute
78: * type = "java.lang.String"
79: * required = "false"
80: * description = "Global id of the update region."
81: */
82: public void setGlobalId(String globalId) throws JspException {
83: this .globalId = (String) evaluate("globalId", globalId,
84: String.class);
85: }
86: }
|