updated for core.el move and new resolvers
This commit is contained in:
@@ -7,8 +7,8 @@ import org.springframework.faces.expression.LegacyJSFELExpressionParser;
|
||||
import org.springframework.faces.model.converter.FacesConversionService;
|
||||
import org.springframework.faces.webflow.JsfViewFactoryCreator;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.webflow.core.expression.el.WebFlowELExpressionParser;
|
||||
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
|
||||
import org.springframework.webflow.expression.el.WebFlowELExpressionParser;
|
||||
import org.w3c.dom.Element;
|
||||
|
||||
public class FacesFlowBuilderServicesBeanDefinitionParser extends AbstractSingleBeanDefinitionParser implements
|
||||
|
||||
@@ -4,8 +4,8 @@ import javax.el.CompositeELResolver;
|
||||
import javax.faces.el.PropertyResolver;
|
||||
|
||||
import org.springframework.binding.expression.el.MapAdaptableELResolver;
|
||||
import org.springframework.webflow.core.expression.el.RequestContextELResolver;
|
||||
import org.springframework.webflow.core.expression.el.ScopeSearchingELResolver;
|
||||
import org.springframework.webflow.expression.el.RequestContextELResolver;
|
||||
import org.springframework.webflow.expression.el.ScopeSearchingELResolver;
|
||||
|
||||
/**
|
||||
* Assembles {@link RequestContextELResolver} and {@link ScopeSearchingELResolver} into a composite that may be used
|
||||
|
||||
@@ -4,8 +4,9 @@ import javax.el.CompositeELResolver;
|
||||
import javax.faces.el.VariableResolver;
|
||||
|
||||
import org.springframework.binding.expression.el.MapAdaptableELResolver;
|
||||
import org.springframework.webflow.core.expression.el.RequestContextELResolver;
|
||||
import org.springframework.webflow.core.expression.el.ScopeSearchingELResolver;
|
||||
import org.springframework.webflow.expression.el.ImplicitFlowVariableELResolver;
|
||||
import org.springframework.webflow.expression.el.RequestContextELResolver;
|
||||
import org.springframework.webflow.expression.el.ScopeSearchingELResolver;
|
||||
|
||||
/**
|
||||
* Assembles {@link RequestContextELResolver} and {@link ScopeSearchingELResolver} into a composite that may be used
|
||||
|
||||
@@ -1,116 +0,0 @@
|
||||
package org.springframework.faces.expression;
|
||||
|
||||
import java.util.Iterator;
|
||||
|
||||
import javax.el.ELContext;
|
||||
import javax.el.ELResolver;
|
||||
import javax.el.PropertyNotFoundException;
|
||||
import javax.el.PropertyNotWritableException;
|
||||
|
||||
import org.springframework.core.enums.StaticLabeledEnum;
|
||||
import org.springframework.core.enums.StaticLabeledEnumResolver;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.execution.RequestContextHolder;
|
||||
|
||||
public class ImplicitFlowVariableELResolver extends ELResolver {
|
||||
|
||||
public Class getCommonPropertyType(ELContext context, Object base) {
|
||||
return Object.class;
|
||||
}
|
||||
|
||||
public Iterator getFeatureDescriptors(ELContext context, Object base) {
|
||||
return null;
|
||||
}
|
||||
|
||||
public Class getType(ELContext context, Object base, Object property) {
|
||||
if (base == null) {
|
||||
Object resolved = resolveVariable(property.toString());
|
||||
if (resolved != null) {
|
||||
context.setPropertyResolved(true);
|
||||
return resolved.getClass();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public Object getValue(ELContext context, Object base, Object property) {
|
||||
if (base == null) {
|
||||
Object resolved = resolveVariable(property.toString());
|
||||
if (resolved != null) {
|
||||
context.setPropertyResolved(true);
|
||||
return resolved;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isReadOnly(ELContext context, Object base, Object property) {
|
||||
if (base == null) {
|
||||
Object resolved = resolveVariable(property.toString());
|
||||
if (resolved != null) {
|
||||
context.setPropertyResolved(true);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public void setValue(ELContext context, Object base, Object property, Object value) {
|
||||
if (base == null) {
|
||||
Object resolved = resolveVariable(property.toString());
|
||||
if (resolved != null) {
|
||||
context.setPropertyResolved(true);
|
||||
throw new PropertyNotWritableException("The implicit flow variable " + property
|
||||
+ " cannot be overwritten.");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private Object resolveVariable(String variable) {
|
||||
try {
|
||||
ImplicitFlowVariable flowVariable = (ImplicitFlowVariable) StaticLabeledEnumResolver.instance()
|
||||
.getLabeledEnumByLabel(ImplicitFlowVariable.class, variable);
|
||||
return flowVariable.resolve();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class ImplicitFlowVariable extends StaticLabeledEnum {
|
||||
|
||||
private ImplicitFlowVariable(int code, String label) {
|
||||
super(code, label);
|
||||
}
|
||||
|
||||
public static final ImplicitFlowVariable FLASH_SCOPE = new ImplicitFlowVariable(1, "flashScope") {
|
||||
public Object doResolve(RequestContext context) {
|
||||
return context.getFlashScope();
|
||||
}
|
||||
};
|
||||
|
||||
public static final ImplicitFlowVariable FLOW_SCOPE = new ImplicitFlowVariable(2, "flowScope") {
|
||||
public Object doResolve(RequestContext context) {
|
||||
return context.getFlowScope();
|
||||
}
|
||||
};
|
||||
|
||||
public static final ImplicitFlowVariable CONVERSATION_SCOPE = new ImplicitFlowVariable(3, "conversationScope") {
|
||||
public Object doResolve(RequestContext context) {
|
||||
return context.getConversationScope();
|
||||
}
|
||||
};
|
||||
|
||||
public Object resolve() {
|
||||
RequestContext context = RequestContextHolder.getRequestContext();
|
||||
if (context != null) {
|
||||
return doResolve(context);
|
||||
} else {
|
||||
throw new PropertyNotFoundException("Implicit flow variable " + this.getLabel()
|
||||
+ " could not be resolved. No active flow found.");
|
||||
}
|
||||
}
|
||||
|
||||
public abstract Object doResolve(RequestContext context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -13,10 +13,12 @@ import org.springframework.binding.expression.el.DefaultELResolver;
|
||||
import org.springframework.binding.expression.el.ELContextFactory;
|
||||
import org.springframework.binding.expression.el.ELExpressionParser;
|
||||
import org.springframework.webflow.core.collection.MutableAttributeMap;
|
||||
import org.springframework.webflow.core.expression.el.RequestContextELResolver;
|
||||
import org.springframework.webflow.core.expression.el.ScopeSearchingELResolver;
|
||||
import org.springframework.webflow.core.expression.el.SpringBeanWebFlowELResolver;
|
||||
import org.springframework.webflow.execution.RequestContext;
|
||||
import org.springframework.webflow.expression.el.ActionMethodELResolver;
|
||||
import org.springframework.webflow.expression.el.ImplicitFlowVariableELResolver;
|
||||
import org.springframework.webflow.expression.el.RequestContextELResolver;
|
||||
import org.springframework.webflow.expression.el.ScopeSearchingELResolver;
|
||||
import org.springframework.webflow.expression.el.SpringBeanWebFlowELResolver;
|
||||
|
||||
/**
|
||||
* A JSF-specific ExpressionParser that allows beans managed by either JSF, Spring, or Web Flow referenced in
|
||||
@@ -47,7 +49,9 @@ public class LegacyJSFELExpressionParser extends ELExpressionParser {
|
||||
public ELContext getELContext(Object target) {
|
||||
List customResolvers = new ArrayList();
|
||||
customResolvers.add(new RequestContextELResolver());
|
||||
customResolvers.add(new ImplicitFlowVariableELResolver());
|
||||
customResolvers.add(new SpringBeanWebFlowELResolver());
|
||||
customResolvers.add(new ActionMethodELResolver());
|
||||
customResolvers.add(new ScopeSearchingELResolver());
|
||||
customResolvers.add(new LegacyJSFBeanResolver());
|
||||
ELResolver resolver = new DefaultELResolver(target, customResolvers);
|
||||
|
||||
Reference in New Issue
Block a user