View Javadoc

1   /*
2    * Copyright 2002-2004 The Apache Software Foundation.
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *      http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  
17  package org.apache.struts.faces.taglib;
18  
19  
20  import javax.faces.component.UIComponent;
21  
22  
23  /***
24   * <p>Render an input form that is submitted to a Struts <code>Action</code>,
25   * for the <em>Struts-Faces Integration Library</em>.</p>
26   *
27   * @version $Rev: 421138 $ $Date: 2006-07-11 22:41:40 -0700 (Tue, 11 Jul 2006) $
28   */
29  
30  public class FormTag extends AbstractFacesTag {
31  
32  
33      // ---------------------------------------------------------- Tag Attributes
34  
35  
36      /***
37       * <p>The <code>path</code> of the Struts <code>Action</code> to which
38       * this form should be submitted.  This property is analogous to the
39       * <code>formName</code> property on the form tag in the standard
40       * HTML RenderKit.</p>
41       */
42      protected String action = null;
43  
44      public void setAction(String action) {
45          this.action = action;
46      }
47  
48  
49      /***
50       * <p>The content encoding type to use.</p>
51       */
52      protected String enctype = null;
53  
54      public void setEnctype(String enctype) {
55          this.enctype = enctype;
56      }
57  
58  
59      /***
60       * <p>The name of the field to which focus should be set when this
61       * form is displayed.</p>
62       */
63      protected String focus = null;
64  
65      public void setFocus(String focus) {
66          this.focus = focus;
67      }
68  
69  
70      /***
71       * <p>The subscript of the focus field array to receive focus.</p>
72       */
73      protected String focusIndex = null;
74  
75      public void setFocusIndex(String focusIndex) {
76          this.focusIndex = focusIndex;
77      }
78  
79  
80      /***
81       * <p>The JavaScript reset event handler.</p>
82       */
83      protected String onreset = null;
84  
85      public void setOnreset(String onreset) {
86          this.onreset = onreset;
87      }
88  
89  
90      /***
91       * <p>The JavaScript submit event handler.</p>
92       */
93      protected String onsubmit = null;
94  
95      public void setOnsubmit(String onsubmit) {
96          this.onsubmit = onsubmit;
97      }
98  
99  
100     /***
101      * <p>The window target for this submit.</p>
102      */
103     protected String target = null;
104 
105     public void setTarget(String target) {
106         this.target = target;
107     }
108 
109 
110     // ------------------------------------------------------------- Tag Methods
111 
112 
113     /***
114      * <p>Release any allocated resources.</p>
115      */
116     public void release() {
117 
118         super.release();
119         action = null;
120         enctype = null;
121         focus = null;
122         focusIndex = null;
123         onreset = null;
124         onsubmit = null;
125         target = null;
126 
127     }
128 
129 
130     // ---------------------------------------------------------- Public Methods
131 
132 
133     /***
134      * <p>Return the type of component to be created for this tag.</p>
135      */
136     public String getComponentType() {
137 
138         return ("org.apache.struts.faces.Form");
139 
140     }
141 
142 
143     /***
144      * <p>Return the <code>rendererType</code> to be used for rendering
145      * our component.</p>
146      */
147     public String getRendererType() {
148 
149         return ("org.apache.struts.faces.Form");
150 
151     }
152 
153 
154     // ------------------------------------------------------- Protected Methods
155 
156 
157     /***
158      * <p>Override attributes set on this tag instance.</p>
159      *
160      * @param component Component whose attributes should be overridden
161      */
162     protected void setProperties(UIComponent component) {
163 
164         super.setProperties(component);
165         setStringAttribute(component, "action", action);
166         setStringAttribute(component, "enctype", enctype);
167         setStringAttribute(component, "focus", focus);
168         setStringAttribute(component, "focusIndex", focusIndex);
169         setStringAttribute(component, "onreset", onreset);
170         setStringAttribute(component, "onsubmit", onsubmit);
171         setStringAttribute(component, "target", target);
172 
173     }
174 
175 
176 }