1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * The contents of this file are subject to the terms of the Liferay Enterprise
5    * Subscription License ("License"). You may not use this file except in
6    * compliance with the License. You can obtain a copy of the License by
7    * contacting Liferay, Inc. See the License for the specific language governing
8    * permissions and limitations under the License, including but not limited to
9    * distribution rights of the Software.
10   *
11   *
12   * 
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.portal.kernel.dao.orm.QueryUtil;
18  import com.liferay.portal.kernel.servlet.StringServletResponse;
19  import com.liferay.taglib.util.IncludeTag;
20  
21  import javax.servlet.RequestDispatcher;
22  import javax.servlet.ServletContext;
23  import javax.servlet.http.HttpServletRequest;
24  import javax.servlet.http.HttpServletResponse;
25  import javax.servlet.jsp.JspException;
26  
27  /**
28   * <a href="MyPlacesTag.java.html"><b><i>View Source</i></b></a>
29   *
30   * @author Brian Wing Shun Chan
31   */
32  public class MyPlacesTag extends IncludeTag {
33  
34      public static void doTag(
35              ServletContext servletContext, HttpServletRequest request,
36              HttpServletResponse response)
37          throws Exception {
38  
39          doTag(_PAGE, _MAX, servletContext, request, response);
40      }
41  
42      public static void doTag(
43              int max, ServletContext servletContext, HttpServletRequest request,
44              HttpServletResponse response)
45          throws Exception {
46  
47          doTag(_PAGE, max, servletContext, request, response);
48      }
49  
50      public static void doTag(
51              String page, int max, ServletContext servletContext,
52              HttpServletRequest request, HttpServletResponse response)
53          throws Exception {
54  
55          request.setAttribute("liferay-ui:my_places:max", String.valueOf(max));
56  
57          RequestDispatcher requestDispatcher =
58              servletContext.getRequestDispatcher(page);
59  
60          requestDispatcher.include(request, response);
61      }
62  
63      public int doEndTag() throws JspException {
64          try {
65              ServletContext servletContext = getServletContext();
66              HttpServletRequest request = getServletRequest();
67              StringServletResponse stringResponse = getServletResponse();
68  
69              doTag(getPage(), _max, servletContext, request, stringResponse);
70  
71              pageContext.getOut().print(stringResponse.getString());
72  
73              return EVAL_PAGE;
74          }
75          catch (Exception e) {
76              throw new JspException(e);
77          }
78      }
79  
80      public void setMax(int max) {
81          _max = max;
82      }
83  
84      protected String getDefaultPage() {
85          return _PAGE;
86      }
87  
88      private static final String _PAGE = "/html/taglib/ui/my_places/page.jsp";
89  
90      private static final int _MAX = QueryUtil.ALL_POS;
91  
92      private int _max = _MAX;
93  
94  }