1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.taglib.util.IncludeTag;
18  
19  import java.text.Format;
20  
21  import java.util.Set;
22  
23  import javax.servlet.http.HttpServletRequest;
24  
25  /**
26   * <a href="CalendarTag.java.html"><b><i>View Source</i></b></a>
27   *
28   * @author Brian Wing Shun Chan
29   */
30  public class CalendarTag extends IncludeTag {
31  
32      public int doStartTag() {
33          HttpServletRequest request =
34              (HttpServletRequest)pageContext.getRequest();
35  
36          request.setAttribute("liferay-ui:calendar:data", _data);
37          request.setAttribute("liferay-ui:calendar:day", String.valueOf(_day));
38          request.setAttribute(
39              "liferay-ui:calendar:headerPattern", _headerPattern);
40          request.setAttribute("liferay-ui:calendar:headerFormat", _headerFormat);
41          request.setAttribute(
42              "liferay-ui:calendar:month", String.valueOf(_month));
43          request.setAttribute(
44              "liferay-ui:calendar:showAllPotentialWeeks",
45              String.valueOf(_showAllPotentialWeeks));
46          request.setAttribute("liferay-ui:calendar:year", String.valueOf(_year));
47  
48          return EVAL_BODY_BUFFERED;
49      }
50  
51      public void setData(Set<Integer> data) {
52          _data = data;
53      }
54  
55      public void setDay(int day) {
56          _day = day;
57      }
58  
59      public void setHeaderFormat(Format headerFormat) {
60          _headerFormat = headerFormat;
61      }
62  
63      public void setHeaderPattern(String headerPattern) {
64          _headerPattern = headerPattern;
65      }
66  
67      public void setMonth(int month) {
68          _month = month;
69      }
70  
71      public void setShowAllPotentialWeeks(boolean showAllPotentialWeeks) {
72          _showAllPotentialWeeks = showAllPotentialWeeks;
73      }
74  
75      public void setYear(int year) {
76          _year = year;
77      }
78  
79      protected String getDefaultPage() {
80          return _PAGE;
81      }
82  
83      private static final String _PAGE = "/html/taglib/ui/calendar/page.jsp";
84  
85      private Set<Integer> _data;
86      private int _day;
87      private Format _headerFormat;
88      private String _headerPattern;
89      private int _month;
90      private boolean _showAllPotentialWeeks;
91      private int _year;
92  
93  }