KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > myfaces > wap > base > ComponentTagBase


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.wap.base;
17
18 import javax.faces.component.UIComponent;
19 import javax.faces.context.FacesContext;
20 import javax.faces.el.ValueBinding;
21 import javax.faces.webapp.UIComponentTag;
22
23 /**
24  * Implements attributes:
25  * <ol>
26  * <li>id
27  * <li>renderer
28  * <li>binding
29  * </ol>
30  *
31  * @author <a HREF="mailto:Jiri.Zaloudek@ivancice.cz">Jiri Zaloudek</a> (latest modification by $Author: matzew $)
32  * @version $Revision: 1.1 $ $Date: 2004/12/30 09:37:27 $
33  * $Log: ComponentTagBase.java,v $
34  * Revision 1.1 2004/12/30 09:37:27 matzew
35  * added a new RenderKit for WML. Thanks to Jirí Žaloudek
36  *
37  */

38
39 public abstract class ComponentTagBase extends UIComponentTag {
40     
41     /* properties */
42     private String JavaDoc id = null;
43     private String JavaDoc rendered = null;
44     private String JavaDoc binding = null;
45     
46     /** Creates a new instance of UIComponentTagBase */
47     public ComponentTagBase() {
48         super();
49     }
50     
51     public abstract String JavaDoc getRendererType();
52     
53     public void release() {
54         super.release();
55         this.id = null;
56         this.rendered = null;
57         this.binding = null;
58     }
59     
60     protected void setProperties(UIComponent component) {
61         super.setProperties(component);
62                 
63         if (getRendererType() != null) {
64             component.setRendererType(getRendererType());
65         }
66         
67         if (id != null) {
68             if (isValueReference(id)) {
69                 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(id);
70                 component.setValueBinding("id", vb);
71             } else {
72                 component.setId(id);
73             }
74         }
75         
76         if (rendered != null) {
77             if (isValueReference(rendered)) {
78                 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(rendered);
79                 component.setValueBinding("rendered", vb);
80             } else {
81                 boolean bool = Boolean.valueOf(rendered).booleanValue();
82                 component.setRendered(bool);
83             }
84         }
85
86         if (binding != null) {
87             if (isValueReference(binding)) {
88                 ValueBinding vb = FacesContext.getCurrentInstance().getApplication().createValueBinding(binding);
89                 component.setValueBinding("binding", vb);
90             } else {
91                 throw new IllegalArgumentException JavaDoc("Not a valid binding: " + binding);
92             }
93         }
94     }
95     // ----------------------------------------------------- Getters and Setters
96

97     /**
98      * Getter for property id.
99      * @return value of property id.
100      */

101     public String JavaDoc getId() {
102         return id;
103     }
104     
105     /**
106      * Setter for property id.
107      * @param id new value of property id.
108      */

109     public void setId(String JavaDoc id) {
110         this.id = id;
111     }
112     /**
113      * Getter for property rendered.
114      * @return value of property rendered.
115      */

116     public String JavaDoc getRendered() {
117         return rendered;
118     }
119     
120     /**
121      * Setter for property rendered.
122      * @param rendered new value of property rendered.
123      */

124     public void setRendered(String JavaDoc rendered) {
125         this.rendered = rendered;
126     }
127     
128     /**
129      * Setter for property binding.
130      * @param binding new value of property binding.
131      */

132     public void setBinding(String JavaDoc binding) {
133         if (!isValueReference(binding)) {
134             throw new IllegalArgumentException JavaDoc("Not a valid binding: " + binding);
135         }
136         this.binding = binding;
137     }
138 }
139
Popular Tags