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 void setData(Set<Integer> data) {
33          _data = data;
34      }
35  
36      public void setDay(int day) {
37          _day = day;
38      }
39  
40      public void setHeaderFormat(Format headerFormat) {
41          _headerFormat = headerFormat;
42      }
43  
44      public void setHeaderPattern(String headerPattern) {
45          _headerPattern = headerPattern;
46      }
47  
48      public void setMonth(int month) {
49          _month = month;
50      }
51  
52      public void setShowAllPotentialWeeks(boolean showAllPotentialWeeks) {
53          _showAllPotentialWeeks = showAllPotentialWeeks;
54      }
55  
56      public void setYear(int year) {
57          _year = year;
58      }
59  
60      protected void cleanUp() {
61          _data = null;
62          _day = 0;
63          _headerFormat = null;
64          _headerPattern = null;
65          _month = 0;
66          _showAllPotentialWeeks = false;
67          _year = 0;
68      }
69  
70      protected String getPage() {
71          return _PAGE;
72      }
73  
74      protected void setAttributes(HttpServletRequest request) {
75          request.setAttribute("liferay-ui:calendar:data", _data);
76          request.setAttribute("liferay-ui:calendar:day", String.valueOf(_day));
77          request.setAttribute(
78              "liferay-ui:calendar:headerPattern", _headerPattern);
79          request.setAttribute("liferay-ui:calendar:headerFormat", _headerFormat);
80          request.setAttribute(
81              "liferay-ui:calendar:month", String.valueOf(_month));
82          request.setAttribute(
83              "liferay-ui:calendar:showAllPotentialWeeks",
84              String.valueOf(_showAllPotentialWeeks));
85          request.setAttribute("liferay-ui:calendar:year", String.valueOf(_year));
86      }
87  
88      private static final String _PAGE = "/html/taglib/ui/calendar/page.jsp";
89  
90      private Set<Integer> _data;
91      private int _day;
92      private Format _headerFormat;
93      private String _headerPattern;
94      private int _month;
95      private boolean _showAllPotentialWeeks;
96      private int _year;
97  
98  }