1
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 import com.liferay.portal.kernel.util.Validator;
22
23 import java.util.List;
24
25 import javax.portlet.PortletURL;
26
27 import javax.servlet.jsp.JspException;
28 import javax.servlet.jsp.JspTagException;
29
30
36 public class SearchContainerColumnButtonTag extends SearchContainerColumnTag {
37
38 public int doEndTag() {
39 try {
40 SearchContainerRowTag parentTag =
41 (SearchContainerRowTag)findAncestorWithClass(
42 this, SearchContainerRowTag.class);
43
44 ResultRow row = parentTag.getRow();
45
46 if (index <= -1) {
47 index = row.getEntries().size();
48 }
49
50 row.addButton(
51 index, getAlign(), getValign(), getColspan(), getName(),
52 (String)getHref());
53
54 return EVAL_PAGE;
55 }
56 finally {
57 if (!ServerDetector.isResin()) {
58 align = SearchEntry.DEFAULT_ALIGN;
59 colspan = SearchEntry.DEFAULT_COLSPAN;
60 _href = null;
61 index = -1;
62 name = StringPool.BLANK;
63 valign = SearchEntry.DEFAULT_VALIGN;
64 }
65 }
66 }
67
68 public int doStartTag() throws JspException {
69 SearchContainerRowTag parentRowTag =
70 (SearchContainerRowTag)findAncestorWithClass(
71 this, SearchContainerRowTag.class);
72
73 if (parentRowTag == null) {
74 throw new JspTagException(
75 "Requires liferay-ui:search-container-row");
76 }
77
78 if (!parentRowTag.isHeaderNamesAssigned()) {
79 List<String> headerNames = parentRowTag.getHeaderNames();
80
81 headerNames.add(StringPool.BLANK);
82 }
83
84 return EVAL_BODY_INCLUDE;
85 }
86
87 public Object getHref() {
88 if (Validator.isNotNull(_href) && (_href instanceof PortletURL)) {
89 _href = _href.toString();
90 }
91
92 return _href;
93 }
94
95 public void setHref(Object href) {
96 _href = href;
97 }
98
99 private Object _href;
100
101 }