FileDocCategorySizeDatePackage
ScopesHashModel.javaAPI DocExample3659Mon Jul 23 13:26:42 BST 2007org.apache.struts2.views.freemarker

ScopesHashModel

public class ScopesHashModel extends freemarker.template.SimpleHash
Simple Hash model that also searches other scopes.

If the key doesn't exist in this hash, this template model tries to resolve the key within the attributes of the following scopes, in the order stated: Request, Session, Servlet Context

Fields Summary
private static final long
serialVersionUID
private HttpServletRequest
request
private ServletContext
servletContext
private com.opensymphony.xwork2.util.ValueStack
stack
Constructors Summary
public ScopesHashModel(freemarker.template.ObjectWrapper objectWrapper, ServletContext context, HttpServletRequest request, com.opensymphony.xwork2.util.ValueStack stack)



             
        super(objectWrapper);
        this.servletContext = context;
        this.request = request;
        this.stack = stack;
    
Methods Summary
public freemarker.template.TemplateModelget(java.lang.String key)

        // Lookup in default scope
        TemplateModel model = super.get(key);

        if (model != null) {
            return model;
        }


        if (stack != null) {
            Object obj = stack.findValue(key);

            if (obj != null) {
                return wrap(obj);
            }

            // ok, then try the context
            obj = stack.getContext().get(key);
            if (obj != null) {
                return wrap(obj);
            }
        }

        if (request != null) {
            // Lookup in request scope
            Object obj = request.getAttribute(key);

            if (obj != null) {
                return wrap(obj);
            }

            // Lookup in session scope
            HttpSession session = request.getSession(false);

            if (session != null) {
                obj = session.getAttribute(key);

                if (obj != null) {
                    return wrap(obj);
                }
            }
        }

        if (servletContext != null) {
            // Lookup in application scope
            Object obj = servletContext.getAttribute(key);

            if (obj != null) {
                return wrap(obj);
            }
        }

        return null;
    
public voidput(java.lang.String string, boolean b)

        super.put(string, b);
    
public voidput(java.lang.String string, java.lang.Object object)

        super.put(string, object);