1 16 package org.springframework.webflow.action; 17 18 import org.springframework.binding.expression.EvaluationContext; 19 import org.springframework.binding.expression.Expression; 20 import org.springframework.binding.expression.SettableExpression; 21 import org.springframework.util.Assert; 22 import org.springframework.webflow.core.collection.MutableAttributeMap; 23 import org.springframework.webflow.execution.Event; 24 import org.springframework.webflow.execution.RequestContext; 25 import org.springframework.webflow.execution.ScopeType; 26 27 33 public class SetAction extends AbstractAction { 34 35 38 private SettableExpression attributeExpression; 39 40 43 private ScopeType scope; 44 45 48 private Expression valueExpression; 49 50 56 public SetAction(SettableExpression attributeExpression, ScopeType scope, Expression valueExpression) { 57 Assert.notNull(attributeExpression, "The attribute expression is required"); 58 Assert.notNull(scope, "The scope type is required"); 59 Assert.notNull(valueExpression, "The value expression is required"); 60 this.attributeExpression = attributeExpression; 61 this.scope = scope; 62 this.valueExpression = valueExpression; 63 } 64 65 protected Event doExecute(RequestContext context) throws Exception { 66 EvaluationContext evaluationContext = getEvaluationContext(context); 67 Object value = valueExpression.evaluate(context, evaluationContext); 68 MutableAttributeMap scopeMap = scope.getScope(context); 69 attributeExpression.evaluateToSet(scopeMap, value, evaluationContext); 70 return success(); 71 } 72 73 79 protected EvaluationContext getEvaluationContext(RequestContext context) { 80 return null; 81 } 82 } | Popular Tags |