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