org.springjutsu.validation.spel
Class WebContextSPELResolver

java.lang.Object
  extended by org.springjutsu.validation.spel.WebContextSPELResolver

public class WebContextSPELResolver
extends Object

A request-aware resolver of SPEL Expressions. Evaluates SPEL expressions in a MVC & Web Flow aware context.

Author:
Clark Duplichien

Field Summary
protected  org.springframework.expression.ExpressionParser expressionParser
          Expression parser used to parse expressions.
protected  NamedScopeEvaluationContext scopedContext
          Evaluation context which will contain request handler implementation-specific scopes.
 
Constructor Summary
WebContextSPELResolver(Object model)
          Initialize evaluation context and expression parser.
 
Method Summary
 Object getBySpel(String spel)
          Evaluates a SPEL expression within the current web context, returning the result.
protected  org.springframework.webflow.execution.RequestContext getOrMockRequestContext()
          Either gets the current thread-bound Web Flow requestContext instance, if this is a Web Flow request, or mocks a Web Flow request out of an MVC request, in order to standardize our web-scoped property access.
protected  void initContexts(Object model)
          Initialize Scopes to search within the Named Scope Context.
protected  void initPropertyAccessors()
          Initialize property accessors.
 void setBySpel(String spel, Object object)
          Sets some object to the location specified by a spel expression.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

scopedContext

protected NamedScopeEvaluationContext scopedContext
Evaluation context which will contain request handler implementation-specific scopes.


expressionParser

protected org.springframework.expression.ExpressionParser expressionParser
Expression parser used to parse expressions.

Constructor Detail

WebContextSPELResolver

public WebContextSPELResolver(Object model)
Initialize evaluation context and expression parser. Initializes property accessors and contexts.

Parameters:
model - the Model for this request
Method Detail

getBySpel

public Object getBySpel(String spel)
Evaluates a SPEL expression within the current web context, returning the result.

Parameters:
spel - String SPEL expression
Returns:
result of evaluated SPEL expression.

setBySpel

public void setBySpel(String spel,
                      Object object)
Sets some object to the location specified by a spel expression.

Parameters:
spel - String SPEL expression
object - some object to set at SPEL-specified location.

getOrMockRequestContext

protected org.springframework.webflow.execution.RequestContext getOrMockRequestContext()
Either gets the current thread-bound Web Flow requestContext instance, if this is a Web Flow request, or mocks a Web Flow request out of an MVC request, in order to standardize our web-scoped property access. If neither a MVC or Web Flow request is active, return null.

Returns:
RequestContext instance or null if no request

initPropertyAccessors

protected void initPropertyAccessors()
Initialize property accessors. Only add Web Flow variables if this is a Web Flow request.


initContexts

protected void initContexts(Object model)
Initialize Scopes to search within the Named Scope Context. Only add Web Flow Scopes if this is a Web Flow Request.

Parameters:
model - The validated model for this request.


Copyright © 2013 Spring Jutsu. All Rights Reserved.