View Javadoc

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 FaceletViewDeclarationLanguage.retargetAttachedObjects(FacesContext, UIComponent, List<AttachedObjectHandler>)
28   * to redirect the client behavior attached object when there is a chain of composite components.  
29   * 
30   * @author Leonardo Uribe (latest modification by $Author: bommel $)
31   * @version $Revision: 1187700 $ $Date: 2011-10-22 07:19:37 -0500 (Sat, 22 Oct 2011) $
32   */
33  public class ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper implements BehaviorHolderAttachedObjectHandler, FacesWrapper<BehaviorHolderAttachedObjectHandler>
34  {
35      
36      private final BehaviorHolderAttachedObjectHandler _delegate;
37      private final String _eventName;
38  
39      public ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper(
40              BehaviorHolderAttachedObjectHandler delegate, String eventName)
41      {
42          super();
43          _delegate = delegate;
44          _eventName = eventName;
45      }
46  
47      public void applyAttachedObject(FacesContext context, UIComponent parent)
48      {
49          _delegate.applyAttachedObject(context, parent);
50      }
51  
52      public String getEventName()
53      {
54          return _eventName;
55      }
56      
57      public String getWrappedEventName()
58      {
59          if (_delegate instanceof ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper)
60          {
61              return ((ClientBehaviorRedirectBehaviorAttachedObjectHandlerWrapper) _delegate).getWrappedEventName();
62          }
63          else
64          {
65              return _delegate.getEventName();
66          }
67      }
68  
69      public String getFor()
70      {
71          return _delegate.getFor();
72      }
73  
74      public BehaviorHolderAttachedObjectHandler getWrapped()
75      {
76          return _delegate;
77      }
78  }