01: /*
02: * $Id: ClosingUIBean.java 497654 2007-01-19 00:21:57Z rgielen $
03: *
04: * Licensed to the Apache Software Foundation (ASF) under one
05: * or more contributor license agreements. See the NOTICE file
06: * distributed with this work for additional information
07: * regarding copyright ownership. The ASF licenses this file
08: * to you under the Apache License, Version 2.0 (the
09: * "License"); you may not use this file except in compliance
10: * with the License. You may obtain a copy of the License at
11: *
12: * http://www.apache.org/licenses/LICENSE-2.0
13: *
14: * Unless required by applicable law or agreed to in writing,
15: * software distributed under the License is distributed on an
16: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
17: * KIND, either express or implied. See the License for the
18: * specific language governing permissions and limitations
19: * under the License.
20: */
21: package org.apache.struts2.components;
22:
23: import java.io.Writer;
24:
25: import javax.servlet.http.HttpServletRequest;
26: import javax.servlet.http.HttpServletResponse;
27:
28: import org.apache.commons.logging.Log;
29: import org.apache.commons.logging.LogFactory;
30: import org.apache.struts2.views.annotations.StrutsTagAttribute;
31:
32: import com.opensymphony.xwork2.util.ValueStack;
33:
34: /**
35: * ClosingUIBean is the standard superclass for UI components such as div etc.
36: */
37: public abstract class ClosingUIBean extends UIBean {
38: private static final Log LOG = LogFactory
39: .getLog(ClosingUIBean.class);
40:
41: protected ClosingUIBean(ValueStack stack,
42: HttpServletRequest request, HttpServletResponse response) {
43: super (stack, request, response);
44: }
45:
46: String openTemplate;
47:
48: public abstract String getDefaultOpenTemplate();
49:
50: @StrutsTagAttribute(description="Set template to use for opening the rendered html.")
51: public void setOpenTemplate(String openTemplate) {
52: this .openTemplate = openTemplate;
53: }
54:
55: public boolean start(Writer writer) {
56: boolean result = super .start(writer);
57: try {
58: evaluateParams();
59:
60: mergeTemplate(writer, buildTemplateName(openTemplate,
61: getDefaultOpenTemplate()));
62: } catch (Exception e) {
63: LOG.error("Could not open template", e);
64: e.printStackTrace();
65: }
66:
67: return result;
68: }
69: }
|