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.application;
21  
22  import org.apache.myfaces.tobago.util.DebugUtils;
23  import org.apache.myfaces.tobago.util.RequestUtils;
24  import org.slf4j.Logger;
25  import org.slf4j.LoggerFactory;
26  
27  import javax.faces.FacesException;
28  import javax.faces.application.ViewHandler;
29  import javax.faces.component.UIViewRoot;
30  import javax.faces.context.FacesContext;
31  import java.io.IOException;
32  import java.util.Locale;
33  
34  /**
35   * Not longer needed.
36   *
37   * @deprecated since Tobago 2.0.0
38   */
39  @Deprecated
40  public class ViewHandlerImpl extends ViewHandler {
41  
42    private static final Logger LOG = LoggerFactory.getLogger(ViewHandlerImpl.class);
43  
44    private ViewHandler base;
45  
46    public ViewHandlerImpl(ViewHandler base) {
47      if (LOG.isInfoEnabled()) {
48        LOG.info("Hiding RI base implementation: " + base);
49      }
50      this.base = base;
51    }
52  
53    public Locale calculateLocale(FacesContext facesContext) {
54      return base.calculateLocale(facesContext);
55    }
56  
57    public String calculateRenderKitId(FacesContext facesContext) {
58      return base.calculateRenderKitId(facesContext);
59    }
60  
61    public UIViewRoot createView(FacesContext facesContext, String viewId) {
62      if (LOG.isDebugEnabled()) {
63        LOG.debug("creating new view with viewId:        '{}'", viewId);
64      }
65      return base.createView(facesContext, viewId);
66    }
67  
68    public String getActionURL(FacesContext facesContext, String viewId) {
69  
70  /*
71      if (PortletUtils.isRenderResponse(facesContext)) {
72        return PortletUtils.setViewIdForUrl(facesContext, viewId);
73      }
74  
75  */
76      return base.getActionURL(facesContext, viewId);
77    }
78  
79    public String getResourceURL(FacesContext facesContext, String path) {
80      return base.getResourceURL(facesContext, path);
81    }
82  
83    public void renderView(FacesContext facesContext, UIViewRoot viewRoot)
84        throws IOException, FacesException {
85      // standard
86      base.renderView(facesContext, viewRoot);
87  
88      if (LOG.isDebugEnabled()) {
89        LOG.debug("VIEW");
90        LOG.debug(DebugUtils.toString(facesContext.getViewRoot(), 0));
91      }
92    }
93  
94    public UIViewRoot restoreView(FacesContext facesContext, String viewId) {
95      if (LOG.isDebugEnabled()) {
96        LOG.debug("restore view with viewId:             '{}'", viewId);
97      }
98      // this is only needed in the first request, the later will be handled by faces
99      // TODO: maybe find a way to make this unneeded
100     RequestUtils.ensureEncoding(facesContext);
101     UIViewRoot viewRoot = base.restoreView(facesContext, viewId);
102     return viewRoot;
103   }
104 
105   public void writeState(FacesContext facesContext) throws IOException {
106     base.writeState(facesContext);
107   }
108 
109 }
110