special action handling
TODO - move core.expression package - it isnt that low-level
This commit is contained in:
@@ -0,0 +1,64 @@
|
||||
package org.springframework.webflow.core.expression.el;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
|
||||
import org.springframework.webflow.engine.ActionExecutor;
|
||||
import org.springframework.webflow.engine.AnnotatedAction;
|
||||
import org.springframework.webflow.execution.Action;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
public class ActionExecutingELResolver extends ELResolver {
|
||||
|
||||
public Class getCommonPropertyType(ELContext elContext, Object base) {
|
||||
return Action.class;
|
||||
}
|
||||
|
||||
public Iterator getFeatureDescriptors(ELContext elContext, Object base) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Class getType(ELContext elContext, Object base, Object property) {
|
||||
if (base instanceof Action) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return Action.class;
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public Object getValue(ELContext elContext, Object base, Object property) {
|
||||
if (base instanceof Action) {
|
||||
Action action = (Action) base;
|
||||
elContext.setPropertyResolved(true);
|
||||
if (property == null) {
|
||||
return ActionExecutor.execute(action, RequestContextHolder.getRequestContext());
|
||||
} else {
|
||||
AnnotatedAction decorator = new AnnotatedAction(action);
|
||||
decorator.setMethod((String) property);
|
||||
return ActionExecutor.execute(decorator, RequestContextHolder.getRequestContext());
|
||||
}
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isReadOnly(ELContext elContext, Object base, Object property) {
|
||||
if (base instanceof Action) {
|
||||
elContext.setPropertyResolved(true);
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public void setValue(ELContext elContext, Object base, Object property, Object value) {
|
||||
if (base instanceof Action) {
|
||||
elContext.setPropertyResolved(true);
|
||||
throw new PropertyNotWritableException("The Action cannot be set with an expression.");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -45,6 +45,7 @@ public class WebFlowELExpressionParser extends ELExpressionParser {
|
||||
List customResolvers = new ArrayList();
|
||||
customResolvers.add(new RequestContextELResolver());
|
||||
customResolvers.add(new SpringBeanWebFlowELResolver());
|
||||
customResolvers.add(new ActionExecutingELResolver());
|
||||
customResolvers.add(new ScopeSearchingELResolver());
|
||||
ELResolver resolver = new DefaultELResolver(target, customResolvers);
|
||||
return new WebFlowELContext(resolver);
|
||||
|
||||
@@ -24,6 +24,7 @@ import org.springframework.webflow.config.FlowDefinitionResource;
|
||||
import org.springframework.webflow.config.FlowDefinitionResourceFactory;
|
||||
import org.springframework.webflow.context.ExternalContext;
|
||||
import org.springframework.webflow.core.collection.AttributeMap;
|
||||
import org.springframework.webflow.core.expression.el.WebFlowELExpressionParser;
|
||||
import org.springframework.webflow.engine.EndState;
|
||||
import org.springframework.webflow.engine.Flow;
|
||||
import org.springframework.webflow.test.execution.AbstractXmlFlowExecutionTests;
|
||||
@@ -67,6 +68,7 @@ public class SearchFlowExecutionTests extends AbstractXmlFlowExecutionTests {
|
||||
}
|
||||
|
||||
protected void configure(MockFlowBuilderContext builderContext) {
|
||||
builderContext.getFlowBuilderServices().setExpressionParser(new WebFlowELExpressionParser());
|
||||
Flow mockDetailFlow = new Flow("detail-flow");
|
||||
mockDetailFlow.setInputMapper(new AttributeMapper() {
|
||||
public void map(Object source, Object target, MappingContext context) {
|
||||
|
||||
@@ -5,16 +5,16 @@
|
||||
|
||||
<view-state id="enterCriteria" view="searchCriteria">
|
||||
<render-actions>
|
||||
<evaluate expression="formAction.setupForm" />
|
||||
<evaluate expression="#{formAction.setupForm}" />
|
||||
</render-actions>
|
||||
<transition on="search" to="displayResults">
|
||||
<evaluate expression="formAction.bindAndValidate" />
|
||||
<evaluate expression="#{formAction.bindAndValidate}" />
|
||||
</transition>
|
||||
</view-state>
|
||||
|
||||
<view-state id="displayResults" view="searchResults">
|
||||
<render-actions>
|
||||
<evaluate expression="phonebook.search(searchCriteria)" result="results" />
|
||||
<evaluate expression="#{phonebook.search(searchCriteria)}" result="#{flowScope.results}" />
|
||||
</render-actions>
|
||||
<transition on="newSearch" to="enterCriteria"/>
|
||||
<transition on="select" to="browseDetails"/>
|
||||
@@ -22,7 +22,7 @@
|
||||
|
||||
<subflow-state id="browseDetails" subflow="detail-flow">
|
||||
<input-mapper>
|
||||
<mapping source="${requestParameters.id}" target="${id}" from="string" to="long"/>
|
||||
<mapping source="#{requestParameters.id}" target="#{id}" from="string" to="long"/>
|
||||
</input-mapper>
|
||||
<transition on="finish" to="displayResults"/>
|
||||
</subflow-state>
|
||||
|
||||
Reference in New Issue
Block a user