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.aui;
16  
17  import com.liferay.portal.kernel.util.HtmlUtil;
18  import com.liferay.taglib.util.IncludeTag;
19  
20  import javax.portlet.PortletURL;
21  
22  import javax.servlet.http.HttpServletRequest;
23  
24  /**
25   * <a href="FormTag.java.html"><b><i>View Source</i></b></a>
26   *
27   * @author Julio Camarero
28   * @author Jorge Ferrer
29   * @author Brian Wing Shun Chan
30   */
31  public class FormTag extends IncludeTag {
32  
33      public void setAction(PortletURL portletURL) {
34          if (portletURL != null) {
35              _action = portletURL.toString();
36          }
37      }
38  
39      public void setAction(String action) {
40          _action = action;
41      }
42  
43      public void setCssClass(String cssClass) {
44          _cssClass = cssClass;
45      }
46  
47      public void setEscapeXml(boolean escapeXml) {
48          _escapeXml = escapeXml;
49      }
50  
51      public void setInlineLabel(boolean inlineLabel) {
52          _inlineLabel = inlineLabel;
53      }
54  
55      public void setName(String name) {
56          _name = name;
57      }
58  
59      public void setOnSubmit(String onSubmit) {
60          _onSubmit = onSubmit;
61      }
62  
63      public void setUseNamespace(boolean useNamespace) {
64          _useNamespace = useNamespace;
65      }
66  
67      protected void cleanUp() {
68          _action = null;
69          _cssClass = null;
70          _escapeXml = true;
71          _inlineLabel = false;
72          _name = "fm";
73          _onSubmit = null;
74          _useNamespace = true;
75      }
76  
77      protected String getEndPage() {
78          return _END_PAGE;
79      }
80  
81      protected String getStartPage() {
82          return _START_PAGE;
83      }
84  
85      protected boolean isCleanUpSetAttributes() {
86          return _CLEAN_UP_SET_ATTRIBUTES;
87      }
88  
89      protected void setAttributes(HttpServletRequest request) {
90          String action = _action;
91  
92          if (_escapeXml) {
93              action = HtmlUtil.escape(action);
94          }
95  
96          request.setAttribute("aui:form:action", action);
97          request.setAttribute("aui:form:cssClass", _cssClass);
98          request.setAttribute(
99              "aui:form:dynamicAttributes", getDynamicAttributes());
100         request.setAttribute(
101             "aui:form:inlineLabel", String.valueOf(_inlineLabel));
102         request.setAttribute("aui:form:name", _name);
103         request.setAttribute("aui:form:onSubmit", _onSubmit);
104         request.setAttribute(
105             "aui:form:useNamespace", String.valueOf(_useNamespace));
106     }
107 
108     private static final boolean _CLEAN_UP_SET_ATTRIBUTES = true;
109 
110     private static final String _END_PAGE = "/html/taglib/aui/form/end.jsp";
111 
112     private static final String _START_PAGE = "/html/taglib/aui/form/start.jsp";
113 
114     private String _action;
115     private String _cssClass;
116     private boolean _escapeXml = true;
117     private boolean _inlineLabel;
118     private String _name = "fm";
119     private String _onSubmit;
120     private boolean _useNamespace = true;
121 
122 }