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.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 setModel(Class<?> model) {
061                    _model = model;
062            }
063    
064            protected void cleanUp() {
065                    _bean = null;
066                    _cssClass = null;
067                    _defaultValue = null;
068                    _disabled = false;
069                    _field = null;
070                    _fieldParam = null;
071                    _format = null;
072                    _formName = "fm";
073                    _model = null;
074            }
075    
076            protected String getPage() {
077                    return _PAGE;
078            }
079    
080            protected void setAttributes(HttpServletRequest request) {
081                    request.setAttribute("liferay-ui:input-field:bean", _bean);
082                    request.setAttribute("liferay-ui:input-field:cssClass", _cssClass);
083                    request.setAttribute(
084                            "liferay-ui:input-field:defaultValue", _defaultValue);
085                    request.setAttribute(
086                            "liferay-ui:input-field:disabled", String.valueOf(_disabled));
087                    request.setAttribute("liferay-ui:input-field:field", _field);
088                    request.setAttribute("liferay-ui:input-field:fieldParam", _fieldParam);
089                    request.setAttribute("liferay-ui:input-field:format", _format);
090                    request.setAttribute("liferay-ui:input-field:formName", _formName);
091                    request.setAttribute("liferay-ui:input-field:model", _model.getName());
092            }
093    
094            private static final String _PAGE = "/html/taglib/ui/input_field/page.jsp";
095    
096            private Object _bean;
097            private String _cssClass;
098            private Object _defaultValue;
099            private boolean _disabled;
100            private String _field;
101            private String _fieldParam;
102            private Format _format;
103            private String _formName = "fm";
104            private Class<?> _model;
105    
106    }