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.taglib.search.JSPSearchEntry;
022
023 import java.util.List;
024
025 import javax.portlet.PortletURL;
026
027 import javax.servlet.http.HttpServletRequest;
028 import javax.servlet.http.HttpServletResponse;
029 import javax.servlet.jsp.JspException;
030 import javax.servlet.jsp.JspTagException;
031
032
035 public class SearchContainerColumnJSPTag<R> extends SearchContainerColumnTag {
036
037 @Override
038 public int doEndTag() {
039 try {
040 SearchContainerRowTag<R> searchContainerRowTag =
041 (SearchContainerRowTag<R>)findAncestorWithClass(
042 this, SearchContainerRowTag.class);
043
044 ResultRow resultRow = searchContainerRowTag.getRow();
045
046 if (index <= -1) {
047 List<SearchEntry> searchEntries = resultRow.getEntries();
048
049 index = searchEntries.size();
050 }
051
052 JSPSearchEntry jspSearchEntry = new JSPSearchEntry();
053
054 jspSearchEntry.setAlign(getAlign());
055 jspSearchEntry.setColspan(getColspan());
056 jspSearchEntry.setCssClass(getCssClass());
057 jspSearchEntry.setHref(String.valueOf(getHref()));
058 jspSearchEntry.setPath(getPath());
059 jspSearchEntry.setRequest(
060 (HttpServletRequest)pageContext.getRequest());
061 jspSearchEntry.setResponse(
062 (HttpServletResponse)pageContext.getResponse());
063 jspSearchEntry.setServletContext(pageContext.getServletContext());
064 jspSearchEntry.setTruncate(getTruncate());
065 jspSearchEntry.setValign(getValign());
066
067 resultRow.addSearchEntry(index, jspSearchEntry);
068
069 return EVAL_PAGE;
070 }
071 finally {
072 index = -1;
073
074 if (!ServerDetector.isResin()) {
075 align = SearchEntry.DEFAULT_ALIGN;
076 colspan = SearchEntry.DEFAULT_COLSPAN;
077 cssClass = SearchEntry.DEFAULT_CSS_CLASS;
078 name = StringPool.BLANK;
079 _path = null;
080 valign = SearchEntry.DEFAULT_VALIGN;
081 }
082 }
083 }
084
085 @Override
086 public int doStartTag() throws JspException {
087 SearchContainerRowTag<R> searchContainerRowTag =
088 (SearchContainerRowTag<R>)findAncestorWithClass(
089 this, SearchContainerRowTag.class);
090
091 if (searchContainerRowTag == null) {
092 throw new JspTagException(
093 "Requires liferay-ui:search-container-row");
094 }
095
096 if (!searchContainerRowTag.isHeaderNamesAssigned()) {
097 List<String> headerNames = searchContainerRowTag.getHeaderNames();
098
099 headerNames.add(name);
100 }
101
102 return EVAL_BODY_INCLUDE;
103 }
104
105 public Object getHref() {
106 if (_href instanceof PortletURL) {
107 _href = _href.toString();
108 }
109
110 return _href;
111 }
112
113 public String getPath() {
114 return _path;
115 }
116
117 public void setHref(Object href) {
118 _href = href;
119 }
120
121 public void setPath(String path) {
122 _path = path;
123 }
124
125 private Object _href;
126 private String _path;
127
128 }