KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > taglib > UIComponentTagBase


1 /*
2  * Copyright 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 package org.apache.myfaces.taglib;
17
18 import org.apache.myfaces.renderkit.JSFAttr;
19
20 import javax.faces.component.UIComponent;
21 import javax.faces.webapp.UIComponentTag;
22
23 /**
24  * @author Manfred Geiler (latest modification by $Author: matzew $)
25  * @version $Revision: 1.13 $ $Date: 2005/03/07 09:06:51 $
26  * $Log: UIComponentTagBase.java,v $
27  * Revision 1.13 2005/03/07 09:06:51 matzew
28  * Patch for the new tree form Sean Schofield
29  *
30  * Revision 1.12 2005/02/18 17:19:30 matzew
31  * added release() to tag clazzes.
32  *
33  * Revision 1.11 2005/01/30 15:24:10 matzew
34  * thanks to sean schofield for removing *legacy* attributes of MyFaces
35  *
36  * Revision 1.10 2005/01/28 17:19:09 matzew
37  * Patch for MYFACES-91 form Sean Schofield
38  *
39  * Revision 1.9 2005/01/25 22:15:53 matzew
40  * JavaDoc patch form Sean Schofield
41  *
42  * Revision 1.8 2005/01/10 08:08:12 matzew
43  * added patch form sean schofield. forceId for reuse of "legacy JavaScript" (MyFaces-70)
44  *
45  * Revision 1.7 2004/10/13 11:51:01 matze
46  * renamed packages to org.apache
47  *
48  * Revision 1.6 2004/07/01 22:01:21 mwessendorf
49  * ASF switch
50  *
51  * Revision 1.5 2004/04/16 15:13:33 manolito
52  * validator attribute support and MethodBinding invoke exception handling fixed
53  *
54  * Revision 1.4 2004/04/05 11:04:57 manolito
55  * setter for renderer type removed, no more default renderer type needed
56  *
57  * Revision 1.3 2004/04/01 09:33:43 manolito
58  * user role support removed
59  *
60  * Revision 1.2 2004/03/30 12:16:08 manolito
61  * header comments
62  *
63  */

