001    /**
002     * Copyright (c) 2000-2011 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.taglib.util.IncludeTag;
018    
019    import java.text.Format;
020    
021    import javax.servlet.http.HttpServletRequest;
022    
023    /**
024     * @author Brian Wing Shun Chan
025     */
026    public class InputFieldTag extends IncludeTag {
027    
028            public void setBean(Object bean) {
029                    _bean = bean;
030            }
031    
032            public void setCssClass(String cssClass) {
033                    _cssClass = cssClass;
034            }
035    
036            public void setDefaultValue(Object defaultValue) {
037                    _defaultValue = defaultValue;
038            }
039    
040            public void setDisabled(boolean disabled) {
041                    _disabled = disabled;
042            }
043    
044            public void setField(String field) {
045                    _field = field;
046            }
047    
048            public void setFieldParam(String fieldParam) {
049                    _fieldParam = fieldParam;
050            }
051    
052            public void setFormat(Format format) {
053                    _format = format;
054            }
055    
056            public void setFormName(String formName) {
057                    _formName = formName;
058            }
059    
060            public void setLanguageId(String languageId) {
061                    _languageId = languageId;
062            }
063    
064            public void setModel(Class<?> model) {
065                    _model = model;
066            }
067    
068            public void setPlaceholder(String placeholder) {
069                    _placeholder = placeholder;
070            }
071    
072            @Override
073            protected void cleanUp() {
074                    _bean = null;
075                    _cssClass = null;
076                    _defaultValue = null;
077                    _disabled = false;
078                    _field = null;
079                    _fieldParam = null;
080                    _format = null;
081                    _formName = "fm";
082                    _languageId = null;
083                    _model = null;
084                    _placeholder = null;
085            }
086    
087            @Override
088            protected String getPage() {
089                    return _PAGE;
090            }
091    
092            @Override
093            protected void setAttributes(HttpServletRequest request) {
094                    request.setAttribute("liferay-ui:input-field:bean", _bean);
095                    request.setAttribute("liferay-ui:input-field:cssClass", _cssClass);
096                    request.setAttribute(
097                            "liferay-ui:input-field:defaultValue", _defaultValue);
098                    request.setAttribute(
099                            "liferay-ui:input-field:disabled", String.valueOf(_disabled));
100                    request.setAttribute("liferay-ui:input-field:field", _field);
101                    request.setAttribute("liferay-ui:input-field:fieldParam", _fieldParam);
102                    request.setAttribute("liferay-ui:input-field:format", _format);
103                    request.setAttribute("liferay-ui:input-field:formName", _formName);
104                    request.setAttribute("liferay-ui:input-field:languageId", _languageId);
105                    request.setAttribute("liferay-ui:input-field:model", _model.getName());
106                    request.setAttribute(
107                            "liferay-ui:input-field:placeholder", _placeholder);
108            }
109    
110            private static final String _PAGE = "/html/taglib/ui/input_field/page.jsp";
111    
112            private Object _bean;
113            private String _cssClass;
114            private Object _defaultValue;
115            private boolean _disabled;
116            private String _field;
117            private String _fieldParam;
118            private Format _format;
119            private String _formName = "fm";
120            private String _languageId;
121            private Class<?> _model;
122            private String _placeholder;
123    
124    }