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 index = -1;
055
056 if (!ServerDetector.isResin()) {
057 align = SearchEntry.DEFAULT_ALIGN;
058 colspan = SearchEntry.DEFAULT_COLSPAN;
059 _href = null;
060 name = StringPool.BLANK;
061 valign = SearchEntry.DEFAULT_VALIGN;
062 }
063 }
064 }
065
066 public int doStartTag() throws JspException {
067 SearchContainerRowTag parentRowTag =
068 (SearchContainerRowTag)findAncestorWithClass(
069 this, SearchContainerRowTag.class);
070
071 if (parentRowTag == null) {
072 throw new JspTagException(
073 "Requires liferay-ui:search-container-row");
074 }
075
076 if (!parentRowTag.isHeaderNamesAssigned()) {
077 List<String> headerNames = parentRowTag.getHeaderNames();
078
079 headerNames.add(StringPool.BLANK);
080 }
081
082 return EVAL_BODY_INCLUDE;
083 }
084
085 public Object getHref() {
086 if (Validator.isNotNull(_href) && (_href instanceof PortletURL)) {
087 _href = _href.toString();
088 }
089
090 return _href;
091 }
092
093 public void setHref(Object href) {
094 _href = href;
095 }
096
097 private Object _href;
098
099 }