1 package org.andromda.cartridges.jsf.taglib;
2
3 import javax.faces.component.UIComponent;
4 import javax.faces.context.FacesContext;
5 import javax.faces.el.MethodBinding;
6 import javax.faces.el.ValueBinding;
7 import javax.faces.webapp.UIComponentBodyTag;
8 import org.andromda.cartridges.jsf.component.html.HtmlPopupFrame;
9
10
11
12
13 public class PopupFrameTag
14 extends UIComponentBodyTag
15 {
16 private String value;
17 private String accesskey;
18 private String dir;
19 private String lang;
20 private String tabindex;
21 private String title;
22 private String style;
23 private String styleClass;
24 private String actionOpen;
25 private String actionClose;
26 private String immediate;
27 private String mouseHorizPos;
28 private String mouseVertPos;
29 private String styleFrame;
30 private String styleClassFrame;
31 private String absolute;
32 private String center;
33 private String height;
34 private String width;
35 private String scrolling;
36
37
38
39
40 public void setValue(String valueIn)
41 {
42 this.value = valueIn;
43 }
44
45
46
47
48 public void setAccesskey(String accesskeyIn)
49 {
50 this.accesskey = accesskeyIn;
51 }
52
53
54
55
56 public void setDir(String dirIn)
57 {
58 this.dir = dirIn;
59 }
60
61
62
63
64 public void setLang(String langIn)
65 {
66 this.lang = langIn;
67 }
68
69
70
71
72 public void setTabindex(String tabindexIn)
73 {
74 this.tabindex = tabindexIn;
75 }
76
77
78
79
80 public void setTitle(String titleIn)
81 {
82 this.title = titleIn;
83 }
84
85
86
87
88 @Override
89 public String getRendererType()
90 {
91 return HtmlPopupFrame.RENDERER_TYPE;
92 }
93
94
95
96
97 @Override
98 public String getComponentType()
99 {
100 return HtmlPopupFrame.COMPONENT_TYPE;
101 }
102
103
104
105
106 public void setStyle(String styleIn)
107 {
108 this.style = styleIn;
109 }
110
111
112
113
114 public void setStyleClass(String styleClassIn)
115 {
116 this.styleClass = styleClassIn;
117 }
118
119
120
121
122 public void setAbsolute(String absoluteIn)
123 {
124 this.absolute = absoluteIn;
125 }
126
127
128
129
130 public void setActionClose(String actionCloseIn)
131 {
132 this.actionClose = actionCloseIn;
133 }
134
135
136
137
138 public void setActionOpen(String actionOpenIn)
139 {
140 this.actionOpen = actionOpenIn;
141 }
142
143
144
145
146 public void setCenter(String centerIn)
147 {
148 this.center = centerIn;
149 }
150
151
152
153
154 public void setImmediate(String immediateIn)
155 {
156 this.immediate = immediateIn;
157 }
158
159
160
161
162 public void setMouseVertPos(String mouseVertPosIn)
163 {
164 this.mouseVertPos = mouseVertPosIn;
165 }
166
167
168
169
170 public void setMouseHorizPos(String mouseHorizPosIn)
171 {
172 this.mouseHorizPos = mouseHorizPosIn;
173 }
174
175
176
177
178 public void setStyleClassFrame(String styleClassFrameIn)
179 {
180 this.styleClassFrame = styleClassFrameIn;
181 }
182
183
184
185
186 public void setStyleFrame(String styleFrameIn)
187 {
188 this.styleFrame = styleFrameIn;
189 }
190
191
192
193
194 public void setHeight(String heightIn)
195 {
196 this.height = heightIn;
197 }
198
199
200
201
202 public void setWidth(String widthIn)
203 {
204 this.width = widthIn;
205 }
206
207
208
209
210 public void setScrolling(String scrollingIn)
211 {
212 this.scrolling = scrollingIn;
213 }
214
215 private ValueBinding createValueBinding(final String valueIn)
216 {
217 return FacesContext.getCurrentInstance().getApplication().createValueBinding(valueIn);
218 }
219
220 private MethodBinding createMethodBinding(
221 final String valueIn,
222 Class[] args)
223 {
224 return FacesContext.getCurrentInstance().getApplication().createMethodBinding(
225 valueIn,
226 args);
227 }
228
229
230
231
232 @Override
233 protected void setProperties(UIComponent component)
234 {
235 super.setProperties(component);
236 HtmlPopupFrame command = null;
237 try
238 {
239 command = (HtmlPopupFrame)component;
240 }
241 catch (ClassCastException cce)
242 {
243 throw new IllegalStateException("Component " + component.toString() +
244 " not expected type. Expected: UICommand. Perhaps you're missing a tag?");
245 }
246
247 if (this.value != null)
248 {
249 if (isValueReference(this.value))
250 {
251 ValueBinding binding = createValueBinding(this.value);
252 command.setValueBinding(
253 "value",
254 binding);
255 }
256 else
257 {
258 command.setValue(this.value);
259 }
260 }
261 if (this.accesskey != null)
262 {
263 if (isValueReference(this.accesskey))
264 {
265 ValueBinding binding = createValueBinding(this.accesskey);
266 command.setValueBinding(
267 "accesskey",
268 binding);
269 }
270 else
271 {
272 command.getAttributes().put(
273 "accesskey",
274 this.accesskey);
275 }
276 }
277 if (this.dir != null)
278 {
279 if (isValueReference(this.dir))
280 {
281 ValueBinding binding = createValueBinding(this.dir);
282 command.setValueBinding(
283 "dir",
284 binding);
285 }
286 else
287 {
288 command.getAttributes().put(
289 "dir",
290 this.dir);
291 }
292 }
293 if (this.lang != null)
294 {
295 if (isValueReference(this.lang))
296 {
297 ValueBinding binding = createValueBinding(this.lang);
298 command.setValueBinding(
299 "lang",
300 binding);
301 }
302 else
303 {
304 command.getAttributes().put(
305 "lang",
306 this.lang);
307 }
308 }
309 if (this.tabindex != null)
310 {
311 if (isValueReference(this.tabindex))
312 {
313 ValueBinding binding = createValueBinding(this.tabindex);
314 command.setValueBinding(
315 "tabindex",
316 binding);
317 }
318 else
319 {
320 command.getAttributes().put(
321 "tabindex",
322 this.tabindex);
323 }
324 }
325 if (this.title != null)
326 {
327 if (isValueReference(this.title))
328 {
329 ValueBinding binding = createValueBinding(this.title);
330 command.setValueBinding(
331 "title",
332 binding);
333 }
334 else
335 {
336 command.getAttributes().put(
337 "title",
338 this.title);
339 }
340 }
341 if (this.style != null)
342 {
343 if (isValueReference(this.style))
344 {
345 ValueBinding binding = createValueBinding(this.style);
346 command.setValueBinding(
347 "style",
348 binding);
349 }
350 else
351 {
352 command.getAttributes().put(
353 "style",
354 this.style);
355 }
356 }
357 if (this.styleClass != null)
358 {
359 if (isValueReference(this.styleClass))
360 {
361 ValueBinding binding = createValueBinding(this.styleClass);
362 command.setValueBinding(
363 "styleClass",
364 binding);
365 }
366 else
367 {
368 command.getAttributes().put(
369 "styleClass",
370 this.styleClass);
371 }
372 }
373 if (this.absolute != null)
374 {
375 if (isValueReference(this.absolute))
376 {
377 ValueBinding binding = createValueBinding(this.absolute);
378 command.setValueBinding(
379 "absolute",
380 binding);
381 }
382 else
383 {
384 command.getAttributes().put(
385 "absolute",
386 this.absolute);
387 }
388 }
389 if (this.actionClose != null)
390 {
391 if (isValueReference(this.actionClose))
392 {
393 final MethodBinding binding = this.createMethodBinding(
394 this.actionClose,
395 new Class[0]);
396 command.setActionClose(binding);
397 }
398 else
399 {
400 throw new IllegalStateException("Invalid actionClose." + this.actionClose);
401 }
402 }
403 if (this.actionOpen != null)
404 {
405 if (isValueReference(this.actionOpen))
406 {
407 final MethodBinding binding = this.createMethodBinding(
408 this.actionOpen,
409 new Class[0]);
410 command.setActionOpen(binding);
411 }
412 else
413 {
414 throw new IllegalStateException("Invalid actionOpen." + this.actionOpen);
415 }
416 }
417 if (this.center != null)
418 {
419 if (isValueReference(this.center))
420 {
421 ValueBinding binding = createValueBinding(this.center);
422 command.setValueBinding(
423 "center",
424 binding);
425 }
426 else
427 {
428 command.getAttributes().put(
429 "center",
430 this.center);
431 }
432 }
433 if (this.immediate != null)
434 {
435 if (isValueReference(this.immediate))
436 {
437 ValueBinding binding = createValueBinding(this.immediate);
438 command.setValueBinding(
439 "immediate",
440 binding);
441 }
442 else
443 {
444 command.getAttributes().put(
445 "immediate",
446 this.immediate);
447 }
448 }
449 if (this.height != null)
450 {
451 if (isValueReference(this.height))
452 {
453 ValueBinding binding = createValueBinding(this.height);
454 command.setValueBinding(
455 "height",
456 binding);
457 }
458 else
459 {
460 command.getAttributes().put(
461 "height",
462 this.height);
463 }
464 }
465 if (this.width != null)
466 {
467 if (isValueReference(this.width))
468 {
469 ValueBinding binding = createValueBinding(this.width);
470 command.setValueBinding(
471 "width",
472 binding);
473 }
474 else
475 {
476 command.getAttributes().put(
477 "width",
478 this.width);
479 }
480 }
481 if (this.mouseHorizPos != null)
482 {
483 if (isValueReference(this.mouseHorizPos))
484 {
485 ValueBinding binding = createValueBinding(this.mouseHorizPos);
486 command.setValueBinding(
487 "mouseHorizPos",
488 binding);
489 }
490 else
491 {
492 command.getAttributes().put(
493 "mouseHorizPos",
494 this.mouseHorizPos);
495 }
496 }
497 if (this.mouseVertPos != null)
498 {
499 if (isValueReference(this.mouseVertPos))
500 {
501 ValueBinding binding = createValueBinding(this.mouseVertPos);
502 command.setValueBinding(
503 "mouseVertPos",
504 binding);
505 }
506 else
507 {
508 command.getAttributes().put(
509 "mouseVertPos",
510 this.mouseVertPos);
511 }
512 }
513 if (this.styleClassFrame != null)
514 {
515 if (isValueReference(this.styleClassFrame))
516 {
517 ValueBinding binding = createValueBinding(this.styleClassFrame);
518 command.setValueBinding(
519 "styleClassFrame",
520 binding);
521 }
522 else
523 {
524 command.getAttributes().put(
525 "styleClassFrame",
526 this.styleClassFrame);
527 }
528 }
529 if (this.styleFrame != null)
530 {
531 if (isValueReference(this.styleFrame))
532 {
533 ValueBinding binding = createValueBinding(this.styleFrame);
534 command.setValueBinding(
535 "styleFrame",
536 binding);
537 }
538 else
539 {
540 command.getAttributes().put(
541 "styleFrame",
542 this.styleFrame);
543 }
544 }
545 if (this.scrolling != null)
546 {
547 if (isValueReference(this.scrolling))
548 {
549 ValueBinding binding = createValueBinding(this.scrolling);
550 command.setValueBinding(
551 "scrolling",
552 binding);
553 }
554 else
555 {
556 command.getAttributes().put(
557 "scrolling",
558 this.scrolling);
559 }
560 }
561 }
562 }