1   /**
2    * Copyright (c) 2000-2010 Liferay, Inc. All rights reserved.
3    *
4    * This library is free software; you can redistribute it and/or modify it under
5    * the terms of the GNU Lesser General Public License as published by the Free
6    * Software Foundation; either version 2.1 of the License, or (at your option)
7    * any later version.
8    *
9    * This library is distributed in the hope that it will be useful, but WITHOUT
10   * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
11   * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
12   * details.
13   */
14  
15  package com.liferay.taglib.ui;
16  
17  import com.liferay.taglib.util.IncludeTag;
18  
19  import java.text.Format;
20  
21  import javax.servlet.http.HttpServletRequest;
22  
23  /**
24   * <a href="InputFieldTag.java.html"><b><i>View Source</i></b></a>
25   *
26   * @author Brian Wing Shun Chan
27   */
28  public class InputFieldTag extends IncludeTag {
29  
30      public void setBean(Object bean) {
31          _bean = bean;
32      }
33  
34      public void setCssClass(String cssClass) {
35          _cssClass = cssClass;
36      }
37  
38      public void setDefaultValue(Object defaultValue) {
39          _defaultValue = defaultValue;
40      }
41  
42      public void setDisabled(boolean disabled) {
43          _disabled = disabled;
44      }
45  
46      public void setField(String field) {
47          _field = field;
48      }
49  
50      public void setFieldParam(String fieldParam) {
51          _fieldParam = fieldParam;
52      }
53  
54      public void setFormat(Format format) {
55          _format = format;
56      }
57  
58      public void setFormName(String formName) {
59          _formName = formName;
60      }
61  
62      public void setModel(Class<?> model) {
63          _model = model;
64      }
65  
66      protected void cleanUp() {
67          _bean = null;
68          _cssClass = null;
69          _defaultValue = null;
70          _disabled = false;
71          _field = null;
72          _fieldParam = null;
73          _format = null;
74          _formName = "fm";
75          _model = null;
76      }
77  
78      protected String getPage() {
79          return _PAGE;
80      }
81  
82      protected void setAttributes(HttpServletRequest request) {
83          request.setAttribute("liferay-ui:input-field:bean", _bean);
84          request.setAttribute("liferay-ui:input-field:cssClass", _cssClass);
85          request.setAttribute(
86              "liferay-ui:input-field:defaultValue", _defaultValue);
87          request.setAttribute(
88              "liferay-ui:input-field:disabled", String.valueOf(_disabled));
89          request.setAttribute("liferay-ui:input-field:field", _field);
90          request.setAttribute("liferay-ui:input-field:fieldParam", _fieldParam);
91          request.setAttribute("liferay-ui:input-field:format", _format);
92          request.setAttribute("liferay-ui:input-field:formName", _formName);
93          request.setAttribute("liferay-ui:input-field:model", _model.getName());
94      }
95  
96      private static final String _PAGE = "/html/taglib/ui/input_field/page.jsp";
97  
98      private Object _bean;
99      private String _cssClass;
100     private Object _defaultValue;
101     private boolean _disabled;
102     private String _field;
103     private String _fieldParam;
104     private Format _format;
105     private String _formName = "fm";
106     private Class<?> _model;
107 
108 }