001    /**
002     * Copyright (c) 2000-2010 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 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            protected void cleanUp() {
058                    _cssClass = null;
059                    _daylight = false;
060                    _disabled = false;
061                    _displayStyle = TimeZone.LONG;
062                    _name = null;
063                    _nullable = false;
064                    _value = TimeZoneUtil.getDefault().getID();
065            }
066    
067            protected String getPage() {
068                    return _PAGE;
069            }
070    
071            protected void setAttributes(HttpServletRequest request) {
072                    request.setAttribute("liferay-ui:input-time-zone:cssClass", _cssClass);
073                    request.setAttribute(
074                            "liferay-ui:input-time-zone:daylight", String.valueOf(_daylight));
075                    request.setAttribute(
076                            "liferay-ui:input-time-zone:disabled", String.valueOf(_disabled));
077                    request.setAttribute(
078                            "liferay-ui:input-time-zone:displayStyle",
079                            String.valueOf(_displayStyle));
080                    request.setAttribute("liferay-ui:input-time-zone:name", _name);
081                    request.setAttribute(
082                            "liferay-ui:input-time-zone:nullable", String.valueOf(_nullable));
083                    request.setAttribute("liferay-ui:input-time-zone:value", _value);
084            }
085    
086            private static final String _PAGE =
087                    "/html/taglib/ui/input_time_zone/page.jsp";
088    
089            private String _cssClass;
090            private boolean _daylight;
091            private boolean _disabled;
092            private int _displayStyle = TimeZone.LONG;
093            private String _name;
094            private boolean _nullable;
095            private String _value = TimeZoneUtil.getDefault().getID();
096    
097    }