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