001
014
015 package com.liferay.taglib.ui;
016
017 import com.liferay.portal.kernel.dao.search.ResultRow;
018 import com.liferay.portal.kernel.dao.search.SearchEntry;
019 import com.liferay.portal.kernel.util.ServerDetector;
020 import com.liferay.portal.kernel.util.StringPool;
021 import com.liferay.portal.kernel.util.Validator;
022
023 import java.util.List;
024
025 import javax.portlet.PortletURL;
026
027 import javax.servlet.jsp.JspException;
028 import javax.servlet.jsp.JspTagException;
029
030
033 public class SearchContainerColumnButtonTag extends SearchContainerColumnTag {
034
035 public int doEndTag() {
036 try {
037 SearchContainerRowTag parentTag =
038 (SearchContainerRowTag)findAncestorWithClass(
039 this, SearchContainerRowTag.class);
040
041 ResultRow row = parentTag.getRow();
042
043 if (index <= -1) {
044 index = row.getEntries().size();
045 }
046
047 row.addButton(
048 index, getAlign(), getValign(), getColspan(), getName(),
049 (String)getHref());
050
051 return EVAL_PAGE;
052 }
053 finally {
054 if (!ServerDetector.isResin()) {
055 align = SearchEntry.DEFAULT_ALIGN;
056 colspan = SearchEntry.DEFAULT_COLSPAN;
057 _href = null;
058 index = -1;
059 name = StringPool.BLANK;
060 valign = SearchEntry.DEFAULT_VALIGN;
061 }
062 }
063 }
064
065 public int doStartTag() throws JspException {
066 SearchContainerRowTag parentRowTag =
067 (SearchContainerRowTag)findAncestorWithClass(
068 this, SearchContainerRowTag.class);
069
070 if (parentRowTag == null) {
071 throw new JspTagException(
072 "Requires liferay-ui:search-container-row");
073 }
074
075 if (!parentRowTag.isHeaderNamesAssigned()) {
076 List<String> headerNames = parentRowTag.getHeaderNames();
077
078 headerNames.add(StringPool.BLANK);
079 }
080
081 return EVAL_BODY_INCLUDE;
082 }
083
084 public Object getHref() {
085 if (Validator.isNotNull(_href) && (_href instanceof PortletURL)) {
086 _href = _href.toString();
087 }
088
089 return _href;
090 }
091
092 public void setHref(Object href) {
093 _href = href;
094 }
095
096 private Object _href;
097
098 }