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 javax.el.ValueExpression;
7 import javax.faces.component.UIViewRoot;
8 import org.apache.commons.logging.Log;
9 import javax.servlet.jsp.tagext.Tag;
10 import org.apache.commons.logging.LogFactory;
11 import org.rcfaces.core.internal.tools.ListenersTools1_2;
12 import org.rcfaces.core.internal.tools.ListenersTools;
13 import org.rcfaces.core.component.TextEditorImageButtonComponent;
14 import javax.faces.context.FacesContext;
15
16 public class TextEditorImageButtonTag extends ImageButtonTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(TextEditorImageButtonTag.class);
20
21 private ValueExpression forValue;
22 private ValueExpression groupName;
23 private ValueExpression type;
24 public String getComponentType() {
25 return TextEditorImageButtonComponent.COMPONENT_TYPE;
26 }
27
28 public final void setFor(ValueExpression forValue) {
29 this.forValue = forValue;
30 }
31
32 public final void setGroupName(ValueExpression groupName) {
33 this.groupName = groupName;
34 }
35
36 public final void setType(ValueExpression type) {
37 this.type = type;
38 }
39
40 protected void setProperties(UIComponent uiComponent) {
41 if (LOG.isDebugEnabled()) {
42 if (TextEditorImageButtonComponent.COMPONENT_TYPE==getComponentType()) {
43 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
44 }
45 LOG.debug(" forValue='"+forValue+"'");
46 LOG.debug(" groupName='"+groupName+"'");
47 LOG.debug(" type='"+type+"'");
48 }
49 if ((uiComponent instanceof TextEditorImageButtonComponent)==false) {
50 if (uiComponent instanceof UIViewRoot) {
51 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
52 }
53 throw new IllegalStateException("Component specified by tag is not instanceof of 'TextEditorImageButtonComponent'.");
54 }
55
56 super.setProperties(uiComponent);
57
58 TextEditorImageButtonComponent component = (TextEditorImageButtonComponent) uiComponent;
59 FacesContext facesContext = getFacesContext();
60
61 if (forValue != null) {
62 if (forValue.isLiteralText()==false) {
63 component.setValueExpression(Properties.FOR, forValue);
64
65 } else {
66 component.setFor(forValue.getExpressionString());
67 }
68 }
69
70 if (groupName != null) {
71 if (groupName.isLiteralText()==false) {
72 component.setValueExpression(Properties.GROUP_NAME, groupName);
73
74 } else {
75 component.setGroupName(groupName.getExpressionString());
76 }
77 }
78
79 if (type != null) {
80 if (type.isLiteralText()==false) {
81 component.setValueExpression(Properties.TYPE, type);
82
83 } else {
84 component.setType(type.getExpressionString());
85 }
86 }
87 }
88
89 public void release() {
90 forValue = null;
91 groupName = null;
92 type = null;
93
94 super.release();
95 }
96
97 }