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.component.TextEditorToolFolderComponent;
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 TextEditorToolFolderTag extends ToolFolderTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(TextEditorToolFolderTag.class);
20
21 private ValueExpression itemTypes;
22 private ValueExpression fontSizes;
23 private ValueExpression fontNames;
24 private ValueExpression forVal;
25 public String getComponentType() {
26 return TextEditorToolFolderComponent.COMPONENT_TYPE;
27 }
28
29 public final void setItemTypes(ValueExpression itemTypes) {
30 this.itemTypes = itemTypes;
31 }
32
33 public final void setFontSizes(ValueExpression fontSizes) {
34 this.fontSizes = fontSizes;
35 }
36
37 public final void setFontNames(ValueExpression fontNames) {
38 this.fontNames = fontNames;
39 }
40
41 public final void setFor(ValueExpression forVal) {
42 this.forVal = forVal;
43 }
44
45 protected void setProperties(UIComponent uiComponent) {
46 if (LOG.isDebugEnabled()) {
47 if (TextEditorToolFolderComponent.COMPONENT_TYPE==getComponentType()) {
48 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
49 }
50 LOG.debug(" itemTypes='"+itemTypes+"'");
51 LOG.debug(" fontSizes='"+fontSizes+"'");
52 LOG.debug(" fontNames='"+fontNames+"'");
53 LOG.debug(" forVal='"+forVal+"'");
54 }
55 if ((uiComponent instanceof TextEditorToolFolderComponent)==false) {
56 if (uiComponent instanceof UIViewRoot) {
57 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
58 }
59 throw new IllegalStateException("Component specified by tag is not instanceof of 'TextEditorToolFolderComponent'.");
60 }
61
62 super.setProperties(uiComponent);
63
64 TextEditorToolFolderComponent component = (TextEditorToolFolderComponent) uiComponent;
65 FacesContext facesContext = getFacesContext();
66
67 if (itemTypes != null) {
68 if (itemTypes.isLiteralText()==false) {
69 component.setValueExpression(Properties.ITEM_TYPES, itemTypes);
70
71 } else {
72 component.setItemTypes(itemTypes.getExpressionString());
73 }
74 }
75
76 if (fontSizes != null) {
77 if (fontSizes.isLiteralText()==false) {
78 component.setValueExpression(Properties.FONT_SIZES, fontSizes);
79
80 } else {
81 component.setFontSizes(fontSizes.getExpressionString());
82 }
83 }
84
85 if (fontNames != null) {
86 if (fontNames.isLiteralText()==false) {
87 component.setValueExpression(Properties.FONT_NAMES, fontNames);
88
89 } else {
90 component.setFontNames(fontNames.getExpressionString());
91 }
92 }
93
94 if (forVal != null) {
95 if (forVal.isLiteralText()==false) {
96 component.setValueExpression(Properties.FOR, forVal);
97
98 } else {
99 component.setFor(forVal.getExpressionString());
100 }
101 }
102 }
103
104 public void release() {
105 itemTypes = null;
106 fontSizes = null;
107 fontNames = null;
108 forVal = null;
109
110 super.release();
111 }
112
113 }