001: /**
002: * Licensed under the Common Development and Distribution License,
003: * you may not use this file except in compliance with the License.
004: * You may obtain a copy of the License at
005: *
006: * http://www.sun.com/cddl/
007: *
008: * Unless required by applicable law or agreed to in writing, software
009: * distributed under the License is distributed on an "AS IS" BASIS,
010: * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
011: * implied. See the License for the specific language governing
012: * permissions and limitations under the License.
013: */package com.sun.facelets;
014:
015: import java.io.IOException;
016: import java.net.URL;
017:
018: import javax.el.ELContext;
019: import javax.el.ELException;
020: import javax.el.ExpressionFactory;
021: import javax.el.FunctionMapper;
022: import javax.el.VariableMapper;
023: import javax.faces.FacesException;
024: import javax.faces.component.UIComponent;
025: import javax.faces.context.FacesContext;
026:
027: /**
028: * Context representative of a single request from a Facelet
029: *
030: * @author Jacob Hookom
031: * @version $Id: FaceletContext.java,v 1.6 2006/03/29 04:10:11 jhook Exp $
032: */
033: public abstract class FaceletContext extends ELContext {
034:
035: /**
036: * The current FacesContext bound to this "request"
037: *
038: * @return cannot be null
039: */
040: public abstract FacesContext getFacesContext();
041:
042: /**
043: * Generate a unique ID for the passed String
044: *
045: * @param base
046: * @return a unique ID given the passed base
047: */
048: public abstract String generateUniqueId(String base);
049:
050: /**
051: * The ExpressionFactory to use within the Facelet this context is executing
052: * upon.
053: *
054: * @return cannot be null
055: */
056: public abstract ExpressionFactory getExpressionFactory();
057:
058: /**
059: * Set the VariableMapper to use in EL evaluation/creation
060: *
061: * @param varMapper
062: */
063: public abstract void setVariableMapper(VariableMapper varMapper);
064:
065: /**
066: * Set the FunctionMapper to use in EL evaluation/creation
067: *
068: * @param fnMapper
069: */
070: public abstract void setFunctionMapper(FunctionMapper fnMapper);
071:
072: /**
073: * Support method which is backed by the current VariableMapper
074: *
075: * @param name
076: * @param value
077: */
078: public abstract void setAttribute(String name, Object value);
079:
080: /**
081: * Support method which is backed by the current VariableMapper
082: *
083: * @param name
084: * @return an Object specified for that name
085: */
086: public abstract Object getAttribute(String name);
087:
088: /**
089: * Include another Facelet defined at some path, relative to the executing
090: * context, not the current Facelet (same as include directive in JSP)
091: *
092: * @param parent
093: * @param relativePath
094: * @throws IOException
095: * @throws FaceletException
096: * @throws FacesException
097: * @throws ELException
098: */
099: public abstract void includeFacelet(UIComponent parent,
100: String relativePath) throws IOException, FaceletException,
101: FacesException, ELException;
102:
103: /**
104: * Include another Facelet defined at some path, absolute to this
105: * ClassLoader/OS
106: *
107: * @param parent
108: * @param absolutePath
109: * @throws IOException
110: * @throws FaceletException
111: * @throws FacesException
112: * @throws ELException
113: */
114: public abstract void includeFacelet(UIComponent parent,
115: URL absolutePath) throws IOException, FaceletException,
116: 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: public abstract void extendClient(TemplateClient client);
132:
133: /**
134: * This method will walk through the TemplateClient stack to resolve and
135: * apply the definition for the passed name.
136: * If it's been resolved and applied, this method will return true.
137: *
138: * @param parent the UIComponent to apply to
139: * @param name name or null of the definition you want to apply
140: * @return true if successfully applied, otherwise false
141: * @throws IOException
142: * @throws FaceletException
143: * @throws FacesException
144: * @throws ELException
145: */
146: public abstract boolean includeDefinition(UIComponent parent,
147: String name) throws IOException, FaceletException,
148: FacesException, ELException;
149: }
|