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.trinidad.component;
20  
21  import javax.faces.component.UIComponent;
22  import javax.faces.context.FacesContext;
23  import javax.faces.event.FacesEvent;
24  import javax.faces.event.FacesListener;
25  import javax.faces.event.PhaseId;
26  import org.apache.myfaces.trinidad.logging.TrinidadLogger;
27  
28  /**
29   * This class wraps a FacesEvent
30   */
31  public class WrapperEvent extends FacesEvent
32  {
33    public WrapperEvent(UIComponent source, FacesEvent wrappedEvent)
34    {
35      super(source);
36      // Event can't be null 
37      if (wrappedEvent == null)
38        throw new NullPointerException(_LOG.getMessage(
39          "WRAPPEDEVENT"));
40  
41      _event = wrappedEvent;
42    }
43  
44    @Override
45    public PhaseId getPhaseId()
46    {
47      return _event.getPhaseId();
48    }
49  
50    @Override
51    public void setPhaseId(PhaseId phaseId)
52    {
53      _event.setPhaseId(phaseId);
54    }
55  
56    @Override
57    public void processListener(FacesListener listener)
58    {
59      // This event is never delivered to a listener
60      throw new IllegalStateException();
61    }
62  
63    @Override
64    public boolean isAppropriateListener(FacesListener listener)
65    {
66      // This event is never delivered to a listener
67      return false;
68    }
69  
70    public FacesEvent getEvent()
71    {
72      return _event;
73    }
74  
75    /**
76     * Broadcasts the original wrapped event from the wrapper event
77     * 
78     * @param context The current instance of FacesContext
79     */
80    final public void broadcastWrappedEvent(FacesContext context)
81    {
82      UIXComponent.broadcastInContext(context, getEvent());
83    }
84  
85    private final FacesEvent _event;
86    private static final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(
87      WrapperEvent.class);
88    private static final long serialVersionUID = 1L;
89  }