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.ComponentsListComponent;
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 ComponentsListTag extends AbstractDataTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(ComponentsListTag.class);
20
21 private ValueExpression border;
22 private ValueExpression borderType;
23 private ValueExpression horizontalScrollPosition;
24 private ValueExpression verticalScrollPosition;
25 private ValueExpression showValue;
26 private ValueExpression rowCountVar;
27 private ValueExpression rowIndexVar;
28 private ValueExpression columnNumber;
29 private ValueExpression rowStyleClass;
30 private ValueExpression columnStyleClass;
31 public String getComponentType() {
32 return ComponentsListComponent.COMPONENT_TYPE;
33 }
34
35 public final void setBorder(ValueExpression border) {
36 this.border = border;
37 }
38
39 public final void setBorderType(ValueExpression borderType) {
40 this.borderType = borderType;
41 }
42
43 public final void setHorizontalScrollPosition(ValueExpression horizontalScrollPosition) {
44 this.horizontalScrollPosition = horizontalScrollPosition;
45 }
46
47 public final void setVerticalScrollPosition(ValueExpression verticalScrollPosition) {
48 this.verticalScrollPosition = verticalScrollPosition;
49 }
50
51 public final void setShowValue(ValueExpression showValue) {
52 this.showValue = showValue;
53 }
54
55 public final void setRowCountVar(ValueExpression rowCountVar) {
56 this.rowCountVar = rowCountVar;
57 }
58
59 public final void setRowIndexVar(ValueExpression rowIndexVar) {
60 this.rowIndexVar = rowIndexVar;
61 }
62
63 public final void setColumnNumber(ValueExpression columnNumber) {
64 this.columnNumber = columnNumber;
65 }
66
67 public final void setRowStyleClass(ValueExpression rowStyleClass) {
68 this.rowStyleClass = rowStyleClass;
69 }
70
71 public final void setColumnStyleClass(ValueExpression columnStyleClass) {
72 this.columnStyleClass = columnStyleClass;
73 }
74
75 protected void setProperties(UIComponent uiComponent) {
76 if (LOG.isDebugEnabled()) {
77 if (ComponentsListComponent.COMPONENT_TYPE==getComponentType()) {
78 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
79 }
80 LOG.debug(" border='"+border+"'");
81 LOG.debug(" borderType='"+borderType+"'");
82 LOG.debug(" horizontalScrollPosition='"+horizontalScrollPosition+"'");
83 LOG.debug(" verticalScrollPosition='"+verticalScrollPosition+"'");
84 LOG.debug(" showValue='"+showValue+"'");
85 LOG.debug(" rowCountVar='"+rowCountVar+"'");
86 LOG.debug(" rowIndexVar='"+rowIndexVar+"'");
87 LOG.debug(" columnNumber='"+columnNumber+"'");
88 LOG.debug(" rowStyleClass='"+rowStyleClass+"'");
89 LOG.debug(" columnStyleClass='"+columnStyleClass+"'");
90 }
91 if ((uiComponent instanceof ComponentsListComponent)==false) {
92 if (uiComponent instanceof UIViewRoot) {
93 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
94 }
95 throw new IllegalStateException("Component specified by tag is not instanceof of 'ComponentsListComponent'.");
96 }
97
98 super.setProperties(uiComponent);
99
100 ComponentsListComponent component = (ComponentsListComponent) uiComponent;
101 FacesContext facesContext = getFacesContext();
102
103 if (border != null) {
104 if (border.isLiteralText()==false) {
105 component.setValueExpression(Properties.BORDER, border);
106
107 } else {
108 component.setBorder(getBool(border.getExpressionString()));
109 }
110 }
111
112 if (borderType != null) {
113 if (borderType.isLiteralText()==false) {
114 component.setValueExpression(Properties.BORDER_TYPE, borderType);
115
116 } else {
117 component.setBorderType(borderType.getExpressionString());
118 }
119 }
120
121 if (horizontalScrollPosition != null) {
122 if (horizontalScrollPosition.isLiteralText()==false) {
123 component.setValueExpression(Properties.HORIZONTAL_SCROLL_POSITION, horizontalScrollPosition);
124
125 } else {
126 component.setHorizontalScrollPosition(getInt(horizontalScrollPosition.getExpressionString()));
127 }
128 }
129
130 if (verticalScrollPosition != null) {
131 if (verticalScrollPosition.isLiteralText()==false) {
132 component.setValueExpression(Properties.VERTICAL_SCROLL_POSITION, verticalScrollPosition);
133
134 } else {
135 component.setVerticalScrollPosition(getInt(verticalScrollPosition.getExpressionString()));
136 }
137 }
138
139 if (showValue != null) {
140 if (showValue.isLiteralText()==false) {
141 component.setValueExpression(Properties.SHOW_VALUE, showValue);
142
143 } else {
144 component.setShowValue(showValue.getExpressionString());
145 }
146 }
147
148 if (rowCountVar != null) {
149 if (rowCountVar.isLiteralText()==false) {
150 throw new javax.faces.FacesException("Attribute 'rowCountVar' does not accept binding !");
151 }
152 component.setRowCountVar(rowCountVar.getExpressionString());
153 }
154
155 if (rowIndexVar != null) {
156 if (rowIndexVar.isLiteralText()==false) {
157 throw new javax.faces.FacesException("Attribute 'rowIndexVar' does not accept binding !");
158 }
159 component.setRowIndexVar(rowIndexVar.getExpressionString());
160 }
161
162 if (columnNumber != null) {
163 if (columnNumber.isLiteralText()==false) {
164 component.setValueExpression(Properties.COLUMN_NUMBER, columnNumber);
165
166 } else {
167 component.setColumnNumber(getInt(columnNumber.getExpressionString()));
168 }
169 }
170
171 if (rowStyleClass != null) {
172 if (rowStyleClass.isLiteralText()==false) {
173 component.setValueExpression(Properties.ROW_STYLE_CLASS, rowStyleClass);
174
175 } else {
176 component.setRowStyleClass(rowStyleClass.getExpressionString());
177 }
178 }
179
180 if (columnStyleClass != null) {
181 if (columnStyleClass.isLiteralText()==false) {
182 component.setValueExpression(Properties.COLUMN_STYLE_CLASS, columnStyleClass);
183
184 } else {
185 component.setColumnStyleClass(columnStyleClass.getExpressionString());
186 }
187 }
188 }
189
190 public void release() {
191 border = null;
192 borderType = null;
193 horizontalScrollPosition = null;
194 verticalScrollPosition = null;
195 showValue = null;
196 rowCountVar = null;
197 rowIndexVar = null;
198 columnNumber = null;
199 rowStyleClass = null;
200 columnStyleClass = null;
201
202 super.release();
203 }
204
205 }