PageRenderTime 11ms CodeModel.GetById 2ms app.highlight 5ms RepoModel.GetById 2ms app.codeStats 0ms

/src/main/java/com/googlecode/struts2yuiplugin/components/ClosingYUIBean.java

http://struts2yuiplugin.googlecode.com/
Java | 46 lines | 31 code | 11 blank | 4 comment | 0 complexity | 826b5bf4c678063b1d0cd3d9a03932aa MD5 | raw file
 1package com.googlecode.struts2yuiplugin.components;
 2
 3import org.apache.struts2.views.annotations.StrutsTagAttribute;
 4import org.apache.commons.logging.Log;
 5import org.apache.commons.logging.LogFactory;
 6import com.opensymphony.xwork2.util.ValueStack;
 7
 8import javax.servlet.http.HttpServletRequest;
 9import javax.servlet.http.HttpServletResponse;
10import java.io.Writer;
11
12/**
13 * A specialization of the YUI Bean that handles open and closing tag templates
14 *
15 */
16public abstract class ClosingYUIBean extends YUIBean {
17
18    private static final Log LOG = LogFactory.getLog(ClosingYUIBean.class);
19
20    public ClosingYUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
21        super(stack, request, response);
22    }
23
24    private String openTemplate;
25
26    public abstract String getDefaultOpenTemplate();
27
28    @StrutsTagAttribute(description="Set template to use for opening the rendered html.")
29    public void setOpenTemplate(String openTemplate) {
30        this.openTemplate = openTemplate;
31    }
32
33    public boolean start(Writer writer) {
34        boolean result = super.start(writer);
35        try {
36            evaluateParams();
37
38            mergeTemplate(writer, buildTemplateName(openTemplate, getDefaultOpenTemplate()));
39        } catch (Exception e) {
40            LOG.error("Could not open template", e);
41            e.printStackTrace();
42        }
43
44        return result;
45    }
46}