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 javax.faces.view.facelets;
20  
21  import java.io.IOException;
22  import java.net.URL;
23  
24  import javax.el.ELContext;
25  import javax.el.ELException;
26  import javax.el.ExpressionFactory;
27  import javax.el.FunctionMapper;
28  import javax.el.VariableMapper;
29  import javax.faces.FacesException;
30  import javax.faces.component.UIComponent;
31  import javax.faces.context.FacesContext;
32  
33  /**
34   * The parent or root object in a FaceletHandler composition. The Facelet will
35   * take care of populating the passed UIComponent parent in relation to the
36   * create/restore lifecycle of JSF.
37   * 
38   * @since 2.0
39   */
40  public abstract class FaceletContext extends ELContext
41  {
42      // TODO: REPORT this aberration to the EG
43      public static final String FACELET_CONTEXT_KEY = "javax.faces.FACELET_CONTEXT";
44      
45      /**
46       * Generate a unique ID for the passed String
47       * 
48       * @param base
49       * @return a unique ID given the passed base
50       */
51      public abstract String generateUniqueId(String base);
52  
53      /**
54       * Support method which is backed by the current VariableMapper
55       * 
56       * @param name
57       * @return an Object specified for that name
58       */
59      public abstract Object getAttribute(String name);
60  
61      /**
62       * The ExpressionFactory to use within the Facelet this context is executing upon.
63       * 
64       * @return cannot be null
65       */
66      public abstract ExpressionFactory getExpressionFactory();
67  
68      /**
69       * The current FacesContext bound to this "request"
70       * 
71       * @return cannot be null
72       */
73      public abstract FacesContext getFacesContext();
74  
75      /**
76       * Include another Facelet defined at some path, relative to the executing context, not the current Facelet (same as
77       * include directive in JSP)
78       * 
79       * @param parent
80       * @param relativePath
81       * @throws IOException
82       * @throws FaceletException
83       * @throws FacesException
84       * @throws ELException
85       */
86      public abstract void includeFacelet(UIComponent parent, String relativePath) throws IOException, FaceletException,
87              FacesException, ELException;
88  
89      /**
90       * Include another Facelet defined at some path, absolute to this ClassLoader/OS
91       * 
92       * @param parent
93       * @param absolutePath
94       * @throws IOException
95       * @throws FaceletException
96       * @throws FacesException
97       * @throws ELException
98       */
99      public abstract void includeFacelet(UIComponent parent, URL absolutePath) throws IOException, FaceletException,
100             FacesException, ELException;
101 
102     /**
103      * Support method which is backed by the current VariableMapper
104      * 
105      * @param name
106      * @param value
107      */
108     public abstract void setAttribute(String name, Object value);
109 
110     /**
111      * Set the FunctionMapper to use in EL evaluation/creation
112      * 
113      * @param fnMapper
114      */
115     public abstract void setFunctionMapper(FunctionMapper fnMapper);
116 
117     /**
118      * Set the VariableMapper to use in EL evaluation/creation
119      * 
120      * @param varMapper
121      */
122     public abstract void setVariableMapper(VariableMapper varMapper);
123 }