Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » components » [javadoc | source]
    1   /*
    2    * $Id: ClosingUIBean.java 497654 2007-01-19 00:21:57Z rgielen $
    3    *
    4    * Licensed to the Apache Software Foundation (ASF) under one
    5    * or more contributor license agreements.  See the NOTICE file
    6    * distributed with this work for additional information
    7    * regarding copyright ownership.  The ASF licenses this file
    8    * to you under the Apache License, Version 2.0 (the
    9    * "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.getLog(ClosingUIBean.class);
   39   
   40       protected ClosingUIBean(ValueStack stack, HttpServletRequest request, HttpServletResponse response) {
   41           super(stack, request, response);
   42       }
   43   
   44       String openTemplate;
   45   
   46       public abstract String getDefaultOpenTemplate();
   47   
   48       @StrutsTagAttribute(description="Set template to use for opening the rendered html.")
   49       public void setOpenTemplate(String openTemplate) {
   50           this.openTemplate = openTemplate;
   51       }
   52   
   53       public boolean start(Writer writer) {
   54           boolean result = super.start(writer);
   55           try {
   56               evaluateParams();
   57   
   58               mergeTemplate(writer, buildTemplateName(openTemplate, getDefaultOpenTemplate()));
   59           } catch (Exception e) {
   60               LOG.error("Could not open template", e);
   61               e.printStackTrace();
   62           }
   63   
   64           return result;
   65       }
   66   }

Save This Page
Home » struts-2.0.11.2-src » org.apache » struts2 » components » [javadoc | source]