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