1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.taglib.aui;
16  
17  import com.liferay.portal.kernel.servlet.PortalIncludeUtil;
18  import com.liferay.portal.kernel.util.ServerDetector;
19  import com.liferay.portal.kernel.util.Validator;
20  import com.liferay.taglib.util.IncludeTag;
21  
22  import java.util.HashMap;
23  import java.util.Map;
24  
25  import javax.servlet.http.HttpServletRequest;
26  import javax.servlet.jsp.JspException;
27  import javax.servlet.jsp.tagext.DynamicAttributes;
28  
29  /**
30   * <a href="ButtonRowTag.java.html"><b><i>View Source</i></b></a>
31   *
32   * @author Julio Camarero
33   * @author Jorge Ferrer
34   * @author Brian Wing Shun Chan
35   */
36  public class ButtonRowTag extends IncludeTag implements DynamicAttributes {
37  
38      public int doEndTag() throws JspException {
39          try{
40              PortalIncludeUtil.include(pageContext, getEndPage());
41  
42              return EVAL_PAGE;
43          }
44          catch (Exception e) {
45              throw new JspException(e);
46          }
47          finally {
48              if (!ServerDetector.isResin()) {
49                  _cssClass = null;
50                  _dynamicAttributes.clear();
51                  _endPage = null;
52                  _startPage = null;
53              }
54          }
55      }
56  
57      public int doStartTag() throws JspException {
58          try{
59              HttpServletRequest request =
60                  (HttpServletRequest)pageContext.getRequest();
61  
62              request.setAttribute("aui:button-row:cssClass", _cssClass);
63              request.setAttribute(
64                  "aui:button-row:dynamicAttributes", _dynamicAttributes);
65  
66              PortalIncludeUtil.include(pageContext, getStartPage());
67  
68              return EVAL_BODY_INCLUDE;
69          }
70          catch (Exception e) {
71              throw new JspException(e);
72          }
73      }
74  
75      public String getEndPage() {
76          if (Validator.isNull(_endPage)) {
77              return _END_PAGE;
78          }
79          else {
80              return _endPage;
81          }
82      }
83  
84      public String getStartPage() {
85          if (Validator.isNull(_startPage)) {
86              return _START_PAGE;
87          }
88          else {
89              return _startPage;
90          }
91      }
92  
93      public void setCssClass(String cssClass) {
94          _cssClass = cssClass;
95      }
96  
97      public void setDynamicAttribute(
98          String uri, String localName, Object value) {
99  
100         _dynamicAttributes.put(localName, value);
101     }
102 
103     public void setEndPage(String endPage) {
104         _endPage = endPage;
105     }
106 
107     public void setStartPage(String startPage) {
108         _startPage = startPage;
109     }
110 
111     private static final String _END_PAGE =
112         "/html/taglib/aui/button_row/end.jsp";
113 
114     private static final String _START_PAGE =
115         "/html/taglib/aui/button_row/start.jsp";
116 
117     private String _cssClass;
118     private Map<String, Object> _dynamicAttributes =
119         new HashMap<String, Object>();
120     private String _endPage;
121     private String _startPage;
122 
123 }