001    /**
002     * Copyright (c) 2000-2013 Liferay, Inc. All rights reserved.
003     *
004     * This library is free software; you can redistribute it and/or modify it under
005     * the terms of the GNU Lesser General Public License as published by the Free
006     * Software Foundation; either version 2.1 of the License, or (at your option)
007     * any later version.
008     *
009     * This library is distributed in the hope that it will be useful, but WITHOUT
010     * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
011     * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
012     * details.
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            @Override
059            protected void cleanUp() {
060                    _data = null;
061                    _day = 0;
062                    _headerFormat = null;
063                    _headerPattern = null;
064                    _month = 0;
065                    _showAllPotentialWeeks = false;
066                    _year = 0;
067            }
068    
069            @Override
070            protected String getPage() {
071                    return _PAGE;
072            }
073    
074            @Override
075            protected void setAttributes(HttpServletRequest request) {
076                    request.setAttribute("liferay-ui:calendar:data", _data);
077                    request.setAttribute("liferay-ui:calendar:day", String.valueOf(_day));
078                    request.setAttribute(
079                            "liferay-ui:calendar:headerPattern", _headerPattern);
080                    request.setAttribute("liferay-ui:calendar:headerFormat", _headerFormat);
081                    request.setAttribute(
082                            "liferay-ui:calendar:month", String.valueOf(_month));
083                    request.setAttribute(
084                            "liferay-ui:calendar:showAllPotentialWeeks",
085                            String.valueOf(_showAllPotentialWeeks));
086                    request.setAttribute("liferay-ui:calendar:year", String.valueOf(_year));
087            }
088    
089            private static final String _PAGE = "/html/taglib/ui/calendar/page.jsp";
090    
091            private Set<Integer> _data;
092            private int _day;
093            private Format _headerFormat;
094            private String _headerPattern;
095            private int _month;
096            private boolean _showAllPotentialWeeks;
097            private int _year;
098    
099    }