Source code: com/sun/facelets/FaceletContext.java
1 /**
2 * Licensed under the Common Development and Distribution License,
3 * you may not use this file except in compliance with the License.
4 * You may obtain a copy of the License at
5 *
6 * http://www.sun.com/cddl/
7 *
8 * Unless required by applicable law or agreed to in writing, software
9 * distributed under the License is distributed on an "AS IS" BASIS,
10 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
11 * implied. See the License for the specific language governing
12 * permissions and limitations under the License.
13 */
14
15 package com.sun.facelets;
16
17 import java.io.IOException;
18 import java.net.URL;
19
20 import javax.el.ELContext;
21 import javax.el.ELException;
22 import javax.el.ExpressionFactory;
23 import javax.el.FunctionMapper;
24 import javax.el.VariableMapper;
25 import javax.faces.FacesException;
26 import javax.faces.component.UIComponent;
27 import javax.faces.context.FacesContext;
28
29 /**
30 * Context representative of a single request from a Facelet
31 *
32 * @author Jacob Hookom
33 * @version $Id: FaceletContext.java,v 1.6 2006/03/29 04:10:11 jhook Exp $
34 */
35 public abstract class FaceletContext extends ELContext {
36
37 /**
38 * The current FacesContext bound to this "request"
39 *
40 * @return cannot be null
41 */
42 public abstract FacesContext getFacesContext();
43
44 /**
45 * Generate a unique ID for the passed String
46 *
47 * @param base
48 * @return a unique ID given the passed base
49 */
50 public abstract String generateUniqueId(String base);
51
52 /**
53 * The ExpressionFactory to use within the Facelet this context is executing
54 * upon.
55 *
56 * @return cannot be null
57 */
58 public abstract ExpressionFactory getExpressionFactory();
59
60 /**
61 * Set the VariableMapper to use in EL evaluation/creation
62 *
63 * @param varMapper
64 */
65 public abstract void setVariableMapper(VariableMapper varMapper);
66
67 /**
68 * Set the FunctionMapper to use in EL evaluation/creation
69 *
70 * @param fnMapper
71 */
72 public abstract void setFunctionMapper(FunctionMapper fnMapper);
73
74 /**
75 * Support method which is backed by the current VariableMapper
76 *
77 * @param name
78 * @param value
79 */
80 public abstract void setAttribute(String name, Object value);
81
82 /**
83 * Support method which is backed by the current VariableMapper
84 *
85 * @param name
86 * @return an Object specified for that name
87 */
88 public abstract Object getAttribute(String name);
89
90 /**
91 * Include another Facelet defined at some path, relative to the executing
92 * context, not the current Facelet (same as include directive in JSP)
93 *
94 * @param parent
95 * @param relativePath
96 * @throws IOException
97 * @throws FaceletException
98 * @throws FacesException
99 * @throws ELException
100 */
101 public abstract void includeFacelet(UIComponent parent, String relativePath)
102 throws IOException, FaceletException, FacesException, ELException;
103
104 /**
105 * Include another Facelet defined at some path, absolute to this
106 * ClassLoader/OS
107 *
108 * @param parent
109 * @param absolutePath
110 * @throws IOException
111 * @throws FaceletException
112 * @throws FacesException
113 * @throws ELException
114 */
115 public abstract void includeFacelet(UIComponent parent, URL absolutePath)
116 throws IOException, FaceletException, FacesException, ELException;
117
118 /**
119 * Push the passed TemplateClient onto the stack for Definition Resolution
120 * @param client
121 * @see TemplateClient
122 */
123 public abstract void pushClient(TemplateClient client);
124
125 /**
126 * Pop the last added TemplateClient
127 * @see TemplateClient
128 */
129 public abstract void popClient(TemplateClient client);
130
131
132 public abstract void extendClient(TemplateClient client);
133
134 /**
135 * This method will walk through the TemplateClient stack to resolve and
136 * apply the definition for the passed name.
137 * If it's been resolved and applied, this method will return true.
138 *
139 * @param parent the UIComponent to apply to
140 * @param name name or null of the definition you want to apply
141 * @return true if successfully applied, otherwise false
142 * @throws IOException
143 * @throws FaceletException
144 * @throws FacesException
145 * @throws ELException
146 */
147 public abstract boolean includeDefinition(UIComponent parent, String name) throws IOException, FaceletException, FacesException, ELException ;
148 }