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.TimeZoneUtil;
018    import com.liferay.taglib.util.IncludeTag;
019    
020    import java.util.TimeZone;
021    
022    import javax.servlet.http.HttpServletRequest;
023    
024    /**
025     * @author Brian Wing Shun Chan
026     */
027    public class InputTimeZoneTag extends IncludeTag {
028    
029            public InputTimeZoneTag() {
030                    TimeZone timeZone = TimeZoneUtil.getDefault();
031    
032                    _value = timeZone.getID();
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 setDaylight(boolean daylight) {
044                    _daylight = daylight;
045            }
046    
047            public void setDisabled(boolean disabled) {
048                    _disabled = disabled;
049            }
050    
051            public void setDisplayStyle(int displayStyle) {
052                    _displayStyle = displayStyle;
053            }
054    
055            public void setName(String name) {
056                    _name = name;
057            }
058    
059            public void setNullable(boolean nullable) {
060                    _nullable = nullable;
061            }
062    
063            public void setValue(String value) {
064                    _value = value;
065            }
066    
067            @Override
068            protected void cleanUp() {
069                    _autoFocus = false;
070                    _cssClass = null;
071                    _daylight = false;
072                    _disabled = false;
073                    _displayStyle = TimeZone.LONG;
074                    _name = null;
075                    _nullable = false;
076    
077                    TimeZone timeZone = TimeZoneUtil.getDefault();
078    
079                    _value = timeZone.getID();
080            }
081    
082            @Override
083            protected String getPage() {
084                    return _PAGE;
085            }
086    
087            @Override
088            protected void setAttributes(HttpServletRequest request) {
089                    request.setAttribute(
090                            "liferay-ui:input-time-zone:autoFocus", String.valueOf(_autoFocus));
091                    request.setAttribute("liferay-ui:input-time-zone:cssClass", _cssClass);
092                    request.setAttribute(
093                            "liferay-ui:input-time-zone:daylight", String.valueOf(_daylight));
094                    request.setAttribute(
095                            "liferay-ui:input-time-zone:disabled", String.valueOf(_disabled));
096                    request.setAttribute(
097                            "liferay-ui:input-time-zone:displayStyle",
098                            String.valueOf(_displayStyle));
099                    request.setAttribute("liferay-ui:input-time-zone:name", _name);
100                    request.setAttribute(
101                            "liferay-ui:input-time-zone:nullable", String.valueOf(_nullable));
102                    request.setAttribute("liferay-ui:input-time-zone:value", _value);
103            }
104    
105            private static final String _PAGE =
106                    "/html/taglib/ui/input_time_zone/page.jsp";
107    
108            private boolean _autoFocus;
109            private String _cssClass;
110            private boolean _daylight;
111            private boolean _disabled;
112            private int _displayStyle = TimeZone.LONG;
113            private String _name;
114            private boolean _nullable;
115            private String _value;
116    
117    }