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  
20  package org.apache.myfaces.tobago.internal.lifecycle;
21  
22  import javax.faces.FacesException;
23  import javax.faces.application.Application;
24  import javax.faces.application.ViewHandler;
25  import javax.faces.component.UIViewRoot;
26  import javax.faces.context.FacesContext;
27  import javax.faces.event.PhaseId;
28  import javax.servlet.http.HttpServletResponse;
29  import java.io.IOException;
30  
31  /**
32   * Implements the lifecycle as described in Spec. 1.0 PFD Chapter 2
33   * <p/>
34   * render response phase (JSF Spec 2.2.6)
35   *
36   * Not longer needed.
37   *
38   * @deprecated since Tobago 2.0.0
39   */
40  @Deprecated
41  class RenderResponseExecutor implements PhaseExecutor {
42  
43    public boolean execute(FacesContext facesContext) {
44      Application application = facesContext.getApplication();
45      ViewHandler viewHandler = application.getViewHandler();
46  
47      try {
48        final UIViewRoot viewRoot = facesContext.getViewRoot();
49        if (viewRoot.getViewId() != null) {
50          viewHandler.renderView(facesContext, viewRoot);
51        } else {
52          Object respObj = facesContext.getExternalContext().getResponse();
53          if (respObj instanceof HttpServletResponse) {
54              HttpServletResponse respHttp = (HttpServletResponse) respObj;
55              respHttp.sendError(HttpServletResponse.SC_NOT_FOUND);
56              facesContext.responseComplete();
57          }
58        }
59      } catch (IOException e) {
60        throw new FacesException(e.getMessage(), e);
61      }
62      return false;
63    }
64  
65    public PhaseId getPhase() {
66      return PhaseId.RENDER_RESPONSE;
67    }
68  }