KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > cocoon > faces > samples > components > taglib > AreaTag


1 /*
2  * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
3  *
4  * Redistribution and use in source and binary forms, with or
5  * without modification, are permitted provided that the following
6  * conditions are met:
7  *
8  * - Redistributions of source code must retain the above copyright
9  * notice, this list of conditions and the following disclaimer.
10  *
11  * - Redistribution in binary form must reproduce the above
12  * copyright notice, this list of conditions and the following
13  * disclaimer in the documentation and/or other materials
14  * provided with the distribution.
15  *
16  * Neither the name of Sun Microsystems, Inc. or the names of
17  * contributors may be used to endorse or promote products derived
18  * from this software without specific prior written permission.
19  *
20  * This software is provided "AS IS," without a warranty of any
21  * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
22  * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
23  * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
24  * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
25  * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
26  * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
27  * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
28  * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
29  * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
30  * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
31  * THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
32  * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
33  *
34  * You acknowledge that this software is not designed, licensed or
35  * intended for use in the design, construction, operation or
36  * maintenance of any nuclear facility.
37  */

38
39 package org.apache.cocoon.faces.samples.components.taglib;
40
41 import org.apache.cocoon.faces.FacesUtils;
42 import org.apache.cocoon.faces.taglib.UIComponentTag;
43 import org.apache.cocoon.faces.samples.components.components.AreaComponent;
44 import org.apache.cocoon.faces.samples.components.renderkit.Util;
45
46 import javax.faces.component.UIComponent;
47 import javax.faces.component.ValueHolder;
48
49
50 /**
51  * <p>{@link UIComponentTag} for an image map hotspot.</p>
52  */

53
54 public class AreaTag extends UIComponentTag {
55
56
57     private String JavaDoc alt = null;
58
59
60     public void setAlt(String JavaDoc alt) {
61         this.alt = alt;
62     }
63
64
65     private String JavaDoc targetImage = null;
66
67
68     public void setTargetImage(String JavaDoc targetImage) {
69         this.targetImage = targetImage;
70     }
71
72
73     private String JavaDoc coords = null;
74
75
76     public void setCoords(String JavaDoc coords) {
77         this.coords = coords;
78     }
79
80
81     private String JavaDoc onmouseout = null;
82
83
84     public void setOnmouseout(String JavaDoc newonmouseout) {
85         onmouseout = newonmouseout;
86     }
87
88
89     private String JavaDoc onmouseover = null;
90
91
92     public void setOnmouseover(String JavaDoc newonmouseover) {
93         onmouseover = newonmouseover;
94     }
95
96
97     private String JavaDoc shape = null;
98
99
100     public void setShape(String JavaDoc shape) {
101         this.shape = shape;
102     }
103
104
105     private String JavaDoc styleClass = null;
106
107
108     public void setStyleClass(String JavaDoc styleClass) {
109         this.styleClass = styleClass;
110     }
111
112
113     private String JavaDoc value = null;
114
115
116     public void setValue(String JavaDoc newValue) {
117         value = newValue;
118     }
119
120
121     public String JavaDoc getComponentType() {
122         return ("DemoArea");
123     }
124
125
126     public String JavaDoc getRendererType() {
127         return ("DemoArea");
128     }
129
130
131     public void recycle() {
132         super.recycle();
133         this.alt = null;
134         this.coords = null;
135         this.onmouseout = null;
136         this.onmouseover = null;
137         this.shape = null;
138         this.styleClass = null;
139         this.value = null;
140     }
141
142
143     protected void setProperties(UIComponent component) {
144         super.setProperties(component);
145         AreaComponent area = (AreaComponent) component;
146         if (alt != null) {
147             if (FacesUtils.isExpression(alt)) {
148                 area.setValueBinding("alt", Util.getValueBinding(alt));
149             } else {
150                 area.getAttributes().put("alt", alt);
151             }
152         }
153         if (coords != null) {
154             if (FacesUtils.isExpression(coords)) {
155                 area.setValueBinding("coords", Util.getValueBinding(coords));
156             } else {
157                 area.getAttributes().put("coords", coords);
158             }
159         }
160         if (onmouseout != null) {
161             if (FacesUtils.isExpression(onmouseout)) {
162                 area.setValueBinding("onmouseout",
163                                      Util.getValueBinding(onmouseout));
164             } else {
165                 area.getAttributes().put("onmouseout", onmouseout);
166             }
167         }
168         if (onmouseover != null) {
169             if (FacesUtils.isExpression(onmouseover)) {
170                 area.setValueBinding("onmouseover",
171                                      Util.getValueBinding(onmouseover));
172             } else {
173                 area.getAttributes().put("onmouseover", onmouseover);
174             }
175         }
176         if (shape != null) {
177             if (FacesUtils.isExpression(shape)) {
178                 area.setValueBinding("shape", Util.getValueBinding(shape));
179             } else {
180                 area.getAttributes().put("shape", shape);
181             }
182         }
183         if (styleClass != null) {
184             if (FacesUtils.isExpression(styleClass)) {
185                 area.setValueBinding("styleClass",
186                                      Util.getValueBinding(styleClass));
187             } else {
188                 area.getAttributes().put("styleClass", styleClass);
189             }
190         }
191         if (area instanceof ValueHolder) {
192             ValueHolder valueHolder = (ValueHolder) component;
193             if (value != null) {
194                 if (FacesUtils.isExpression(value)) {
195                     area.setValueBinding("value", Util.getValueBinding(value));
196                 } else {
197                     valueHolder.setValue(value);
198                 }
199             }
200         }
201         // target image is required
202
area.setTargetImage(targetImage);
203     }
204 }
205
Popular Tags