64 public abstract class UIComponentTagBase
65         extends UIComponentTag
66 {
67     //private static final Log log = LogFactory.getLog(UIComponentTagBase.class);
68

69     //UIComponent attributes
70
private String JavaDoc _forceId;
71     private String JavaDoc _forceIdIndex = "true";
72     private String JavaDoc _javascriptLocation;
73     private String JavaDoc _imageLocation;
74     private String JavaDoc _styleLocation;
75
76     //Special UIComponent attributes (ValueHolder, ConvertibleValueHolder)
77
private String JavaDoc _value;
78     private String JavaDoc _converter;
79     //attributes id, rendered and binding are handled by UIComponentTag
80

81     public void release() {
82         super.release();
83
84         _forceId=null;
85         //see declaration of that property
86
_forceIdIndex = "true";
87
88         _value=null;
89         _converter=null;
90     }
91
92     protected void setProperties(UIComponent component)
93     {
94         super.setProperties(component);
95
96         setBooleanProperty(component, JSFAttr.FORCE_ID_ATTR, _forceId);
97         setBooleanProperty(component, JSFAttr.FORCE_ID_INDEX_ATTR, _forceIdIndex);
98         if (_javascriptLocation != null) setStringProperty(component, JSFAttr.JAVASCRIPT_LOCATION, _javascriptLocation);
99         if (_imageLocation != null) setStringProperty(component, JSFAttr.IMAGE_LOCATION, _imageLocation);
100         if (_styleLocation != null) setStringProperty(component, JSFAttr.STYLE_LOCATION, _styleLocation);
101
102         //rendererType already handled by UIComponentTag
103

104         setValueProperty(component, _value);
105         setConverterProperty(component, _converter);
106     }
107
108     /**
109      * Sets the forceId attribute of the tag. NOTE: Not every tag that extends this class will
110      * actually make use of this attribute. Check the TLD to see which components actually
111      * implement it.
112      *
113      * @param aForceId The value of the forceId attribute.
114      */

115     public void setForceId(String JavaDoc aForceId)
116     {
117         _forceId = aForceId;
118     }
119
120     /**
121      * Sets the forceIdIndex attribute of the tag. NOTE: Not every tag that extends this class will
122      * actually make use of this attribute. Check the TLD to see which components actually implement it.
123      *
124      * @param aForceIdIndex The value of the forceIdIndex attribute.
125      */

126     public void setForceIdIndex(String JavaDoc aForceIdIndex)
127     {
128         _forceIdIndex = aForceIdIndex;
129     }
130
131     public void setValue(String JavaDoc value)
132     {
133         _value = value;
134     }
135
136     public void setConverter(String JavaDoc converter)
137     {
138         _converter = converter;
139     }
140
141
142     /**
143      * Sets the javascript location attribute of the tag. NOTE: Not every tag that extends this class will
144      * actually make use of this attribute. Check the TLD to see which components actually implement it.
145      *
146      * @param aJavascriptLocation The alternate javascript location to use.
147      */

148     public void setJavascriptLocation(String JavaDoc aJavascriptLocation)
149     {
150         _javascriptLocation = aJavascriptLocation;
151     }
152
153     /**
154      * Sets the image location attribute of the tag. NOTE: Not every tag that extends this class will
155      * actually make use of this attribute. Check the TLD to see which components actually implement it.
156      *
157      * @param aImageLocation The alternate image location to use.
158      */

159     public void setImageLocation(String JavaDoc aImageLocation)
160     {
161         _imageLocation = aImageLocation;
162     }
163
164     /**
165      * Sets the style location attribute of the tag. NOTE: Not every tag that extends this class will
166      * actually make use of this attribute. Check the TLD to see which components actually implement it.
167      *
168      * @param aStyleLocation The alternate style location to use.
169      */

170     public void setStyleLocation(String JavaDoc aStyleLocation)
171     {
172         _styleLocation = aStyleLocation;
173     }
174
175     // sub class helpers
176

177     protected void setIntegerProperty(UIComponent component, String JavaDoc propName, String JavaDoc value)
178     {
179         UIComponentTagUtils.setIntegerProperty(getFacesContext(), component, propName, value);
180     }
181
182     protected void setStringProperty(UIComponent component, String JavaDoc propName, String JavaDoc value)
183     {
184         UIComponentTagUtils.setStringProperty(getFacesContext(), component, propName, value);
185     }
186
187     protected void setBooleanProperty(UIComponent component, String JavaDoc propName, String JavaDoc value)
188     {
189         UIComponentTagUtils.setBooleanProperty(getFacesContext(), component, propName, value);
190     }
191
192     private void setValueProperty(UIComponent component, String JavaDoc value)
193     {
194         UIComponentTagUtils.setValueProperty(getFacesContext(), component, value);
195     }
196
197     private void setConverterProperty(UIComponent component, String JavaDoc value)
198     {
199         UIComponentTagUtils.setConverterProperty(getFacesContext(), component, value);
200     }
201
202     protected void setValidatorProperty(UIComponent component, String JavaDoc value)
203     {
204         UIComponentTagUtils.setValidatorProperty(getFacesContext(), component, value);
205     }
206
207     protected void setActionProperty(UIComponent component, String JavaDoc action)
208     {
209         UIComponentTagUtils.setActionProperty(getFacesContext(), component, action);
210     }
211
212     protected void setActionListenerProperty(UIComponent component, String JavaDoc actionListener)
213     {
214         UIComponentTagUtils.setActionListenerProperty(getFacesContext(), component, actionListener);
215     }
216
217     protected void setValueChangedListenerProperty(UIComponent component, String JavaDoc valueChangedListener)
218     {
219         UIComponentTagUtils.setValueChangedListenerProperty(getFacesContext(), component, valueChangedListener);
220     }
221
222     protected void setValueBinding(UIComponent component,
223                                    String JavaDoc propName,
224                                    String JavaDoc value)
225     {
226         UIComponentTagUtils.setValueBinding(getFacesContext(), component, propName, value);
227     }
228
229
230 }
231
232
Popular Tags