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.context;
20  
21  
22  import java.util.Map;
23  
24  import javax.faces.context.FacesContext;
25  
26  /**
27   * Abstract implementation for code that provides page flow scopes;  this
28   * may be overridden.
29   * <p>
30   *  To override this, provide a file on the classpath at
31   *  <code>/META-INF/services/org.apache.myfaces.trinidad.context.PageFlowScopeProvider</code>
32   *  with the name of the alternative implementation.  (There's no current
33   *  support for decoration, and this general approach may be revisited
34   *  in the future.)
35   *  </p>
36   */
37  public abstract class PageFlowScopeProvider
38  {  
39    /**
40     */
41    protected PageFlowScopeProvider()
42    {
43    }
44  
45    /**
46     * Returns the current PageFlowScope, including any calls
47     * to <code>pushPageFlowScope()</code> or <code>popPageFlowScope()</code>.
48     * 
49     * @param context the current FacesContext
50     */
51    public abstract Map<String, Object> getPageFlowScope(FacesContext context); 
52  
53    /**
54     * Pushes a new process scope onto the stack.
55     *
56     * @param context the current FacesContext
57     * @param copyParent if true, all values from the parent process
58     *   scope will be copied into the new process scope.
59     * @return the new scope
60     */
61    public abstract Map<String, Object> pushPageFlowScope(
62      FacesContext context,
63      boolean copyParent);
64  
65    /**
66     * Pushes a new process scope onto the stack.
67     *
68     * @param context the current FacesContext
69     * @param discardScope if true, the scope will be immediately destroyed.
70     *   if false, the scope may be available (for back button use, for 
71     *   example), but this is at the discretion of the implementation,
72     *   which may aggressively destroy page flow scopes in some circumstances.
73     */
74    public abstract Map<String, Object> popPageFlowScope(FacesContext context, boolean discardScope);
75  
76    /**
77     * Encode the page flow scope into the current URL for processing
78     * in later requests.
79     *
80     * @param context the current FacesContext
81     * @param url an URL (which may already contain query parameters)
82     */
83    public abstract String encodeCurrentPageFlowScopeURL(
84       FacesContext context,
85       String url);
86  }