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.component.StyledMessageComponent;
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 StyledMessageTag extends AbstractBasicTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(StyledMessageTag.class);
20
21 private ValueExpression backgroundImageHorizontalPosition;
22 private ValueExpression backgroundImageHorizontalRepeat;
23 private ValueExpression backgroundImageURL;
24 private ValueExpression backgroundImageVerticalPosition;
25 private ValueExpression backgroundImageVerticalRepeat;
26 private ValueExpression border;
27 private ValueExpression mouseOutListeners;
28 private ValueExpression mouseOverListeners;
29 private ValueExpression initListeners;
30 private ValueExpression forValue;
31 private ValueExpression errorStyleClass;
32 private ValueExpression fatalStyleClass;
33 private ValueExpression infoStyleClass;
34 private ValueExpression warnStyleClass;
35 private ValueExpression showIfMessage;
36 private ValueExpression setFocusIfMessage;
37 public String getComponentType() {
38 return StyledMessageComponent.COMPONENT_TYPE;
39 }
40
41 public final void setBackgroundImageHorizontalPosition(ValueExpression backgroundImageHorizontalPosition) {
42 this.backgroundImageHorizontalPosition = backgroundImageHorizontalPosition;
43 }
44
45 public final void setBackgroundImageHorizontalRepeat(ValueExpression backgroundImageHorizontalRepeat) {
46 this.backgroundImageHorizontalRepeat = backgroundImageHorizontalRepeat;
47 }
48
49 public final void setBackgroundImageURL(ValueExpression backgroundImageURL) {
50 this.backgroundImageURL = backgroundImageURL;
51 }
52
53 public final void setBackgroundImageVerticalPosition(ValueExpression backgroundImageVerticalPosition) {
54 this.backgroundImageVerticalPosition = backgroundImageVerticalPosition;
55 }
56
57 public final void setBackgroundImageVerticalRepeat(ValueExpression backgroundImageVerticalRepeat) {
58 this.backgroundImageVerticalRepeat = backgroundImageVerticalRepeat;
59 }
60
61 public final void setBorder(ValueExpression border) {
62 this.border = border;
63 }
64
65 public final void setMouseOutListener(ValueExpression mouseOutListeners) {
66 this.mouseOutListeners = mouseOutListeners;
67 }
68
69 public final void setMouseOverListener(ValueExpression mouseOverListeners) {
70 this.mouseOverListeners = mouseOverListeners;
71 }
72
73 public final void setInitListener(ValueExpression initListeners) {
74 this.initListeners = initListeners;
75 }
76
77 public final void setFor(ValueExpression forValue) {
78 this.forValue = forValue;
79 }
80
81 public final void setErrorStyleClass(ValueExpression errorStyleClass) {
82 this.errorStyleClass = errorStyleClass;
83 }
84
85 public final void setFatalStyleClass(ValueExpression fatalStyleClass) {
86 this.fatalStyleClass = fatalStyleClass;
87 }
88
89 public final void setInfoStyleClass(ValueExpression infoStyleClass) {
90 this.infoStyleClass = infoStyleClass;
91 }
92
93 public final void setWarnStyleClass(ValueExpression warnStyleClass) {
94 this.warnStyleClass = warnStyleClass;
95 }
96
97 public final void setShowIfMessage(ValueExpression showIfMessage) {
98 this.showIfMessage = showIfMessage;
99 }
100
101 public final void setSetFocusIfMessage(ValueExpression setFocusIfMessage) {
102 this.setFocusIfMessage = setFocusIfMessage;
103 }
104
105 protected void setProperties(UIComponent uiComponent) {
106 if (LOG.isDebugEnabled()) {
107 if (StyledMessageComponent.COMPONENT_TYPE==getComponentType()) {
108 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
109 }
110 LOG.debug(" backgroundImageHorizontalPosition='"+backgroundImageHorizontalPosition+"'");
111 LOG.debug(" backgroundImageHorizontalRepeat='"+backgroundImageHorizontalRepeat+"'");
112 LOG.debug(" backgroundImageURL='"+backgroundImageURL+"'");
113 LOG.debug(" backgroundImageVerticalPosition='"+backgroundImageVerticalPosition+"'");
114 LOG.debug(" backgroundImageVerticalRepeat='"+backgroundImageVerticalRepeat+"'");
115 LOG.debug(" border='"+border+"'");
116 LOG.debug(" forValue='"+forValue+"'");
117 LOG.debug(" errorStyleClass='"+errorStyleClass+"'");
118 LOG.debug(" fatalStyleClass='"+fatalStyleClass+"'");
119 LOG.debug(" infoStyleClass='"+infoStyleClass+"'");
120 LOG.debug(" warnStyleClass='"+warnStyleClass+"'");
121 LOG.debug(" showIfMessage='"+showIfMessage+"'");
122 LOG.debug(" setFocusIfMessage='"+setFocusIfMessage+"'");
123 }
124 if ((uiComponent instanceof StyledMessageComponent)==false) {
125 if (uiComponent instanceof UIViewRoot) {
126 throw new IllegalStateException("The first component of the page must be a UIViewRoot component !");
127 }
128 throw new IllegalStateException("Component specified by tag is not instanceof of 'StyledMessageComponent'.");
129 }
130
131 super.setProperties(uiComponent);
132
133 StyledMessageComponent component = (StyledMessageComponent) uiComponent;
134 FacesContext facesContext = getFacesContext();
135
136 if (backgroundImageHorizontalPosition != null) {
137 if (backgroundImageHorizontalPosition.isLiteralText()==false) {
138 component.setValueExpression(Properties.BACKGROUND_IMAGE_HORIZONTAL_POSITION, backgroundImageHorizontalPosition);
139
140 } else {
141 component.setBackgroundImageHorizontalPosition(backgroundImageHorizontalPosition.getExpressionString());
142 }
143 }
144
145 if (backgroundImageHorizontalRepeat != null) {
146 if (backgroundImageHorizontalRepeat.isLiteralText()==false) {
147 component.setValueExpression(Properties.BACKGROUND_IMAGE_HORIZONTAL_REPEAT, backgroundImageHorizontalRepeat);
148
149 } else {
150 component.setBackgroundImageHorizontalRepeat(getBool(backgroundImageHorizontalRepeat.getExpressionString()));
151 }
152 }
153
154 if (backgroundImageURL != null) {
155 if (backgroundImageURL.isLiteralText()==false) {
156 component.setValueExpression(Properties.BACKGROUND_IMAGE_URL, backgroundImageURL);
157
158 } else {
159 component.setBackgroundImageURL(backgroundImageURL.getExpressionString());
160 }
161 }
162
163 if (backgroundImageVerticalPosition != null) {
164 if (backgroundImageVerticalPosition.isLiteralText()==false) {
165 component.setValueExpression(Properties.BACKGROUND_IMAGE_VERTICAL_POSITION, backgroundImageVerticalPosition);
166
167 } else {
168 component.setBackgroundImageVerticalPosition(backgroundImageVerticalPosition.getExpressionString());
169 }
170 }
171
172 if (backgroundImageVerticalRepeat != null) {
173 if (backgroundImageVerticalRepeat.isLiteralText()==false) {
174 component.setValueExpression(Properties.BACKGROUND_IMAGE_VERTICAL_REPEAT, backgroundImageVerticalRepeat);
175
176 } else {
177 component.setBackgroundImageVerticalRepeat(getBool(backgroundImageVerticalRepeat.getExpressionString()));
178 }
179 }
180
181 if (border != null) {
182 if (border.isLiteralText()==false) {
183 component.setValueExpression(Properties.BORDER, border);
184
185 } else {
186 component.setBorder(getBool(border.getExpressionString()));
187 }
188 }
189
190 if (mouseOutListeners != null) {
191 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OUT_LISTENER_TYPE, mouseOutListeners);
192 }
193
194 if (mouseOverListeners != null) {
195 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.MOUSE_OVER_LISTENER_TYPE, mouseOverListeners);
196 }
197
198 if (initListeners != null) {
199 ListenersTools1_2.parseListener(facesContext, component, ListenersTools.INIT_LISTENER_TYPE, initListeners);
200 }
201
202 if (forValue != null) {
203 if (forValue.isLiteralText()==false) {
204 component.setValueExpression(Properties.FOR, forValue);
205
206 } else {
207 component.setFor(forValue.getExpressionString());
208 }
209 }
210
211 if (errorStyleClass != null) {
212 if (errorStyleClass.isLiteralText()==false) {
213 component.setValueExpression(Properties.ERROR_STYLE_CLASS, errorStyleClass);
214
215 } else {
216 component.setErrorStyleClass(errorStyleClass.getExpressionString());
217 }
218 }
219
220 if (fatalStyleClass != null) {
221 if (fatalStyleClass.isLiteralText()==false) {
222 component.setValueExpression(Properties.FATAL_STYLE_CLASS, fatalStyleClass);
223
224 } else {
225 component.setFatalStyleClass(fatalStyleClass.getExpressionString());
226 }
227 }
228
229 if (infoStyleClass != null) {
230 if (infoStyleClass.isLiteralText()==false) {
231 component.setValueExpression(Properties.INFO_STYLE_CLASS, infoStyleClass);
232
233 } else {
234 component.setInfoStyleClass(infoStyleClass.getExpressionString());
235 }
236 }
237
238 if (warnStyleClass != null) {
239 if (warnStyleClass.isLiteralText()==false) {
240 component.setValueExpression(Properties.WARN_STYLE_CLASS, warnStyleClass);
241
242 } else {
243 component.setWarnStyleClass(warnStyleClass.getExpressionString());
244 }
245 }
246
247 if (showIfMessage != null) {
248 if (showIfMessage.isLiteralText()==false) {
249 component.setValueExpression(Properties.SHOW_IF_MESSAGE, showIfMessage);
250
251 } else {
252 component.setShowIfMessage(getBool(showIfMessage.getExpressionString()));
253 }
254 }
255
256 if (setFocusIfMessage != null) {
257 if (setFocusIfMessage.isLiteralText()==false) {
258 component.setValueExpression(Properties.SET_FOCUS_IF_MESSAGE, setFocusIfMessage);
259
260 } else {
261 component.setSetFocusIfMessage(getBool(setFocusIfMessage.getExpressionString()));
262 }
263 }
264 }
265
266 public void release() {
267 backgroundImageHorizontalPosition = null;
268 backgroundImageHorizontalRepeat = null;
269 backgroundImageURL = null;
270 backgroundImageVerticalPosition = null;
271 backgroundImageVerticalRepeat = null;
272 border = null;
273 mouseOutListeners = null;
274 mouseOverListeners = null;
275 initListeners = null;
276 forValue = null;
277 errorStyleClass = null;
278 fatalStyleClass = null;
279 infoStyleClass = null;
280 warnStyleClass = null;
281 showIfMessage = null;
282 setFocusIfMessage = null;
283
284 super.release();
285 }
286
287 }