1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing,
13 * software distributed under the License is distributed on an
14 * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15 * KIND, either express or implied. See the License for the
16 * specific language governing permissions and limitations
17 * under the License.
18 */
19 package org.apache.myfaces.view.facelets.tag.composite;
20
21 import javax.faces.FacesWrapper;
22 import javax.faces.component.UIComponent;
23 import javax.faces.context.FacesContext;
24 import javax.faces.view.BehaviorHolderAttachedObjectHandler;
25
26 /**
27 * This wrapper is used in
28 * FaceletViewDeclarationLanguage#retargetAttachedObjects(FacesContext, UIComponent, List<AttachedObjectHandler>)
29 * to redirect the client behavior attached object when there is a chain of composite components.
30 *
31 * @author Leonardo Uribe (latest modification by $Author: struberg $)
32 * @version $Revision: 1189343 $ $Date: 2011-10-26 12:53:36 -0500 (Wed, 26 Oct 2011) $
33 */
34 public class ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper
35 implements BehaviorHolderAttachedObjectHandler, FacesWrapper<BehaviorHolderAttachedObjectHandler>
36 {
37
38 private final BehaviorHolderAttachedObjectHandler _delegate;
39 private final String _eventName;
40
41 public ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper(
42 BehaviorHolderAttachedObjectHandler delegate, String eventName)
43 {
44 super();
45 _delegate = delegate;
46 _eventName = eventName;
47 }
48
49 public void applyAttachedObject(FacesContext context, UIComponent parent)
50 {
51 _delegate.applyAttachedObject(context, parent);
52 }
53
54 public String getEventName()
55 {
56 return _eventName;
57 }
58
59 public String getWrappedEventName()
60 {
61 if (_delegate instanceof ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper)
62 {
63 return ((ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper) _delegate).getWrappedEventName();
64 }
65 else
66 {
67 return _delegate.getEventName();
68 }
69 }
70
71 public String getFor()
72 {
73 return _delegate.getFor();
74 }
75
76 public BehaviorHolderAttachedObjectHandler getWrapped()
77 {
78 return _delegate;
79 }
80 }