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.render;
20  
21  import java.io.IOException;
22  
23  import javax.faces.FacesException;
24  import javax.faces.component.UIViewRoot;
25  import javax.faces.context.FacesContext;
26  
27  /**
28   * An InternalView is a view ID that is handled internally to the webapp,
29   * without (necessarily) dispatching to an external resource.  This
30   * can also be used to register pseudo-URLs that 
31   * <p>
32   * InternalViews should be registered with a .properties-syntax file at
33   * <code>/META-INF/org.apache.myfaces.trinidad.render.InternalView.properties</code>
34   */
35  public abstract class InternalView
36  {  
37    /**
38     * Creates the UIViewRoot.
39     * <p>
40     * Unlike ViewHandler.createView(), null is an acceptable return value -
41     * it indicates that a default, empty UIViewRoot for this viewId should be
42     * created on behalf of the InternalView, which might populate the
43     * view during renderView().
44     */
45    abstract public UIViewRoot createView(FacesContext context, String viewId);
46  
47    /**
48     * Restores the UIViewRoot;  return null if no view should be returned.
49     */
50    abstract public UIViewRoot restoreView(FacesContext context, String viewId);
51    
52    /**
53     * Renders the view.
54     */
55    abstract public void renderView(
56      FacesContext context, 
57      UIViewRoot   viewToRender) throws IOException, FacesException;
58    
59  
60    /**
61     * Return true if this view is stateless;  which, by default, it is.
62     * Stateless views will have no state saved during Render Response. 
63     * restoreView() will still be called, so a stateless view can
64     * still process postback by returning a populated component tree
65     * from restoreView().
66     */
67    public boolean isStateless(FacesContext context, String viewId)
68    {
69      return true;
70    }
71  }
72