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