001
014
015 package com.liferay.taglib.ui;
016
017 import com.liferay.portal.kernel.dao.search.DisplayTerms;
018 import com.liferay.portal.kernel.dao.search.RowChecker;
019 import com.liferay.portal.kernel.dao.search.SearchContainer;
020 import com.liferay.portal.kernel.util.JavaConstants;
021 import com.liferay.portal.kernel.util.ListUtil;
022 import com.liferay.portal.kernel.util.OrderByComparator;
023 import com.liferay.portal.kernel.util.StringUtil;
024 import com.liferay.portal.kernel.util.Validator;
025 import com.liferay.taglib.util.ParamAndPropertyAncestorTagImpl;
026
027 import java.util.List;
028
029 import javax.portlet.MimeResponse;
030 import javax.portlet.PortletRequest;
031 import javax.portlet.PortletResponse;
032 import javax.portlet.PortletURL;
033
034 import javax.servlet.http.HttpServletRequest;
035 import javax.servlet.jsp.JspException;
036
037
040 public class SearchContainerTag extends ParamAndPropertyAncestorTagImpl {
041
042 public static final String DEFAULT_VAR = "searchContainer";
043
044 public int doEndTag() {
045 _curParam = SearchContainer.DEFAULT_CUR_PARAM;
046 _delta = SearchContainer.DEFAULT_DELTA;
047 _deltaConfigurable = SearchContainer.DEFAULT_DELTA_CONFIGURABLE;
048 _deltaParam = SearchContainer.DEFAULT_DELTA_PARAM;
049 _displayTerms = null;
050 _emptyResultsMessage = null;
051 _hasResults = false;
052 _headerNames = null;
053 _hover = false;
054 _id = null;
055 _iteratorURL = null;
056 _orderByCol = null;
057 _orderByColParam = SearchContainer.DEFAULT_ORDER_BY_COL_PARAM;
058 _orderByComparator = null;
059 _orderByType = null;
060 _orderByTypeParam = SearchContainer.DEFAULT_ORDER_BY_TYPE_PARAM;
061 _rowChecker = null;
062 _searchContainer = null;
063 _searchTerms = null;
064 _var = DEFAULT_VAR;
065
066 return EVAL_PAGE;
067 }
068
069 public int doStartTag() throws JspException {
070 try {
071 HttpServletRequest request = getServletRequest();
072
073 PortletRequest portletRequest =
074 (PortletRequest)request.getAttribute(
075 JavaConstants.JAVAX_PORTLET_REQUEST);
076 PortletResponse portletResponse =
077 (PortletResponse)request.getAttribute(
078 JavaConstants.JAVAX_PORTLET_RESPONSE);
079
080 if (_iteratorURL == null) {
081 _iteratorURL =
082 ((MimeResponse)portletResponse).createRenderURL();
083 }
084
085 if (_searchContainer == null) {
086 _searchContainer = new SearchContainer(
087 portletRequest, _displayTerms, _searchTerms, getCurParam(),
088 getDelta(), _iteratorURL, null, _emptyResultsMessage);
089 }
090
091 _searchContainer.setDeltaConfigurable(_deltaConfigurable);
092 _searchContainer.setId(_id);
093
094 if (_headerNames != null) {
095 _searchContainer.setHeaderNames(_headerNames);
096 }
097
098 _searchContainer.setHover(_hover);
099
100 if (Validator.isNotNull(_orderByColParam)) {
101 _searchContainer.setOrderByColParam(_orderByColParam);
102 }
103
104 if (Validator.isNotNull(_orderByCol)) {
105 _searchContainer.setOrderByCol(_orderByCol);
106 }
107
108 if (_orderByComparator != null) {
109 _searchContainer.setOrderByComparator(_orderByComparator);
110 }
111
112 if (Validator.isNotNull(_orderByTypeParam)) {
113 _searchContainer.setOrderByTypeParam(_orderByTypeParam);
114 }
115
116 if (Validator.isNotNull(_orderByType)) {
117 _searchContainer.setOrderByType(_orderByType);
118 }
119
120 if (_rowChecker != null) {
121 _searchContainer.setRowChecker(_rowChecker);
122 }
123
124 pageContext.setAttribute(_var, _searchContainer);
125
126 return EVAL_BODY_INCLUDE;
127 }
128 catch (Exception e) {
129 throw new JspException(e);
130 }
131 }
132
133 public String getCurParam() {
134 return _curParam;
135 }
136
137 public int getDelta() {
138 return _delta;
139 }
140
141 public String getDeltaParam() {
142 return _deltaParam;
143 }
144
145 public DisplayTerms getDisplayTerms() {
146 return _displayTerms;
147 }
148
149 public String getEmptyResultsMessage() {
150 return _emptyResultsMessage;
151 }
152
153 public PortletURL getIteratorURL() {
154 return _iteratorURL;
155 }
156
157 public String getOrderByCol() {
158 return _orderByCol;
159 }
160
161 public String getOrderByColParam() {
162 return _orderByColParam;
163 }
164
165 public OrderByComparator getOrderByComparator() {
166 return _orderByComparator;
167 }
168
169 public String getOrderByType() {
170 return _orderByType;
171 }
172
173 public String getOrderByTypeParam() {
174 return _orderByTypeParam;
175 }
176
177 public RowChecker getRowChecker() {
178 return _rowChecker;
179 }
180
181 public SearchContainer getSearchContainer() {
182 return _searchContainer;
183 }
184
185 public DisplayTerms getSearchTerms() {
186 return _searchTerms;
187 }
188
189 public String getVar() {
190 return _var;
191 }
192
193 public boolean isDeltaConfigurable() {
194 return _deltaConfigurable;
195 }
196
197 public boolean isHasResults() {
198 return _hasResults;
199 }
200
201 public boolean isHover() {
202 return _hover;
203 }
204
205 public void setCurParam(String curParam) {
206 _curParam = curParam;
207 }
208
209 public void setDelta(int delta) {
210 _delta = delta;
211 }
212
213 public void setDeltaConfigurable(boolean deltaConfigurable) {
214 _deltaConfigurable = deltaConfigurable;
215 }
216
217 public void setDeltaParam(String deltaParam) {
218 _deltaParam = deltaParam;
219 }
220
221 public void setDisplayTerms(DisplayTerms displayTerms) {
222 _displayTerms = displayTerms;
223 }
224
225 public void setEmptyResultsMessage(String emptyResultsMessage) {
226 _emptyResultsMessage = emptyResultsMessage;
227 }
228
229 public void setHasResults(boolean hasResults) {
230 _hasResults = hasResults;
231 }
232
233 public void setHeaderNames(String headerNames) {
234 _headerNames = ListUtil.toList(StringUtil.split(headerNames));
235 }
236
237 public void setHover(boolean hover) {
238 _hover = hover;
239 }
240
241 public void setId(String id) {
242 _id = id;
243 }
244
245 public void setIteratorURL(PortletURL iteratorURL) {
246 _iteratorURL = iteratorURL;
247 }
248
249 public void setOrderByCol(String orderByCol) {
250 _orderByCol = orderByCol;
251 }
252
253 public void setOrderByColParam(String orderByColParam) {
254 _orderByColParam = orderByColParam;
255 }
256
257 public void setOrderByComparator(OrderByComparator orderByComparator) {
258 _orderByComparator = orderByComparator;
259 }
260
261 public void setOrderByType(String orderByType) {
262 _orderByType = orderByType;
263 }
264
265 public void setOrderByTypeParam(String orderByTypeParam) {
266 _orderByTypeParam = orderByTypeParam;
267 }
268
269 public void setRowChecker(RowChecker rowChecker) {
270 _rowChecker = rowChecker;
271 }
272
273 public void setSearchContainer(SearchContainer searchContainer) {
274 _searchContainer = searchContainer;
275 }
276
277 public void setSearchTerms(DisplayTerms searchTerms) {
278 _searchTerms = searchTerms;
279 }
280
281 public void setVar(String var) {
282 _var = var;
283 }
284
285 private String _curParam = SearchContainer.DEFAULT_CUR_PARAM;
286 private int _delta = SearchContainer.DEFAULT_DELTA;
287 private boolean _deltaConfigurable =
288 SearchContainer.DEFAULT_DELTA_CONFIGURABLE;
289 private String _deltaParam = SearchContainer.DEFAULT_DELTA_PARAM;
290 private DisplayTerms _displayTerms;
291 private String _emptyResultsMessage;
292 private boolean _hasResults;
293 private List<String> _headerNames;
294 private boolean _hover = true;
295 private String _id;
296 private PortletURL _iteratorURL;
297 private OrderByComparator _orderByComparator;
298 private String _orderByCol;
299 private String _orderByColParam =
300 SearchContainer.DEFAULT_ORDER_BY_COL_PARAM;
301 private String _orderByType;
302 private String _orderByTypeParam =
303 SearchContainer.DEFAULT_ORDER_BY_TYPE_PARAM;
304 private RowChecker _rowChecker;
305 private SearchContainer _searchContainer;
306 private DisplayTerms _searchTerms;
307 private String _var = DEFAULT_VAR;
308
309 }