1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   *
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<R> extends SearchContainerColumnTag {
33  
34      public int doEndTag() {
35          try {
36              SearchContainerRowTag<R> parentTag =
37                  (SearchContainerRowTag<R>)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<R> parentRowTag =
67              (SearchContainerRowTag<R>)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  }