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.internal.tools.ListenersTools1_2;
12 import org.rcfaces.core.internal.tools.ListenersTools;
13 import org.rcfaces.core.component.SubmitWaitComponent;
14 import javax.faces.context.FacesContext;
15
16 public class SubmitWaitTag extends CameliaTag implements Tag {
17
18
19 private static final Log LOG=LogFactory.getLog(SubmitWaitTag.class);
20
21 private ValueExpression imageURL;
22 private ValueExpression text;
23 private ValueExpression styleClass;
24 private ValueExpression width;
25 private ValueExpression height;
26 private ValueExpression ariaLabel;
27 private ValueExpression ariaLevel;
28 private ValueExpression waiRole;
29 private ValueExpression lookId;
30 private ValueExpression backgroundMode;
31 public String getComponentType() {
32 return SubmitWaitComponent.COMPONENT_TYPE;
33 }
34
35 public final void setImageURL(ValueExpression imageURL) {
36 this.imageURL = imageURL;
37 }
38
39 public final void setText(ValueExpression text) {
40 this.text = text;
41 }
42
43 public final void setStyleClass(ValueExpression styleClass) {
44 this.styleClass = styleClass;
45 }
46
47 public final void setWidth(ValueExpression width) {
48 this.width = width;
49 }
50
51 public final void setHeight(ValueExpression height) {
52 this.height = height;
53 }
54
55 public final void setAriaLabel(ValueExpression ariaLabel) {
56 this.ariaLabel = ariaLabel;
57 }
58
59 public final void setAriaLevel(ValueExpression ariaLevel) {
60 this.ariaLevel = ariaLevel;
61 }
62
63 public final void setWaiRole(ValueExpression waiRole) {
64 this.waiRole = waiRole;
65 }
66
67 public final void setLookId(ValueExpression lookId) {
68 this.lookId = lookId;
69 }
70
71 public final void setBackgroundMode(ValueExpression backgroundMode) {
72 this.backgroundMode = backgroundMode;
73 }
74
75 protected void setProperties(UIComponent uiComponent) {
76 if (LOG.isDebugEnabled()) {
77 if (SubmitWaitComponent.COMPONENT_TYPE==getComponentType()) {
78 LOG.debug("Component id='"+getId()+"' type='"+getComponentType()+"'.");
79 }
80 LOG.debug(" imageURL='"+imageURL+"'");
81 LOG.debug(" text='"+text+"'");
82 LOG.debug(" styleClass='"+styleClass+"'");
83 LOG.debug(" width='"+width+"'");
84 LOG.debug(" height='"+height+"'");
85 LOG.debug(" ariaLabel='"+ariaLabel+"'");
86 LOG.debug(" ariaLevel='"+ariaLevel+"'");
87 LOG.debug(" waiRole='"+waiRole+"'");
88 LOG.debug(" lookId='"+lookId+"'");
89 LOG.debug(" backgroundMode='"+backgroundMode+"'");
90 }
91 if ((uiComponent instanceof SubmitWaitComponent)==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 'SubmitWaitComponent'.");
96 }
97
98 super.setProperties(uiComponent);
99
100 SubmitWaitComponent component = (SubmitWaitComponent) uiComponent;
101 FacesContext facesContext = getFacesContext();
102
103 if (imageURL != null) {
104 if (imageURL.isLiteralText()==false) {
105 component.setValueExpression(Properties.IMAGE_URL, imageURL);
106
107 } else {
108 component.setImageURL(imageURL.getExpressionString());
109 }
110 }
111
112 if (text != null) {
113 if (text.isLiteralText()==false) {
114 component.setValueExpression(Properties.TEXT, text);
115
116 } else {
117 component.setText(text.getExpressionString());
118 }
119 }
120
121 if (styleClass != null) {
122 if (styleClass.isLiteralText()==false) {
123 component.setValueExpression(Properties.STYLE_CLASS, styleClass);
124
125 } else {
126 component.setStyleClass(styleClass.getExpressionString());
127 }
128 }
129
130 if (width != null) {
131 if (width.isLiteralText()==false) {
132 component.setValueExpression(Properties.WIDTH, width);
133
134 } else {
135 component.setWidth(width.getExpressionString());
136 }
137 }
138
139 if (height != null) {
140 if (height.isLiteralText()==false) {
141 component.setValueExpression(Properties.HEIGHT, height);
142
143 } else {
144 component.setHeight(height.getExpressionString());
145 }
146 }
147
148 if (ariaLabel != null) {
149 if (ariaLabel.isLiteralText()==false) {
150 component.setValueExpression(Properties.ARIA_LABEL, ariaLabel);
151
152 } else {
153 component.setAriaLabel(ariaLabel.getExpressionString());
154 }
155 }
156
157 if (ariaLevel != null) {
158 if (ariaLevel.isLiteralText()==false) {
159 component.setValueExpression(Properties.ARIA_LEVEL, ariaLevel);
160
161 } else {
162 component.setAriaLevel(getInt(ariaLevel.getExpressionString()));
163 }
164 }
165
166 if (waiRole != null) {
167 if (waiRole.isLiteralText()==false) {
168 component.setValueExpression(Properties.WAI_ROLE, waiRole);
169
170 } else {
171 component.setWaiRole(waiRole.getExpressionString());
172 }
173 }
174
175 if (lookId != null) {
176 if (lookId.isLiteralText()==false) {
177 component.setValueExpression(Properties.LOOK_ID, lookId);
178
179 } else {
180 component.setLookId(lookId.getExpressionString());
181 }
182 }
183
184 if (backgroundMode != null) {
185 if (backgroundMode.isLiteralText()==false) {
186 component.setValueExpression(Properties.BACKGROUND_MODE, backgroundMode);
187
188 } else {
189 component.setBackgroundMode(backgroundMode.getExpressionString());
190 }
191 }
192 }
193
194 public void release() {
195 imageURL = null;
196 text = null;
197 styleClass = null;
198 width = null;
199 height = null;
200 ariaLabel = null;
201 ariaLevel = null;
202 waiRole = null;
203 lookId = null;
204 backgroundMode = null;
205
206 super.release();
207 }
208
209 }