001
014
015 package com.liferay.taglib.ui;
016
017 import com.liferay.portal.kernel.dao.search.JSPSearchEntry;
018 import com.liferay.portal.kernel.dao.search.ResultRow;
019 import com.liferay.portal.kernel.dao.search.SearchEntry;
020 import com.liferay.portal.kernel.util.ServerDetector;
021 import com.liferay.portal.kernel.util.StringPool;
022
023 import java.util.List;
024
025 import javax.servlet.http.HttpServletRequest;
026 import javax.servlet.http.HttpServletResponse;
027 import javax.servlet.jsp.JspException;
028 import javax.servlet.jsp.JspTagException;
029
030
033 public class SearchContainerColumnJSPTag<R> extends SearchContainerColumnTag {
034
035 @Override
036 public int doEndTag() {
037 try {
038 SearchContainerRowTag<R> searchContainerRowTag =
039 (SearchContainerRowTag<R>)findAncestorWithClass(
040 this, SearchContainerRowTag.class);
041
042 ResultRow resultRow = searchContainerRowTag.getRow();
043
044 if (index <= -1) {
045 List<SearchEntry> searchEntries = resultRow.getEntries();
046
047 index = searchEntries.size();
048 }
049
050 JSPSearchEntry jspSearchEntry = new JSPSearchEntry();
051
052 jspSearchEntry.setAlign(getAlign());
053 jspSearchEntry.setColspan(getColspan());
054 jspSearchEntry.setCssClass(getCssClass());
055 jspSearchEntry.setPath(getPath());
056 jspSearchEntry.setRequest(
057 (HttpServletRequest)pageContext.getRequest());
058 jspSearchEntry.setResponse(
059 (HttpServletResponse)pageContext.getResponse());
060 jspSearchEntry.setServletContext(pageContext.getServletContext());
061 jspSearchEntry.setValign(getValign());
062
063 resultRow.addSearchEntry(index, jspSearchEntry);
064
065 return EVAL_PAGE;
066 }
067 finally {
068 index = -1;
069
070 if (!ServerDetector.isResin()) {
071 align = SearchEntry.DEFAULT_ALIGN;
072 colspan = SearchEntry.DEFAULT_COLSPAN;
073 cssClass = SearchEntry.DEFAULT_CSS_CLASS;
074 name = StringPool.BLANK;
075 _path = null;
076 valign = SearchEntry.DEFAULT_VALIGN;
077 }
078 }
079 }
080
081 @Override
082 public int doStartTag() throws JspException {
083 SearchContainerRowTag<R> searchContainerRowTag =
084 (SearchContainerRowTag<R>)findAncestorWithClass(
085 this, SearchContainerRowTag.class);
086
087 if (searchContainerRowTag == null) {
088 throw new JspTagException(
089 "Requires liferay-ui:search-container-row");
090 }
091
092 if (!searchContainerRowTag.isHeaderNamesAssigned()) {
093 List<String> headerNames = searchContainerRowTag.getHeaderNames();
094
095 headerNames.add(name);
096 }
097
098 return EVAL_BODY_INCLUDE;
099 }
100
101 public String getPath() {
102 return _path;
103 }
104
105 public void setPath(String path) {
106 _path = path;
107 }
108
109 private String _path;
110
111 }