freemarker.ext.servlet
Class AllHttpScopesHashModel
java.lang.Object
freemarker.template.WrappingTemplateModel
freemarker.template.SimpleHash
freemarker.ext.servlet.AllHttpScopesHashModel
- All Implemented Interfaces:
- TemplateHashModel, TemplateHashModelEx, TemplateModel, java.io.Serializable
public class AllHttpScopesHashModel
- extends SimpleHash
An extension of SimpleHash that looks up keys in the hash, then in the
request, session, and servlet context scopes. Makes "Application", "Session"
and "Request" keys largely obsolete, however we keep them for backward
compatibility (also, "Request" is required for proper operation of JSP
taglibs).
It is on purpose that we didn't override keys and values
methods. That way, only those variables assigned into the hash directly by a
subclass of FreemarkerServlet that overrides
preTemplateProcess) are discovered as "page" variables by the FM
JSP PageContext implementation.
- Version:
- $Id: AllHttpScopesHashModel.java,v 1.5.4.1 2006/04/26 12:22:07 szegedia Exp $
- Author:
- Attila Szegedi
- See Also:
- Serialized Form
Constructor Summary |
AllHttpScopesHashModel(ObjectWrapper wrapper,
javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request)
Creates a new instance of AllHttpScopesHashModel for handling a single
HTTP servlet request. |
Method Summary |
TemplateModel |
get(java.lang.String key)
Gets a TemplateModel from the hash. |
void |
putUnlistedModel(java.lang.String key,
TemplateModel model)
Stores a model in the hash so that it doesn't show up in keys()
and values() methods. |
Methods inherited from class freemarker.template.SimpleHash |
copyMap, isEmpty, keys, put, put, putAll, remove, size, synchronizedWrapper, toMap, toString, values |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
AllHttpScopesHashModel
public AllHttpScopesHashModel(ObjectWrapper wrapper,
javax.servlet.ServletContext context,
javax.servlet.http.HttpServletRequest request)
- Creates a new instance of AllHttpScopesHashModel for handling a single
HTTP servlet request.
- Parameters:
wrapper
- the object wrapper to usecontext
- the servlet context of the web applicationrequest
- the HTTP servlet request being processed
putUnlistedModel
public void putUnlistedModel(java.lang.String key,
TemplateModel model)
- Stores a model in the hash so that it doesn't show up in keys()
and values() methods. Used to put the Application, Session,
Request, RequestParameters and JspTaglibs objects.
- Parameters:
key
- the key under which the model is storedmodel
- the stored model
get
public TemplateModel get(java.lang.String key)
throws TemplateModelException
- Description copied from interface:
TemplateHashModel
- Gets a TemplateModel from the hash.
- Specified by:
get
in interface TemplateHashModel
- Overrides:
get
in class SimpleHash
- Parameters:
key
- the name by which the TemplateModel
is identified in the template.
- Returns:
- the TemplateModel referred to by the key,
or null if not found.
- Throws:
TemplateModelException