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.portal.kernel.util.StringPool;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import java.util.Calendar;
021    
022    import javax.servlet.http.HttpServletRequest;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class InputDateTag extends IncludeTag {
028    
029            public void setAutoFocus(boolean autoFocus) {
030                    _autoFocus = autoFocus;
031            }
032    
033            public void setCssClass(String cssClass) {
034                    _cssClass = cssClass;
035            }
036    
037            public void setDayParam(String dayParam) {
038                    _dayParam = dayParam;
039            }
040    
041            public void setDayValue(int dayValue) {
042                    _dayValue = dayValue;
043            }
044    
045            public void setDisabled(boolean disabled) {
046                    _disabled = disabled;
047            }
048    
049            public void setDisableNamespace(boolean disableNamespace) {
050                    _disableNamespace = disableNamespace;
051            }
052    
053            public void setFirstDayOfWeek(int firstDayOfWeek) {
054                    _firstDayOfWeek = firstDayOfWeek;
055            }
056    
057            public void setFormName(String formName) {
058                    _formName = formName;
059            }
060    
061            public void setMonthAndYearParam(String monthAndYearParam) {
062                    _monthAndYearParam = monthAndYearParam;
063            }
064    
065            public void setMonthParam(String monthParam) {
066                    _monthParam = monthParam;
067            }
068    
069            public void setMonthValue(int monthValue) {
070                    _monthValue = monthValue;
071            }
072    
073            public void setName(String name) {
074                    _name = name;
075            }
076    
077            public void setNullable(boolean nullable) {
078                    _nullable = nullable;
079            }
080    
081            public void setYearParam(String yearParam) {
082                    _yearParam = yearParam;
083            }
084    
085            public void setYearValue(int yearValue) {
086                    _yearValue = yearValue;
087            }
088    
089            @Override
090            protected void cleanUp() {
091                    _autoFocus = false;
092                    _cssClass = null;
093                    _dayParam = null;
094                    _dayValue = 0;
095                    _disabled = false;
096                    _disableNamespace = false;
097                    _firstDayOfWeek = Calendar.SUNDAY - 2;
098                    _formName = "fm";
099                    _monthAndYearParam = StringPool.BLANK;
100                    _monthParam = null;
101                    _monthValue = -1;
102                    _nullable = false;
103                    _yearParam = null;
104                    _yearValue = 0;
105            }
106    
107            @Override
108            protected String getPage() {
109                    return _PAGE;
110            }
111    
112            @Override
113            protected void setAttributes(HttpServletRequest request) {
114                    request.setAttribute(
115                            "liferay-ui:input-date:autoFocus", String.valueOf(_autoFocus));
116                    request.setAttribute("liferay-ui:input-date:cssClass", _cssClass);
117                    request.setAttribute("liferay-ui:input-date:dayParam", _dayParam);
118                    request.setAttribute(
119                            "liferay-ui:input-date:dayValue", String.valueOf(_dayValue));
120                    request.setAttribute(
121                            "liferay-ui:input-date:disabled", String.valueOf(_disabled));
122                    request.setAttribute(
123                            "liferay-ui:input-date:disableNamespace",
124                            String.valueOf(_disableNamespace));
125                    request.setAttribute(
126                            "liferay-ui:input-date:firstDayOfWeek",
127                            String.valueOf(_firstDayOfWeek));
128                    request.setAttribute("liferay-ui:input-date:formName", _formName);
129                    request.setAttribute(
130                            "liferay-ui:input-date:monthAndYearParam", _monthAndYearParam);
131                    request.setAttribute("liferay-ui:input-date:monthParam", _monthParam);
132                    request.setAttribute(
133                            "liferay-ui:input-date:monthValue", String.valueOf(_monthValue));
134                    request.setAttribute("liferay-ui:input-date:name", _name);
135                    request.setAttribute(
136                            "liferay-ui:input-date:nullable", String.valueOf(_nullable));
137                    request.setAttribute("liferay-ui:input-date:yearParam", _yearParam);
138                    request.setAttribute(
139                            "liferay-ui:input-date:yearValue", String.valueOf(_yearValue));
140            }
141    
142            private static final String _PAGE = "/html/taglib/ui/input_date/page.jsp";
143    
144            private boolean _autoFocus;
145            private String _cssClass;
146            private String _dayParam;
147            private int _dayValue;
148            private boolean _disabled;
149            private boolean _disableNamespace;
150            private int _firstDayOfWeek = Calendar.SUNDAY - 2;
151            private String _formName = "fm";
152            private String _monthAndYearParam = StringPool.BLANK;
153            private String _monthParam;
154            private int _monthValue = -1;
155            private String _name;
156            private boolean _nullable;
157            private String _yearParam;
158            private int _yearValue;
159    
160    }