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.context;
20  
21  import javax.el.ELContext;
22  import javax.faces.application.Application;
23  import javax.faces.application.FacesMessage;
24  import javax.faces.application.FacesMessage.Severity;
25  import javax.faces.component.UIViewRoot;
26  import javax.faces.context.ExceptionHandler;
27  import javax.faces.context.ExternalContext;
28  import javax.faces.context.FacesContext;
29  import javax.faces.context.PartialViewContext;
30  import javax.faces.context.ResponseStream;
31  import javax.faces.context.ResponseWriter;
32  import javax.faces.event.PhaseId;
33  import javax.faces.render.RenderKit;
34  import java.util.Iterator;
35  import java.util.List;
36  import java.util.Map;
37  
38  /**
39   * Convenient class to wrap the current FacesContext.
40   * 
41   * @author Manfred Geiler (latest modification by $Author$)
42   * @author Anton Koinov
43   * @version $Revision$ $Date$
44   */
45  public class FacesContextWrapper extends FacesContext
46  {
47      // ~ Instance fields ----------------------------------------------------------------------------
48  
49      private FacesContext _facesContext;
50  
51      // ~ Constructors -------------------------------------------------------------------------------
52  
53      public FacesContextWrapper(FacesContext facesContext)
54      {
55          _facesContext = facesContext;
56      }
57  
58      // ~ Methods ------------------------------------------------------------------------------------
59  
60      @Override
61      public Application getApplication()
62      {
63          return _facesContext.getApplication();
64      }
65  
66      @Override
67      public Map<Object,Object> getAttributes()
68      {
69          return _facesContext.getAttributes();
70      }
71  
72      @Override
73      public Iterator<String> getClientIdsWithMessages()
74      {
75          return _facesContext.getClientIdsWithMessages();
76      }
77  
78      @Override
79      public PhaseId getCurrentPhaseId()
80      {
81          return _facesContext.getCurrentPhaseId();
82      }
83      
84      @Override
85      public ExceptionHandler getExceptionHandler()
86      {
87          return _facesContext.getExceptionHandler();
88      }
89  
90      @Override
91      public ExternalContext getExternalContext()
92      {
93          return _facesContext.getExternalContext();
94      }
95  
96      @Override
97      public Severity getMaximumSeverity()
98      {
99          return _facesContext.getMaximumSeverity();
100     }
101 
102     @Override
103     public List<FacesMessage> getMessageList()
104     {
105         return _facesContext.getMessageList();
106     }
107 
108     @Override
109     public List<FacesMessage> getMessageList(String clientId)
110     {
111         return _facesContext.getMessageList(clientId);
112     }
113 
114     @Override
115     public Iterator<FacesMessage> getMessages()
116     {
117         return _facesContext.getMessages();
118     }
119 
120     @Override
121     public Iterator<FacesMessage> getMessages(String clientId)
122     {
123         return _facesContext.getMessages(clientId);
124     }
125 
126     @Override
127     public PartialViewContext getPartialViewContext()
128     {
129         return _facesContext.getPartialViewContext();
130     }
131 
132     @Override
133     public RenderKit getRenderKit()
134     {
135         return _facesContext.getRenderKit();
136     }
137 
138     @Override
139     public boolean getRenderResponse()
140     {
141         return _facesContext.getRenderResponse();
142     }
143 
144     @Override
145     public boolean getResponseComplete()
146     {
147         return _facesContext.getResponseComplete();
148     }
149 
150     @Override
151     public void setExceptionHandler(ExceptionHandler exceptionHandler)
152     {
153         _facesContext.setExceptionHandler(exceptionHandler);
154     }
155 
156     @Override
157     public void setResponseStream(ResponseStream responsestream)
158     {
159         _facesContext.setResponseStream(responsestream);
160     }
161 
162     @Override
163     public ResponseStream getResponseStream()
164     {
165         return _facesContext.getResponseStream();
166     }
167 
168     @Override
169     public void setResponseWriter(ResponseWriter responsewriter)
170     {
171         _facesContext.setResponseWriter(responsewriter);
172     }
173 
174     @Override
175     public ResponseWriter getResponseWriter()
176     {
177         return _facesContext.getResponseWriter();
178     }
179 
180     @Override
181     public void setViewRoot(UIViewRoot viewRoot)
182     {
183         _facesContext.setViewRoot(viewRoot);
184     }
185 
186     @Override
187     public UIViewRoot getViewRoot()
188     {
189         return _facesContext.getViewRoot();
190     }
191     
192     @Override
193     public boolean isPostback()
194     {
195         return _facesContext.isPostback();
196     }
197 
198     @Override
199     public void addMessage(String clientId, FacesMessage message)
200     {
201         _facesContext.addMessage(clientId, message);
202     }
203 
204     @Override
205     public void release()
206     {
207         _facesContext.release();
208     }
209 
210     @Override
211     public void renderResponse()
212     {
213         _facesContext.renderResponse();
214     }
215 
216     @Override
217     public void responseComplete()
218     {
219         _facesContext.responseComplete();
220     }
221     
222     @Override
223     public ELContext getELContext()
224     {
225         return _facesContext.getELContext();
226     }
227     
228     @Override
229     public void setCurrentPhaseId(PhaseId currentPhaseId)
230     {
231         _facesContext.setCurrentPhaseId(currentPhaseId);
232     }
233 }