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.StringPool;
20 import com.liferay.portal.kernel.util.Validator;
21
22 import java.util.List;
23
24 import javax.portlet.PortletURL;
25
26 import javax.servlet.jsp.JspException;
27 import javax.servlet.jsp.JspTagException;
28
29
35 public class SearchContainerColumnButtonTag extends SearchContainerColumnTag {
36
37 public int doEndTag() {
38 try {
39 SearchContainerRowTag parentTag =
40 (SearchContainerRowTag)findAncestorWithClass(
41 this, SearchContainerRowTag.class);
42
43 ResultRow row = parentTag.getRow();
44
45 if (index <= -1) {
46 index = row.getEntries().size();
47 }
48
49 row.addButton(
50 index, getAlign(), getValign(), getColspan(), getName(),
51 (String)getHref());
52
53 return EVAL_PAGE;
54 }
55 finally {
56 align = SearchEntry.DEFAULT_ALIGN;
57 colspan = SearchEntry.DEFAULT_COLSPAN;
58 _href = null;
59 index = -1;
60 name = StringPool.BLANK;
61 valign = SearchEntry.DEFAULT_VALIGN;
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(StringPool.BLANK);
79 }
80
81 return EVAL_BODY_INCLUDE;
82 }
83
84 public Object getHref() {
85 if (Validator.isNotNull(_href) && (_href instanceof PortletURL)) {
86 _href = _href.toString();
87 }
88
89 return _href;
90 }
91
92 public void setHref(Object href) {
93 _href = href;
94 }
95
96 private Object _href;
97
98 }