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.lifecycle;
20  
21  import javax.faces.FacesException;
22  import javax.faces.component.UIComponent;
23  import javax.faces.context.ExternalContext;
24  import javax.faces.context.FacesContext;
25  
26  /**
27   * Support class for restore view phase
28   * 
29   * @author Mathias Broekelmann (latest modification by $Author: lu4242 $)
30   * @version $Revision: 887436 $ $Date: 2009-12-04 18:11:25 -0500 (Fri, 04 Dec 2009) $
31   */
32  public interface RestoreViewSupport
33  {
34      /**
35       * <p>
36       * Calculates the view id from the given faces context by the following algorithm
37       * </p>
38       * <ul>
39       * <li>lookup the viewid from the request attribute "javax.servlet.include.path_info"
40       * <li>if null lookup the value for viewid by {@link ExternalContext#getRequestPathInfo()}
41       * <li>if null lookup the value for viewid from the request attribute "javax.servlet.include.servlet_path"
42       * <li>if null lookup the value for viewid by {@link ExternalContext#getRequestServletPath()}
43       * <li>if null throw a {@link FacesException}
44       * </ul>
45       */
46      String calculateViewId(FacesContext facesContext);
47      
48      /**
49       *  Derive a view id retrieved from calling calculateViewId(FacesContext), but
50       * do not check if a resource with this name exists. This method is useful
51       * to retrieve a VDL instance, but note there are some cases (TCK test) where
52       * it is expected in Restore View algorithm a null or dummy viewId is passed. 
53       * 
54       * @param context
55       * @param viewId
56       * @return
57       */
58      String deriveViewId(FacesContext context, String viewId);
59  
60      /**
61       * Processes the component tree. For each component (including the given one) in the tree determine if a value
62       * expression for the attribute "binding" is defined. If the expression is not null set the component instance to
63       * the value of this expression
64       * 
65       * @param facesContext
66       * @param component
67       *            the root component
68       */
69      void processComponentBinding(FacesContext facesContext, UIComponent component);
70  
71      /**
72       * <p>
73       * Determine if the current request is a post back by the following algorithm.
74       * </p>
75       * <p>
76       * Find the render-kit-id for the current request by calling calculateRenderKitId() on the Application’s
77       * ViewHandler. Get that RenderKit’s ResponseStateManager and call its isPostback() method, passing the given
78       * FacesContext.
79       * </p>
80       * 
81       * @param facesContext
82       * @return
83       */
84      boolean isPostback(FacesContext facesContext);
85  }