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.ui;
16  
17  import com.liferay.portal.kernel.dao.search.ResultRow;
18  import com.liferay.portal.kernel.dao.search.SearchEntry;
19  import com.liferay.portal.kernel.util.ServerDetector;
20  import com.liferay.portal.kernel.util.StringPool;
21  
22  import java.util.List;
23  
24  import javax.servlet.jsp.JspException;
25  import javax.servlet.jsp.JspTagException;
26  
27  /**
28   * <a href="SearchContainerColumnJSPTag.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Raymond Augé
31   */
32  public class SearchContainerColumnJSPTag extends SearchContainerColumnTag {
33  
34      public int doEndTag() {
35          try {
36              SearchContainerRowTag parentTag =
37                  (SearchContainerRowTag)findAncestorWithClass(
38                      this, SearchContainerRowTag.class);
39  
40              ResultRow row = parentTag.getRow();
41  
42              if (index <= -1) {
43                  index = row.getEntries().size();
44              }
45  
46              row.addJSP(
47                  index, getAlign(), getValign(), getColspan(), getPath(),
48                  pageContext.getServletContext(), getServletRequest(),
49                  getServletResponse());
50  
51              return EVAL_PAGE;
52          }
53          finally {
54              if (!ServerDetector.isResin()) {
55                  align = SearchEntry.DEFAULT_ALIGN;
56                  colspan = SearchEntry.DEFAULT_COLSPAN;
57                  index = -1;
58                  name = StringPool.BLANK;
59                  _path = null;
60                  valign = SearchEntry.DEFAULT_VALIGN;
61              }
62          }
63      }
64  
65      public int doStartTag() throws JspException {
66          SearchContainerRowTag parentRowTag =
67              (SearchContainerRowTag)findAncestorWithClass(
68                  this, SearchContainerRowTag.class);
69  
70          if (parentRowTag == null) {
71              throw new JspTagException(
72                  "Requires liferay-ui:search-container-row");
73          }
74  
75          if (!parentRowTag.isHeaderNamesAssigned()) {
76              List<String> headerNames = parentRowTag.getHeaderNames();
77  
78              headerNames.add(name);
79          }
80  
81          return EVAL_BODY_INCLUDE;
82      }
83  
84      public String getPath() {
85          return _path;
86      }
87  
88      public void setPath(String path) {
89          _path = path;
90      }
91  
92      private String _path;
93  
94  }