fixed EL-based transition crieria bug
This commit is contained in:
@@ -402,7 +402,7 @@ public interface FlowOutcome {
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<subflow-state id="addGuest" subflow="createGuest">
|
||||
<transition on="guestCreated" to="reviewBooking">
|
||||
<evaluate expression="booking.guests.add(currentEvent.guest)" />
|
||||
<evaluate expression="booking.guests.add(currentEvent.attributes.guest)" />
|
||||
</transition>
|
||||
<transition on="creationCancelled" to="reviewBooking" />
|
||||
</subfow-state>]]>
|
||||
@@ -430,7 +430,7 @@ public interface FlowOutcome {
|
||||
</para>
|
||||
<programlisting language="xml"><![CDATA[
|
||||
<transition on="guestCreated" to="reviewBooking">
|
||||
<evaluate expression="booking.guests.add(currentEvent.guest)" />
|
||||
<evaluate expression="booking.guests.add(currentEvent.attributes.guest)" />
|
||||
</transition>]]>
|
||||
</programlisting>
|
||||
<para>
|
||||
@@ -469,7 +469,7 @@ public interface FlowOutcome {
|
||||
|
||||
<subflow-state id="addGuest" subflow="createGuest">
|
||||
<transition on="guestCreated" to="reviewBooking">
|
||||
<evaluate expression="booking.guests.add(currentEvent.guest)"/>
|
||||
<evaluate expression="booking.guests.add(currentEvent.attributes.guest)"/>
|
||||
</transition>
|
||||
<transition on="creationCancelled" to="reviewBooking" />
|
||||
</subfow-state>
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.0.5.v200803132004]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[2.0.5.v200805032123]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/main/webapp/WEB-INF/config/web-application-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/data-access-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/security-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webflow-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webmvc-config.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
<configSet>
|
||||
<name><![CDATA[webapp]]></name>
|
||||
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
<config>src/main/webapp/WEB-INF/config/web-application-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/data-access-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/security-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webflow-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webmvc-config.xml</config>
|
||||
</configs>
|
||||
</configSet>
|
||||
</configSets>
|
||||
</beansProjectDescription>
|
||||
|
||||
@@ -1,30 +1,13 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.0.5.v200803132004]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[2.0.5.v200805032123]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/main/webapp/WEB-INF/config/data-access-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/security-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/web-application-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webflow-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webmvc-config.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
<configSet>
|
||||
<name><![CDATA[webapp]]></name>
|
||||
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
<config>src/main/webapp/WEB-INF/config/web-application-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/data-access-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/security-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webflow-config.xml</config>
|
||||
<config>src/main/webapp/WEB-INF/config/webmvc-config.xml</config>
|
||||
</configs>
|
||||
</configSet>
|
||||
</configSets>
|
||||
</beansProjectDescription>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.0.5.v200803132004]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[2.0.5.v200805032123]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.0.4.v200802202100]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[2.0.5.v200805032123]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
@@ -9,26 +9,5 @@
|
||||
<configs>
|
||||
</configs>
|
||||
<configSets>
|
||||
<configSet>
|
||||
<name><![CDATA[webapp-config]]></name>
|
||||
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
</configs>
|
||||
</configSet>
|
||||
<configSet>
|
||||
<name><![CDATA[booking]]></name>
|
||||
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
</configs>
|
||||
</configSet>
|
||||
<configSet>
|
||||
<name><![CDATA[main]]></name>
|
||||
<allowBeanDefinitionOverriding>true</allowBeanDefinitionOverriding>
|
||||
<incomplete>false</incomplete>
|
||||
<configs>
|
||||
</configs>
|
||||
</configSet>
|
||||
</configSets>
|
||||
</beansProjectDescription>
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<beansProjectDescription>
|
||||
<version>1</version>
|
||||
<pluginVersion><![CDATA[2.0.4.v200802202100]]></pluginVersion>
|
||||
<pluginVersion><![CDATA[2.0.5.v200805032123]]></pluginVersion>
|
||||
<configSuffixes>
|
||||
<configSuffix><![CDATA[xml]]></configSuffix>
|
||||
</configSuffixes>
|
||||
<enableImports><![CDATA[false]]></enableImports>
|
||||
<configs>
|
||||
<config>src/main/webapp/WEB-INF/web-application-config.xml</config>
|
||||
</configs>
|
||||
<configSets>
|
||||
</configSets>
|
||||
|
||||
@@ -19,7 +19,6 @@ import org.springframework.binding.convert.ConversionExecutionException;
|
||||
import org.springframework.binding.convert.Converter;
|
||||
import org.springframework.binding.expression.Expression;
|
||||
import org.springframework.binding.expression.ExpressionParser;
|
||||
import org.springframework.binding.expression.ExpressionVariable;
|
||||
import org.springframework.binding.expression.support.FluentParserContext;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.webflow.engine.TransitionCriteria;
|
||||
@@ -92,7 +91,7 @@ class TextToTransitionCriteria implements Converter {
|
||||
protected TransitionCriteria createBooleanExpressionTransitionCriteria(String encodedCriteria,
|
||||
ExpressionParser parser) throws ConversionExecutionException {
|
||||
Expression expression = parser.parseExpression(encodedCriteria, new FluentParserContext().template().evaluate(
|
||||
RequestContext.class).variable(new ExpressionVariable("result", "lastEvent.id")));
|
||||
RequestContext.class));
|
||||
return new DefaultTransitionCriteria(expression);
|
||||
}
|
||||
}
|
||||
@@ -228,7 +228,8 @@ class RequestControlContextImpl implements RequestControlContext {
|
||||
|
||||
public String toString() {
|
||||
return new ToStringCreator(this).append("externalContext", externalContext)
|
||||
.append("requestScope", requestScope).append("attributes", attributes).append("flowExecution",
|
||||
flowExecution).toString();
|
||||
.append("currentEvent", currentEvent).append("requestScope", requestScope).append("attributes",
|
||||
attributes).append("messageContext", messageContext).append("flowExecution", flowExecution)
|
||||
.toString();
|
||||
}
|
||||
}
|
||||
@@ -34,7 +34,6 @@ import org.springframework.webflow.context.ExternalContextHolder;
|
||||
import org.springframework.webflow.core.collection.MutableAttributeMap;
|
||||
import org.springframework.webflow.engine.AnnotatedAction;
|
||||
import org.springframework.webflow.execution.Action;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
|
||||
/**
|
||||
@@ -55,7 +54,6 @@ public class WebFlowOgnlExpressionParser extends OgnlExpressionParser {
|
||||
addPropertyAccessor(MessageSource.class, new MessageSourcePropertyAccessor());
|
||||
addPropertyAccessor(RequestContext.class, new RequestContextPropertyAccessor(new ObjectPropertyAccessor()));
|
||||
addPropertyAccessor(Action.class, new ActionPropertyAccessor());
|
||||
addPropertyAccessor(Event.class, new EventPropertyAccessor());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -215,20 +213,6 @@ public class WebFlowOgnlExpressionParser extends OgnlExpressionParser {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves event attributes.
|
||||
*/
|
||||
private static class EventPropertyAccessor implements PropertyAccessor {
|
||||
public Object getProperty(Map context, Object target, Object name) throws OgnlException {
|
||||
Event event = (Event) target;
|
||||
return event.getAttributes().get(name.toString());
|
||||
}
|
||||
|
||||
public void setProperty(Map context, Object target, Object name, Object value) throws OgnlException {
|
||||
throw new OgnlException("Cannot set attributes on an Event instance - operation not allowed");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Resolves messages.
|
||||
*/
|
||||
|
||||
@@ -58,7 +58,6 @@ public class WebFlowELExpressionParser extends ELExpressionParser {
|
||||
customResolvers.add(new ImplicitFlowVariableELResolver(context));
|
||||
customResolvers.add(new ScopeSearchingELResolver(context));
|
||||
customResolvers.add(new SpringBeanWebFlowELResolver(context));
|
||||
customResolvers.add(new EventAttributesElResolver());
|
||||
customResolvers.add(new ActionMethodELResolver());
|
||||
ELResolver resolver = new DefaultELResolver(customResolvers);
|
||||
return new WebFlowELContext(resolver);
|
||||
|
||||
@@ -83,6 +83,15 @@ public class TextToTransitionCriteriaTests extends TestCase {
|
||||
assertTrue("Criterion should evaluate to true", criterion.test(ctx));
|
||||
}
|
||||
|
||||
public void testCurrenEventEval() throws Exception {
|
||||
String expression = "${currentEvent == 'submit'}";
|
||||
TransitionCriteria criterion = (TransitionCriteria) converter.convert(expression, TransitionCriteria.class,
|
||||
null);
|
||||
MockRequestContext ctx = getRequestContext();
|
||||
ctx.setCurrentEvent(new Event(this, "submit"));
|
||||
assertTrue("Criterion should evaluate to true", criterion.test(ctx));
|
||||
}
|
||||
|
||||
public void testNullExpressionEvaluation() throws Exception {
|
||||
serviceLocator.getFlowBuilderServices().setExpressionParser(new ExpressionParser() {
|
||||
public Expression parseExpression(String expressionString, ParserContext context) throws ParserException {
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.springframework.webflow.core.collection.MutableAttributeMap;
|
||||
import org.springframework.webflow.engine.AnnotatedAction;
|
||||
import org.springframework.webflow.engine.StubViewFactory;
|
||||
import org.springframework.webflow.engine.ViewState;
|
||||
import org.springframework.webflow.execution.Event;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.TestAction;
|
||||
import org.springframework.webflow.test.MockRequestContext;
|
||||
@@ -173,6 +174,16 @@ public class WebFlowOgnlExpressionParserTests extends TestCase {
|
||||
assertEquals("setupForm", action.getMethod());
|
||||
}
|
||||
|
||||
public void testResolveEventAttributes() {
|
||||
MockRequestContext context = new MockRequestContext();
|
||||
LocalAttributeMap attributes = new LocalAttributeMap();
|
||||
attributes.put("foo", "bar");
|
||||
context.setCurrentEvent(new Event(this, "event", attributes));
|
||||
Expression exp = parser.parseExpression("currentEvent.attributes.foo", new FluentParserContext()
|
||||
.evaluate(RequestContext.class));
|
||||
assertEquals("bar", exp.getValue(context));
|
||||
}
|
||||
|
||||
public void testResolveMessage() {
|
||||
MockRequestContext context = new MockRequestContext();
|
||||
StaticApplicationContext ac = new StaticApplicationContext();
|
||||
|
||||
@@ -177,7 +177,7 @@ public class WebFlowELExpressionParserTests extends TestCase {
|
||||
LocalAttributeMap attributes = new LocalAttributeMap();
|
||||
attributes.put("foo", "bar");
|
||||
context.setCurrentEvent(new Event(this, "event", attributes));
|
||||
Expression exp = parser.parseExpression("currentEvent.foo", new FluentParserContext()
|
||||
Expression exp = parser.parseExpression("currentEvent.attributes.foo", new FluentParserContext()
|
||||
.evaluate(RequestContext.class));
|
||||
assertEquals("bar", exp.getValue(context));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user