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 * @author Jacob Hookom (latest modification by $Author: bommel $)
39 * @version $Revision: 1187701 $ $Date: 2011-10-22 07:21:54 -0500 (Sat, 22 Oct 2011) $
40 *
41 * @since 2.0
42 */
43 public abstract class FaceletContext extends ELContext
44 {
45 // TODO: REPORT this aberration to the EG
46 public static final String FACELET_CONTEXT_KEY = "com.sun.faces.facelets.FACELET_CONTEXT";
47
48 /**
49 * Generate a unique ID for the passed String
50 *
51 * @param base
52 * @return a unique ID given the passed base
53 */
54 public abstract String generateUniqueId(String base);
55
56 /**
57 * Support method which is backed by the current VariableMapper
58 *
59 * @param name
60 * @return an Object specified for that name
61 */
62 public abstract Object getAttribute(String name);
63
64 /**
65 * The ExpressionFactory to use within the Facelet this context is executing upon.
66 *
67 * @return cannot be null
68 */
69 public abstract ExpressionFactory getExpressionFactory();
70
71 /**
72 * The current FacesContext bound to this "request"
73 *
74 * @return cannot be null
75 */
76 public abstract FacesContext getFacesContext();
77
78 /**
79 * Include another Facelet defined at some path, relative to the executing context, not the current Facelet (same as
80 * include directive in JSP)
81 *
82 * @param parent
83 * @param relativePath
84 * @throws IOException
85 * @throws FaceletException
86 * @throws FacesException
87 * @throws ELException
88 */
89 public abstract void includeFacelet(UIComponent parent, String relativePath) throws IOException, FaceletException,
90 FacesException, ELException;
91
92 /**
93 * Include another Facelet defined at some path, absolute to this ClassLoader/OS
94 *
95 * @param parent
96 * @param absolutePath
97 * @throws IOException
98 * @throws FaceletException
99 * @throws FacesException
100 * @throws ELException
101 */
102 public abstract void includeFacelet(UIComponent parent, URL absolutePath) throws IOException, FaceletException,
103 FacesException, ELException;
104
105 /**
106 * Support method which is backed by the current VariableMapper
107 *
108 * @param name
109 * @param value
110 */
111 public abstract void setAttribute(String name, Object value);
112
113 /**
114 * Set the FunctionMapper to use in EL evaluation/creation
115 *
116 * @param fnMapper
117 */
118 public abstract void setFunctionMapper(FunctionMapper fnMapper);
119
120 /**
121 * Set the VariableMapper to use in EL evaluation/creation
122 *
123 * @param varMapper
124 */
125 public abstract void setVariableMapper(VariableMapper varMapper);
126 }