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.ViewDialogComponent;
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 class ViewDialogTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(ViewDialogTag.class);
20
21 private ValueExpression imageURL;
22 private ValueExpression styleClass;
23 private ValueExpression text;
24 private ValueExpression textDirection;
25 private ValueExpression visible;
26 private ValueExpression dialogPriority;
27 private ValueExpression width;
28 private ValueExpression height;
29 private ValueExpression hiddenMode;
30 private ValueExpression lookId;
31 private ValueExpression ariaLabel;
32 private ValueExpression ariaLevel;
33 private ValueExpression waiRole;
34 private ValueExpression closeListeners;
35 private ValueExpression closable;
36 private ValueExpression immediate;
37 private ValueExpression viewURL;
38 private ValueExpression shellDecoratorName;
39 private ValueExpression value;
40 private ValueExpression converter;
41 public String getComponentType() {
42 return ViewDialogComponent.COMPONENT_TYPE;
43 }
44
45 public final void setImageURL(ValueExpression imageURL) {
46 this.imageURL = imageURL;
47 }
48
49 public final void setStyleClass(ValueExpression styleClass) {
50 this.styleClass = styleClass;
51 }
52
53 public final void setText(ValueExpression text) {
54 this.text = text;
55 }
56
57 public final void setTextDirection(ValueExpression textDirection) {
58 this.textDirection = textDirection;
59 }
60
61 public final void setVisible(ValueExpression visible) {
62 this.visible = visible;
63 }
64
65 public final void setDialogPriority(ValueExpression dialogPriority) {
66 this.dialogPriority = dialogPriority;
67 }
68
69 public final void setWidth(ValueExpression width) {
70 this.width = width;
71 }
72
73 public final void setHeight(ValueExpression height) {
74 this.height = height;
75 }
76
77 public final void setHiddenMode(ValueExpression hiddenMode) {
78 this.hiddenMode = hiddenMode;
79 }
80
81 public final void setLookId(ValueExpression lookId) {
82 this.lookId = lookId;
83 }
84
85 public final void setAriaLabel(ValueExpression ariaLabel) {
86 this.ariaLabel = ariaLabel;
87 }
88
89 public final void setAriaLevel(ValueExpression ariaLevel) {
90 this.ariaLevel = ariaLevel;
91 }
92
93 public final void setWaiRole(ValueExpression waiRole) {
94 this.waiRole = waiRole;
95 }
96
97 public final void setCloseListener(ValueExpression closeListeners) {
98 this.closeListeners = closeListeners;
99 }
100
101 public final void setClosable(ValueExpression closable) {
102 this.closable = closable;
103 }
104
105 public final void setImmediate(ValueExpression immediate) {
106 this.immediate = immediate;
107 }
108
109 public final void setViewURL(ValueExpression viewURL) {
110 this.viewURL = viewURL;
111 }
112
113 public final void setShellDecoratorName(ValueExpression shellDecoratorName) {
114 this.shellDecoratorName = shellDecoratorName;
115 }
116
117 public final void setValue(ValueExpression value) {
118 this.value = value;
119 }
120
121 public final void setConverter(ValueExpression converter) {
122 this.converter = converter;
123 }
124
125 protected void setProperties(UIComponent uiComponent) {
126 if (LOG.isDebugEnabled()) {
127 if (ViewDialogComponent.COMPONENT_TYPE==getComponentType()) {
128 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
129 }
130 LOG.debug(" imageURL='"+imageURL+"'");
131 LOG.debug(" styleClass='"+styleClass+"'");
132 LOG.debug(" text='"+text+"'");
133 LOG.debug(" textDirection='"+textDirection+"'");
134 LOG.debug(" visible='"+visible+"'");
135 LOG.debug(" dialogPriority='"+dialogPriority+"'");
136 LOG.debug(" width='"+width+"'");
137 LOG.debug(" height='"+height+"'");
138 LOG.debug(" hiddenMode='"+hiddenMode+"'");
139 LOG.debug(" lookId='"+lookId+"'");
140 LOG.debug(" ariaLabel='"+ariaLabel+"'");
141 LOG.debug(" ariaLevel='"+ariaLevel+"'");
142 LOG.debug(" waiRole='"+waiRole+"'");
143 LOG.debug(" closable='"+closable+"'");
144 LOG.debug(" immediate='"+immediate+"'");
145 LOG.debug(" viewURL='"+viewURL+"'");
146 LOG.debug(" shellDecoratorName='"+shellDecoratorName+"'");
147 }
148 if ((uiComponent instanceof ViewDialogComponent)==false) {
149 if (uiComponent instanceof UIViewRoot) {
150 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
151 }
152 throw new IllegalStateException("Component specified by tag is not instanceof of 'ViewDialogComponent'.");
153 }
154
155 super.setProperties(uiComponent);
156
157 ViewDialogComponent component = (ViewDialogComponent) uiComponent;
158 FacesContext facesContext = getFacesContext();
159
160 if (imageURL != null) {
161 if (imageURL.isLiteralText()==false) {
162 component.setValueExpression(Properties.IMAGE_URL, imageURL);
163
164 } else {
165 component.setImageURL(imageURL.getExpressionString());
166 }
167 }
168
169 if (styleClass != null) {
170 if (styleClass.isLiteralText()==false) {
171 component.setValueExpression(Properties.STYLE_CLASS, styleClass);
172
173 } else {
174 component.setStyleClass(styleClass.getExpressionString());
175 }
176 }
177
178 if (text != null) {
179 if (text.isLiteralText()==false) {
180 component.setValueExpression(Properties.TEXT, text);
181
182 } else {
183 component.setText(text.getExpressionString());
184 }
185 }
186
187 if (textDirection != null) {
188 if (textDirection.isLiteralText()==false) {
189 component.setValueExpression(Properties.TEXT_DIRECTION, textDirection);
190
191 } else {
192 component.setTextDirection(getInt(textDirection.getExpressionString()));
193 }
194 }
195
196 if (visible != null) {
197 if (visible.isLiteralText()==false) {
198 component.setValueExpression(Properties.VISIBLE, visible);
199
200 } else {
201 component.setVisible(getBool(visible.getExpressionString()));
202 }
203 }
204
205 if (dialogPriority != null) {
206 if (dialogPriority.isLiteralText()==false) {
207 component.setValueExpression(Properties.DIALOG_PRIORITY, dialogPriority);
208
209 } else {
210 component.setDialogPriority(getInt(dialogPriority.getExpressionString()));
211 }
212 }
213
214 if (width != null) {
215 if (width.isLiteralText()==false) {
216 component.setValueExpression(Properties.WIDTH, width);
217
218 } else {
219 component.setWidth(width.getExpressionString());
220 }
221 }
222
223 if (height != null) {
224 if (height.isLiteralText()==false) {
225 component.setValueExpression(Properties.HEIGHT, height);
226
227 } else {
228 component.setHeight(height.getExpressionString());
229 }
230 }
231
232 if (hiddenMode != null) {
233 if (hiddenMode.isLiteralText()==false) {
234 component.setValueExpression(Properties.HIDDEN_MODE, hiddenMode);
235
236 } else {
237 component.setHiddenMode(hiddenMode.getExpressionString());
238 }
239 }
240
241 if (lookId != null) {
242 if (lookId.isLiteralText()==false) {
243 component.setValueExpression(Properties.LOOK_ID, lookId);
244
245 } else {
246 component.setLookId(lookId.getExpressionString());
247 }
248 }
249
250 if (ariaLabel != null) {
251 if (ariaLabel.isLiteralText()==false) {
252 component.setValueExpression(Properties.ARIA_LABEL, ariaLabel);
253
254 } else {
255 component.setAriaLabel(ariaLabel.getExpressionString());
256 }
257 }
258
259 if (ariaLevel != null) {
260 if (ariaLevel.isLiteralText()==false) {
261 component.setValueExpression(Properties.ARIA_LEVEL, ariaLevel);
262
263 } else {
264 component.setAriaLevel(getInt(ariaLevel.getExpressionString()));
265 }
266 }
267
268 if (waiRole != null) {
269 if (waiRole.isLiteralText()==false) {
270 component.setValueExpression(Properties.WAI_ROLE, waiRole);
271
272 } else {
273 component.setWaiRole(waiRole.getExpressionString());
274 }
275 }
276
277 if (closeListeners != null) {
278 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.CLOSE_LISTENER_TYPE, closeListeners);
279 }
280
281 if (closable != null) {
282 if (closable.isLiteralText()==false) {
283 component.setValueExpression(Properties.CLOSABLE, closable);
284
285 } else {
286 component.setClosable(getBool(closable.getExpressionString()));
287 }
288 }
289
290 if (immediate != null) {
291 if (immediate.isLiteralText()==false) {
292 component.setValueExpression(Properties.IMMEDIATE, immediate);
293
294 } else {
295 component.setImmediate(getBool(immediate.getExpressionString()));
296 }
297 }
298
299 if (viewURL != null) {
300 if (viewURL.isLiteralText()==false) {
301 component.setValueExpression(Properties.VIEW_URL, viewURL);
302
303 } else {
304 component.setViewURL(viewURL.getExpressionString());
305 }
306 }
307
308 if (shellDecoratorName != null) {
309 if (shellDecoratorName.isLiteralText()==false) {
310 component.setValueExpression(Properties.SHELL_DECORATOR_NAME, shellDecoratorName);
311
312 } else {
313 component.setShellDecoratorName(shellDecoratorName.getExpressionString());
314 }
315 }
316
317 if (value != null) {
318 if (value.isLiteralText()==false) {
319 component.setValueExpression(Properties.VALUE, value);
320
321 } else {
322 component.setValue(value.getExpressionString());
323 }
324 }
325
326 if (converter != null) {
327 if (converter.isLiteralText()==false) {
328 component.setValueExpression(Properties.CONVERTER, converter);
329
330 } else {
331 component.setConverter(converter.getExpressionString());
332 }
333 }
334 }
335
336 public void release() {
337 imageURL = null;
338 styleClass = null;
339 text = null;
340 textDirection = null;
341 visible = null;
342 dialogPriority = null;
343 width = null;
344 height = null;
345 hiddenMode = null;
346 lookId = null;
347 ariaLabel = null;
348 ariaLevel = null;
349 waiRole = null;
350 closeListeners = null;
351 closable = null;
352 immediate = null;
353 viewURL = null;
354 shellDecoratorName = null;
355 value = null;
356 converter = null;
357
358 super.release();
359 }
360
361 }