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 org.rcfaces.core.component.TextEditorComboComponent;
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 class TextEditorComboTag extends ComboTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(TextEditorComboTag.class);
20
21 private ValueExpression forValue;
22 private ValueExpression type;
23 public String getComponentType() {
24 return TextEditorComboComponent.COMPONENT_TYPE;
25 }
26
27 public final void setFor(ValueExpression forValue) {
28 this.forValue = forValue;
29 }
30
31 public final void setType(ValueExpression type) {
32 this.type = type;
33 }
34
35 protected void setProperties(UIComponent uiComponent) {
36 if (LOG.isDebugEnabled()) {
37 if (TextEditorComboComponent.COMPONENT_TYPE==getComponentType()) {
38 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
39 }
40 LOG.debug(" forValue='"+forValue+"'");
41 LOG.debug(" type='"+type+"'");
42 }
43 if ((uiComponent instanceof TextEditorComboComponent)==false) {
44 if (uiComponent instanceof UIViewRoot) {
45 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
46 }
47 throw new IllegalStateException("Component specified by tag is not instanceof of 'TextEditorComboComponent'.");
48 }
49
50 super.setProperties(uiComponent);
51
52 TextEditorComboComponent component = (TextEditorComboComponent) uiComponent;
53 FacesContext facesContext = getFacesContext();
54
55 if (forValue != null) {
56 if (forValue.isLiteralText()==false) {
57 component.setValueExpression(Properties.FOR, forValue);
58
59 } else {
60 component.setFor(forValue.getExpressionString());
61 }
62 }
63
64 if (type != null) {
65 if (type.isLiteralText()==false) {
66 component.setValueExpression(Properties.TYPE, type);
67
68 } else {
69 component.setType(type.getExpressionString());
70 }
71 }
72 }
73
74 public void release() {
75 forValue = null;
76 type = null;
77
78 super.release();
79 }
80
81 }