001    /**
002     * Copyright (c) 2000-2012 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 setCssClass(String cssClass) {
036                    _cssClass = cssClass;
037            }
038    
039            public void setDaylight(boolean daylight) {
040                    _daylight = daylight;
041            }
042    
043            public void setDisabled(boolean disabled) {
044                    _disabled = disabled;
045            }
046    
047            public void setDisplayStyle(int displayStyle) {
048                    _displayStyle = displayStyle;
049            }
050    
051            public void setName(String name) {
052                    _name = name;
053            }
054    
055            public void setNullable(boolean nullable) {
056                    _nullable = nullable;
057            }
058    
059            public void setValue(String value) {
060                    _value = value;
061            }
062    
063            @Override
064            protected void cleanUp() {
065                    _cssClass = null;
066                    _daylight = false;
067                    _disabled = false;
068                    _displayStyle = TimeZone.LONG;
069                    _name = null;
070                    _nullable = false;
071    
072                    TimeZone timeZone = TimeZoneUtil.getDefault();
073    
074                    _value = timeZone.getID();
075            }
076    
077            @Override
078            protected String getPage() {
079                    return _PAGE;
080            }
081    
082            @Override
083            protected void setAttributes(HttpServletRequest request) {
084                    request.setAttribute("liferay-ui:input-time-zone:cssClass", _cssClass);
085                    request.setAttribute(
086                            "liferay-ui:input-time-zone:daylight", String.valueOf(_daylight));
087                    request.setAttribute(
088                            "liferay-ui:input-time-zone:disabled", String.valueOf(_disabled));
089                    request.setAttribute(
090                            "liferay-ui:input-time-zone:displayStyle",
091                            String.valueOf(_displayStyle));
092                    request.setAttribute("liferay-ui:input-time-zone:name", _name);
093                    request.setAttribute(
094                            "liferay-ui:input-time-zone:nullable", String.valueOf(_nullable));
095                    request.setAttribute("liferay-ui:input-time-zone:value", _value);
096            }
097    
098            private static final String _PAGE =
099                    "/html/taglib/ui/input_time_zone/page.jsp";
100    
101            private String _cssClass;
102            private boolean _daylight;
103            private boolean _disabled;
104            private int _displayStyle = TimeZone.LONG;
105            private String _name;
106            private boolean _nullable;
107            private String _value;
108    
109    }