001: /*
002: * Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
003: *
004: * Redistribution and use in source and binary forms, with or
005: * without modification, are permitted provided that the following
006: * conditions are met:
007: *
008: * - Redistributions of source code must retain the above copyright
009: * notice, this list of conditions and the following disclaimer.
010: *
011: * - Redistribution in binary form must reproduce the above
012: * copyright notice, this list of conditions and the following
013: * disclaimer in the documentation and/or other materials
014: * provided with the distribution.
015: *
016: * Neither the name of Sun Microsystems, Inc. or the names of
017: * contributors may be used to endorse or promote products derived
018: * from this software without specific prior written permission.
019: *
020: * This software is provided "AS IS," without a warranty of any
021: * kind. ALL EXPRESS OR IMPLIED CONDITIONS, REPRESENTATIONS AND
022: * WARRANTIES, INCLUDING ANY IMPLIED WARRANTY OF MERCHANTABILITY,
023: * FITNESS FOR A PARTICULAR PURPOSE OR NON-INFRINGEMENT, ARE HEREBY
024: * EXCLUDED. SUN AND ITS LICENSORS SHALL NOT BE LIABLE FOR ANY
025: * DAMAGES OR LIABILITIES SUFFERED BY LICENSEE AS A RESULT OF OR
026: * RELATING TO USE, MODIFICATION OR DISTRIBUTION OF THIS SOFTWARE OR
027: * ITS DERIVATIVES. IN NO EVENT WILL SUN OR ITS LICENSORS BE LIABLE
028: * FOR ANY LOST REVENUE, PROFIT OR DATA, OR FOR DIRECT, INDIRECT,
029: * SPECIAL, CONSEQUENTIAL, INCIDENTAL OR PUNITIVE DAMAGES, HOWEVER
030: * CAUSED AND REGARDLESS OF THE THEORY OF LIABILITY, ARISING OUT OF
031: * THE USE OF OR INABILITY TO USE THIS SOFTWARE, EVEN IF SUN HAS
032: * BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
033: *
034: * You acknowledge that this software is not designed, licensed or
035: * intended for use in the design, construction, operation or
036: * maintenance of any nuclear facility.
037: */
038:
039: package org.apache.cocoon.faces.samples.components.taglib;
040:
041: import org.apache.cocoon.faces.FacesUtils;
042: import org.apache.cocoon.faces.taglib.UIComponentTag;
043: import org.apache.cocoon.faces.samples.components.components.AreaComponent;
044: import org.apache.cocoon.faces.samples.components.renderkit.Util;
045:
046: import javax.faces.component.UIComponent;
047: import javax.faces.component.ValueHolder;
048:
049: /**
050: * <p>{@link UIComponentTag} for an image map hotspot.</p>
051: */
052:
053: public class AreaTag extends UIComponentTag {
054:
055: private String alt = null;
056:
057: public void setAlt(String alt) {
058: this .alt = alt;
059: }
060:
061: private String targetImage = null;
062:
063: public void setTargetImage(String targetImage) {
064: this .targetImage = targetImage;
065: }
066:
067: private String coords = null;
068:
069: public void setCoords(String coords) {
070: this .coords = coords;
071: }
072:
073: private String onmouseout = null;
074:
075: public void setOnmouseout(String newonmouseout) {
076: onmouseout = newonmouseout;
077: }
078:
079: private String onmouseover = null;
080:
081: public void setOnmouseover(String newonmouseover) {
082: onmouseover = newonmouseover;
083: }
084:
085: private String shape = null;
086:
087: public void setShape(String shape) {
088: this .shape = shape;
089: }
090:
091: private String styleClass = null;
092:
093: public void setStyleClass(String styleClass) {
094: this .styleClass = styleClass;
095: }
096:
097: private String value = null;
098:
099: public void setValue(String newValue) {
100: value = newValue;
101: }
102:
103: public String getComponentType() {
104: return ("DemoArea");
105: }
106:
107: public String getRendererType() {
108: return ("DemoArea");
109: }
110:
111: public void recycle() {
112: super .recycle();
113: this .alt = null;
114: this .coords = null;
115: this .onmouseout = null;
116: this .onmouseover = null;
117: this .shape = null;
118: this .styleClass = null;
119: this .value = null;
120: }
121:
122: protected void setProperties(UIComponent component) {
123: super .setProperties(component);
124: AreaComponent area = (AreaComponent) component;
125: if (alt != null) {
126: if (FacesUtils.isExpression(alt)) {
127: area.setValueBinding("alt", Util.getValueBinding(alt));
128: } else {
129: area.getAttributes().put("alt", alt);
130: }
131: }
132: if (coords != null) {
133: if (FacesUtils.isExpression(coords)) {
134: area.setValueBinding("coords", Util
135: .getValueBinding(coords));
136: } else {
137: area.getAttributes().put("coords", coords);
138: }
139: }
140: if (onmouseout != null) {
141: if (FacesUtils.isExpression(onmouseout)) {
142: area.setValueBinding("onmouseout", Util
143: .getValueBinding(onmouseout));
144: } else {
145: area.getAttributes().put("onmouseout", onmouseout);
146: }
147: }
148: if (onmouseover != null) {
149: if (FacesUtils.isExpression(onmouseover)) {
150: area.setValueBinding("onmouseover", Util
151: .getValueBinding(onmouseover));
152: } else {
153: area.getAttributes().put("onmouseover", onmouseover);
154: }
155: }
156: if (shape != null) {
157: if (FacesUtils.isExpression(shape)) {
158: area.setValueBinding("shape", Util
159: .getValueBinding(shape));
160: } else {
161: area.getAttributes().put("shape", shape);
162: }
163: }
164: if (styleClass != null) {
165: if (FacesUtils.isExpression(styleClass)) {
166: area.setValueBinding("styleClass", Util
167: .getValueBinding(styleClass));
168: } else {
169: area.getAttributes().put("styleClass", styleClass);
170: }
171: }
172: if (component instanceof ValueHolder) {
173: ValueHolder valueHolder = (ValueHolder) component;
174: if (value != null) {
175: if (FacesUtils.isExpression(value)) {
176: area.setValueBinding("value", Util
177: .getValueBinding(value));
178: } else {
179: valueHolder.setValue(value);
180: }
181: }
182: }
183: // target image is required
184: area.setTargetImage(targetImage);
185: }
186: }
|