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