001    /**
002     * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
003     *
004     * The contents of this file are subject to the terms of the Liferay Enterprise
005     * Subscription License ("License"). You may not use this file except in
006     * compliance with the License. You can obtain a copy of the License by
007     * contacting Liferay, Inc. See the License for the specific language governing
008     * permissions and limitations under the License, including but not limited to
009     * distribution rights of the Software.
010     *
011     *
012     *
013     */
014    
015    package com.liferay.taglib.ui;
016    
017    import com.liferay.taglib.util.IncludeTag;
018    
019    import java.text.Format;
020    
021    import java.util.Set;
022    
023    import javax.servlet.http.HttpServletRequest;
024    
025    /**
026     * @author Brian Wing Shun Chan
027     */
028    public class CalendarTag extends IncludeTag {
029    
030            public void setData(Set<Integer> data) {
031                    _data = data;
032            }
033    
034            public void setDay(int day) {
035                    _day = day;
036            }
037    
038            public void setHeaderFormat(Format headerFormat) {
039                    _headerFormat = headerFormat;
040            }
041    
042            public void setHeaderPattern(String headerPattern) {
043                    _headerPattern = headerPattern;
044            }
045    
046            public void setMonth(int month) {
047                    _month = month;
048            }
049    
050            public void setShowAllPotentialWeeks(boolean showAllPotentialWeeks) {
051                    _showAllPotentialWeeks = showAllPotentialWeeks;
052            }
053    
054            public void setYear(int year) {
055                    _year = year;
056            }
057    
058            protected void cleanUp() {
059                    _data = null;
060                    _day = 0;
061                    _headerFormat = null;
062                    _headerPattern = null;
063                    _month = 0;
064                    _showAllPotentialWeeks = false;
065                    _year = 0;
066            }
067    
068            protected String getPage() {
069                    return _PAGE;
070            }
071    
072            protected void setAttributes(HttpServletRequest request) {
073                    request.setAttribute("liferay-ui:calendar:data", _data);
074                    request.setAttribute("liferay-ui:calendar:day", String.valueOf(_day));
075                    request.setAttribute(
076                            "liferay-ui:calendar:headerPattern", _headerPattern);
077                    request.setAttribute("liferay-ui:calendar:headerFormat", _headerFormat);
078                    request.setAttribute(
079                            "liferay-ui:calendar:month", String.valueOf(_month));
080                    request.setAttribute(
081                            "liferay-ui:calendar:showAllPotentialWeeks",
082                            String.valueOf(_showAllPotentialWeeks));
083                    request.setAttribute("liferay-ui:calendar:year", String.valueOf(_year));
084            }
085    
086            private static final String _PAGE = "/html/taglib/ui/calendar/page.jsp";
087    
088            private Set<Integer> _data;
089            private int _day;
090            private Format _headerFormat;
091            private String _headerPattern;
092            private int _month;
093            private boolean _showAllPotentialWeeks;
094            private int _year;
095    
096    }