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