1 package org.rcfaces.core.internal.taglib;
2
3 import org.rcfaces.core.component.CalendarComponent;
4 import javax.faces.application.Application;
5 import javax.faces.component.UIComponent;
6 import org.rcfaces.core.internal.component.Properties;
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 CalendarTag extends AbstractCalendarTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(CalendarTag.class);
20
21 private ValueExpression border;
22 private ValueExpression calendarLayout;
23 private ValueExpression multipleSelect;
24 private ValueExpression mode;
25 private ValueExpression autoSelection;
26 public String getComponentType() {
27 return CalendarComponent.COMPONENT_TYPE;
28 }
29
30 public final void setBorder(ValueExpression border) {
31 this.border = border;
32 }
33
34 public final void setCalendarLayout(ValueExpression calendarLayout) {
35 this.calendarLayout = calendarLayout;
36 }
37
38 public final void setMultipleSelect(ValueExpression multipleSelect) {
39 this.multipleSelect = multipleSelect;
40 }
41
42 public final void setMode(ValueExpression mode) {
43 this.mode = mode;
44 }
45
46 public final void setAutoSelection(ValueExpression autoSelection) {
47 this.autoSelection = autoSelection;
48 }
49
50 protected void setProperties(UIComponent uiComponent) {
51 if (LOG.isDebugEnabled()) {
52 if (CalendarComponent.COMPONENT_TYPE==getComponentType()) {
53 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
54 }
55 LOG.debug(" border='"+border+"'");
56 LOG.debug(" calendarLayout='"+calendarLayout+"'");
57 LOG.debug(" multipleSelect='"+multipleSelect+"'");
58 LOG.debug(" mode='"+mode+"'");
59 LOG.debug(" autoSelection='"+autoSelection+"'");
60 }
61 if ((uiComponent instanceof CalendarComponent)==false) {
62 if (uiComponent instanceof UIViewRoot) {
63 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
64 }
65 throw new IllegalStateException("Component specified by tag is not instanceof of 'CalendarComponent'.");
66 }
67
68 super.setProperties(uiComponent);
69
70 CalendarComponent component = (CalendarComponent) uiComponent;
71 FacesContext facesContext = getFacesContext();
72
73 if (border != null) {
74 if (border.isLiteralText()==false) {
75 component.setValueExpression(Properties.BORDER, border);
76
77 } else {
78 component.setBorder(getBool(border.getExpressionString()));
79 }
80 }
81
82 if (calendarLayout != null) {
83 if (calendarLayout.isLiteralText()==false) {
84 component.setValueExpression(Properties.CALENDAR_LAYOUT, calendarLayout);
85
86 } else {
87 component.setCalendarLayout(calendarLayout.getExpressionString());
88 }
89 }
90
91 if (multipleSelect != null) {
92 if (multipleSelect.isLiteralText()==false) {
93 component.setValueExpression(Properties.MULTIPLE_SELECT, multipleSelect);
94
95 } else {
96 component.setMultipleSelect(getBool(multipleSelect.getExpressionString()));
97 }
98 }
99
100 if (mode != null) {
101 if (mode.isLiteralText()==false) {
102 component.setValueExpression(Properties.MODE, mode);
103
104 } else {
105 component.setMode(mode.getExpressionString());
106 }
107 }
108
109 if (autoSelection != null) {
110 if (autoSelection.isLiteralText()==false) {
111 component.setValueExpression(Properties.AUTO_SELECTION, autoSelection);
112
113 } else {
114 component.setAutoSelection(getBool(autoSelection.getExpressionString()));
115 }
116 }
117 }
118
119 public void release() {
120 border = null;
121 calendarLayout = null;
122 multipleSelect = null;
123 mode = null;
124 autoSelection = null;
125
126 super.release();
127 }
128
129 }