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