1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.myfaces.view.facelets.tag.composite; |
20 | |
|
21 | |
import java.io.IOException; |
22 | |
import java.util.Collection; |
23 | |
import java.util.Collections; |
24 | |
import java.util.HashMap; |
25 | |
import java.util.Iterator; |
26 | |
import java.util.List; |
27 | |
import java.util.Map; |
28 | |
|
29 | |
import javax.el.ValueExpression; |
30 | |
import javax.faces.FacesException; |
31 | |
import javax.faces.FacesWrapper; |
32 | |
import javax.faces.component.ContextCallback; |
33 | |
import javax.faces.component.UIComponent; |
34 | |
import javax.faces.component.behavior.ClientBehavior; |
35 | |
import javax.faces.component.behavior.ClientBehaviorHolder; |
36 | |
import javax.faces.component.visit.VisitCallback; |
37 | |
import javax.faces.component.visit.VisitContext; |
38 | |
import javax.faces.context.FacesContext; |
39 | |
import javax.faces.el.ValueBinding; |
40 | |
import javax.faces.event.AbortProcessingException; |
41 | |
import javax.faces.event.ComponentSystemEvent; |
42 | |
import javax.faces.event.ComponentSystemEventListener; |
43 | |
import javax.faces.event.FacesEvent; |
44 | |
import javax.faces.event.FacesListener; |
45 | |
import javax.faces.event.SystemEvent; |
46 | |
import javax.faces.event.SystemEventListener; |
47 | |
import javax.faces.render.Renderer; |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | 0 | public class ClientBehaviorRedirectEventComponentWrapper extends UIComponent |
64 | |
implements FacesWrapper<UIComponent>, ClientBehaviorHolder |
65 | |
{ |
66 | |
|
67 | |
private final UIComponent _delegate; |
68 | |
private final String _sourceEvent; |
69 | |
private final String _targetEvent; |
70 | |
|
71 | |
public ClientBehaviorRedirectEventComponentWrapper(UIComponent delegate, |
72 | |
String sourceEvent, String targetEvent) |
73 | |
{ |
74 | 0 | super(); |
75 | 0 | _delegate = delegate; |
76 | 0 | _sourceEvent = sourceEvent; |
77 | 0 | _targetEvent = targetEvent; |
78 | 0 | } |
79 | |
|
80 | |
public UIComponent getWrapped() |
81 | |
{ |
82 | 0 | return _delegate; |
83 | |
} |
84 | |
|
85 | |
public void addClientBehavior(String eventName, ClientBehavior behavior) |
86 | |
{ |
87 | 0 | if (_sourceEvent.equals(eventName)) |
88 | |
{ |
89 | 0 | String targetEventName = _targetEvent == null |
90 | |
? ((ClientBehaviorHolder)_delegate).getDefaultEventName() |
91 | |
: _targetEvent; |
92 | 0 | ((ClientBehaviorHolder)_delegate).addClientBehavior(targetEventName , behavior); |
93 | |
} |
94 | 0 | } |
95 | |
|
96 | |
public Map<String, List<ClientBehavior>> getClientBehaviors() |
97 | |
{ |
98 | 0 | Map<String, List<ClientBehavior>> clientBehaviors = new HashMap<String, List<ClientBehavior>>(1); |
99 | 0 | clientBehaviors.put(_sourceEvent, ((ClientBehaviorHolder)_delegate).getClientBehaviors().get(_targetEvent)); |
100 | 0 | return Collections.unmodifiableMap(clientBehaviors); |
101 | |
} |
102 | |
|
103 | |
public String getDefaultEventName() |
104 | |
{ |
105 | 0 | if (_targetEvent == null ) |
106 | |
{ |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | 0 | if (((ClientBehaviorHolder)_delegate).getDefaultEventName() != null) |
113 | |
{ |
114 | 0 | return _sourceEvent; |
115 | |
} |
116 | |
else |
117 | |
{ |
118 | 0 | return null; |
119 | |
} |
120 | |
} |
121 | |
else |
122 | |
{ |
123 | |
|
124 | |
|
125 | 0 | return _sourceEvent; |
126 | |
} |
127 | |
} |
128 | |
|
129 | |
public Collection<String> getEventNames() |
130 | |
{ |
131 | 0 | return Collections.singletonList(_sourceEvent); |
132 | |
} |
133 | |
|
134 | |
|
135 | |
public void broadcast(FacesEvent event) throws AbortProcessingException |
136 | |
{ |
137 | 0 | _delegate.broadcast(event); |
138 | 0 | } |
139 | |
|
140 | |
public void clearInitialState() |
141 | |
{ |
142 | 0 | _delegate.clearInitialState(); |
143 | 0 | } |
144 | |
|
145 | |
public void decode(FacesContext context) |
146 | |
{ |
147 | 0 | _delegate.decode(context); |
148 | 0 | } |
149 | |
|
150 | |
public void encodeAll(FacesContext context) throws IOException |
151 | |
{ |
152 | 0 | _delegate.encodeAll(context); |
153 | 0 | } |
154 | |
|
155 | |
public void encodeBegin(FacesContext context) throws IOException |
156 | |
{ |
157 | 0 | _delegate.encodeBegin(context); |
158 | 0 | } |
159 | |
|
160 | |
public void encodeChildren(FacesContext context) throws IOException |
161 | |
{ |
162 | 0 | _delegate.encodeChildren(context); |
163 | 0 | } |
164 | |
|
165 | |
public void encodeEnd(FacesContext context) throws IOException |
166 | |
{ |
167 | 0 | _delegate.encodeEnd(context); |
168 | 0 | } |
169 | |
|
170 | |
public UIComponent findComponent(String expr) |
171 | |
{ |
172 | 0 | return _delegate.findComponent(expr); |
173 | |
} |
174 | |
|
175 | |
public Map<String, Object> getAttributes() |
176 | |
{ |
177 | 0 | return _delegate.getAttributes(); |
178 | |
} |
179 | |
|
180 | |
public int getChildCount() |
181 | |
{ |
182 | 0 | return _delegate.getChildCount(); |
183 | |
} |
184 | |
|
185 | |
public List<UIComponent> getChildren() |
186 | |
{ |
187 | 0 | return _delegate.getChildren(); |
188 | |
} |
189 | |
|
190 | |
public String getClientId() |
191 | |
{ |
192 | 0 | return _delegate.getClientId(); |
193 | |
} |
194 | |
|
195 | |
public String getClientId(FacesContext context) |
196 | |
{ |
197 | 0 | return _delegate.getClientId(context); |
198 | |
} |
199 | |
|
200 | |
public String getContainerClientId(FacesContext ctx) |
201 | |
{ |
202 | 0 | return _delegate.getContainerClientId(ctx); |
203 | |
} |
204 | |
|
205 | |
public UIComponent getFacet(String name) |
206 | |
{ |
207 | 0 | return _delegate.getFacet(name); |
208 | |
} |
209 | |
|
210 | |
public int getFacetCount() |
211 | |
{ |
212 | 0 | return _delegate.getFacetCount(); |
213 | |
} |
214 | |
|
215 | |
public Map<String, UIComponent> getFacets() |
216 | |
{ |
217 | 0 | return _delegate.getFacets(); |
218 | |
} |
219 | |
|
220 | |
public Iterator<UIComponent> getFacetsAndChildren() |
221 | |
{ |
222 | 0 | return _delegate.getFacetsAndChildren(); |
223 | |
} |
224 | |
|
225 | |
public String getFamily() |
226 | |
{ |
227 | 0 | return _delegate.getFamily(); |
228 | |
} |
229 | |
|
230 | |
public String getId() |
231 | |
{ |
232 | 0 | return _delegate.getId(); |
233 | |
} |
234 | |
|
235 | |
public List<SystemEventListener> getListenersForEventClass( |
236 | |
Class<? extends SystemEvent> eventClass) |
237 | |
{ |
238 | 0 | return _delegate.getListenersForEventClass(eventClass); |
239 | |
} |
240 | |
|
241 | |
public UIComponent getNamingContainer() |
242 | |
{ |
243 | 0 | return _delegate.getNamingContainer(); |
244 | |
} |
245 | |
|
246 | |
public UIComponent getParent() |
247 | |
{ |
248 | 0 | return _delegate.getParent(); |
249 | |
} |
250 | |
|
251 | |
public String getRendererType() |
252 | |
{ |
253 | 0 | return _delegate.getRendererType(); |
254 | |
} |
255 | |
|
256 | |
public boolean getRendersChildren() |
257 | |
{ |
258 | 0 | return _delegate.getRendersChildren(); |
259 | |
} |
260 | |
|
261 | |
public Map<String, String> getResourceBundleMap() |
262 | |
{ |
263 | 0 | return _delegate.getResourceBundleMap(); |
264 | |
} |
265 | |
|
266 | |
public ValueBinding getValueBinding(String name) |
267 | |
{ |
268 | 0 | return _delegate.getValueBinding(name); |
269 | |
} |
270 | |
|
271 | |
public ValueExpression getValueExpression(String name) |
272 | |
{ |
273 | 0 | return _delegate.getValueExpression(name); |
274 | |
} |
275 | |
|
276 | |
public boolean initialStateMarked() |
277 | |
{ |
278 | 0 | return _delegate.initialStateMarked(); |
279 | |
} |
280 | |
|
281 | |
public boolean invokeOnComponent(FacesContext context, String clientId, |
282 | |
ContextCallback callback) throws FacesException |
283 | |
{ |
284 | 0 | return _delegate.invokeOnComponent(context, clientId, callback); |
285 | |
} |
286 | |
|
287 | |
public boolean isInView() |
288 | |
{ |
289 | 0 | return _delegate.isInView(); |
290 | |
} |
291 | |
|
292 | |
public boolean isRendered() |
293 | |
{ |
294 | 0 | return _delegate.isRendered(); |
295 | |
} |
296 | |
|
297 | |
public boolean isTransient() |
298 | |
{ |
299 | 0 | return _delegate.isTransient(); |
300 | |
} |
301 | |
|
302 | |
public void markInitialState() |
303 | |
{ |
304 | 0 | _delegate.markInitialState(); |
305 | 0 | } |
306 | |
|
307 | |
public void processDecodes(FacesContext context) |
308 | |
{ |
309 | 0 | _delegate.processDecodes(context); |
310 | 0 | } |
311 | |
|
312 | |
public void processEvent(ComponentSystemEvent event) |
313 | |
throws AbortProcessingException |
314 | |
{ |
315 | 0 | _delegate.processEvent(event); |
316 | 0 | } |
317 | |
|
318 | |
public void processRestoreState(FacesContext context, Object state) |
319 | |
{ |
320 | 0 | _delegate.processRestoreState(context, state); |
321 | 0 | } |
322 | |
|
323 | |
public Object processSaveState(FacesContext context) |
324 | |
{ |
325 | 0 | return _delegate.processSaveState(context); |
326 | |
} |
327 | |
|
328 | |
public void processUpdates(FacesContext context) |
329 | |
{ |
330 | 0 | _delegate.processUpdates(context); |
331 | 0 | } |
332 | |
|
333 | |
public void processValidators(FacesContext context) |
334 | |
{ |
335 | 0 | _delegate.processValidators(context); |
336 | 0 | } |
337 | |
|
338 | |
public void queueEvent(FacesEvent event) |
339 | |
{ |
340 | 0 | _delegate.queueEvent(event); |
341 | 0 | } |
342 | |
|
343 | |
public void restoreState(FacesContext context, Object state) |
344 | |
{ |
345 | 0 | _delegate.restoreState(context, state); |
346 | 0 | } |
347 | |
|
348 | |
public Object saveState(FacesContext context) |
349 | |
{ |
350 | 0 | return _delegate.saveState(context); |
351 | |
} |
352 | |
|
353 | |
public void setId(String id) |
354 | |
{ |
355 | 0 | _delegate.setId(id); |
356 | 0 | } |
357 | |
|
358 | |
public void setInView(boolean isInView) |
359 | |
{ |
360 | 0 | _delegate.setInView(isInView); |
361 | 0 | } |
362 | |
|
363 | |
public void setParent(UIComponent parent) |
364 | |
{ |
365 | 0 | _delegate.setParent(parent); |
366 | 0 | } |
367 | |
|
368 | |
public void setRendered(boolean rendered) |
369 | |
{ |
370 | 0 | _delegate.setRendered(rendered); |
371 | 0 | } |
372 | |
|
373 | |
public void setRendererType(String rendererType) |
374 | |
{ |
375 | 0 | _delegate.setRendererType(rendererType); |
376 | 0 | } |
377 | |
|
378 | |
public void setTransient(boolean newTransientValue) |
379 | |
{ |
380 | 0 | _delegate.setTransient(newTransientValue); |
381 | 0 | } |
382 | |
|
383 | |
public void setValueBinding(String name, ValueBinding binding) |
384 | |
{ |
385 | 0 | _delegate.setValueBinding(name, binding); |
386 | 0 | } |
387 | |
|
388 | |
public void setValueExpression(String name, ValueExpression expression) |
389 | |
{ |
390 | 0 | _delegate.setValueExpression(name, expression); |
391 | 0 | } |
392 | |
|
393 | |
public void subscribeToEvent(Class<? extends SystemEvent> eventClass, |
394 | |
ComponentSystemEventListener componentListener) |
395 | |
{ |
396 | 0 | _delegate.subscribeToEvent(eventClass, componentListener); |
397 | 0 | } |
398 | |
|
399 | |
public void unsubscribeFromEvent(Class<? extends SystemEvent> eventClass, |
400 | |
ComponentSystemEventListener componentListener) |
401 | |
{ |
402 | 0 | _delegate.unsubscribeFromEvent(eventClass, componentListener); |
403 | 0 | } |
404 | |
|
405 | |
public boolean visitTree(VisitContext context, VisitCallback callback) |
406 | |
{ |
407 | 0 | return _delegate.visitTree(context, callback); |
408 | |
} |
409 | |
|
410 | |
|
411 | |
|
412 | |
|
413 | |
@Override |
414 | |
protected FacesContext getFacesContext() |
415 | |
{ |
416 | 0 | return FacesContext.getCurrentInstance(); |
417 | |
} |
418 | |
|
419 | |
@Override |
420 | |
protected void addFacesListener(FacesListener listener) |
421 | |
{ |
422 | 0 | } |
423 | |
|
424 | |
@Override |
425 | |
protected FacesListener[] getFacesListeners(Class clazz) |
426 | |
{ |
427 | 0 | return null; |
428 | |
} |
429 | |
|
430 | |
@Override |
431 | |
protected Renderer getRenderer(FacesContext context) |
432 | |
{ |
433 | 0 | return null; |
434 | |
} |
435 | |
|
436 | |
@Override |
437 | |
protected void removeFacesListener(FacesListener listener) |
438 | |
{ |
439 | 0 | } |
440 | |
|
441 | |
@Override |
442 | |
public Map<String, Object> getPassThroughAttributes(boolean create) |
443 | |
{ |
444 | 0 | return getWrapped().getPassThroughAttributes(create); |
445 | |
} |
446 | |
} |