1 package org.rcfaces.core.internal.taglib;
2
3 import javax.faces.application.Application;
4 import javax.faces.component.UIComponent;
5 import org.rcfaces.core.internal.component.Properties;
6 import org.rcfaces.core.component.ExpandableItemComponent;
7 import javax.el.ValueExpression;
8 import javax.faces.component.UIViewRoot;
9 import org.apache.commons.logging.Log;
10 import javax.servlet.jsp.tagext.Tag;
11 import org.apache.commons.logging.LogFactory;
12 import org.rcfaces.core.internal.tools.ListenersTools1_2;
13 import org.rcfaces.core.internal.tools.ListenersTools;
14 import javax.faces.context.FacesContext;
15
16 public abstract class ExpandableItemTag extends UIImageItemTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(ExpandableItemTag.class);
20
21 private ValueExpression backgroundColor;
22 private ValueExpression foregroundColor;
23 private ValueExpression text;
24 private ValueExpression expandedImageURL;
25 public final void setBackgroundColor(ValueExpression backgroundColor) {
26 this.backgroundColor = backgroundColor;
27 }
28
29 public final void setForegroundColor(ValueExpression foregroundColor) {
30 this.foregroundColor = foregroundColor;
31 }
32
33 public final void setText(ValueExpression text) {
34 this.text = text;
35 }
36
37 public final void setExpandedImageURL(ValueExpression expandedImageURL) {
38 this.expandedImageURL = expandedImageURL;
39 }
40
41 protected void setProperties(UIComponent uiComponent) {
42 if (LOG.isDebugEnabled()) {
43 LOG.debug(" backgroundColor='"+backgroundColor+"'");
44 LOG.debug(" foregroundColor='"+foregroundColor+"'");
45 LOG.debug(" text='"+text+"'");
46 LOG.debug(" expandedImageURL='"+expandedImageURL+"'");
47 }
48 if ((uiComponent instanceof ExpandableItemComponent)==false) {
49 if (uiComponent instanceof UIViewRoot) {
50 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
51 }
52 throw new IllegalStateException("Component specified by tag is not instanceof of 'ExpandableItemComponent'.");
53 }
54
55 super.setProperties(uiComponent);
56
57 ExpandableItemComponent component = (ExpandableItemComponent) uiComponent;
58 FacesContext facesContext = getFacesContext();
59
60 if (backgroundColor != null) {
61 if (backgroundColor.isLiteralText()==false) {
62 component.setValueExpression(Properties.BACKGROUND_COLOR, backgroundColor);
63
64 } else {
65 component.setBackgroundColor(backgroundColor.getExpressionString());
66 }
67 }
68
69 if (foregroundColor != null) {
70 if (foregroundColor.isLiteralText()==false) {
71 component.setValueExpression(Properties.FOREGROUND_COLOR, foregroundColor);
72
73 } else {
74 component.setForegroundColor(foregroundColor.getExpressionString());
75 }
76 }
77
78 if (text != null) {
79 if (text.isLiteralText()==false) {
80 component.setValueExpression(Properties.TEXT, text);
81
82 } else {
83 component.setText(text.getExpressionString());
84 }
85 }
86
87 if (expandedImageURL != null) {
88 if (expandedImageURL.isLiteralText()==false) {
89 component.setValueExpression(Properties.EXPANDED_IMAGE_URL, expandedImageURL);
90
91 } else {
92 component.setExpandedImageURL(expandedImageURL.getExpressionString());
93 }
94 }
95 }
96
97 public void release() {
98 backgroundColor = null;
99 foregroundColor = null;
100 text = null;
101 expandedImageURL = null;
102
103 super.release();
104 }
105
106 }