SWF-1419 Add ability to plug in custom Spring Validator via FlowBuilderServices to support JSR-303 validation

This commit is contained in:
Rossen Stoyanchev
2010-12-02 13:54:00 +00:00
parent 8928b6d7ff
commit df7f3406a0
57 changed files with 981 additions and 142 deletions

View File

@@ -73,25 +73,4 @@ When set to true, changes to a flow definition will be auto-detected and will re
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="resources">
<xsd:annotation>
<xsd:documentation
source="java:org.springframework.faces.webflow.JsfResourceRequestHandler"><![CDATA[
Configures a handler that uses the JSF ResourceHandler API introduced in JSF 2 to serve web application and
classpath resources such as images, CSS and JavaScript files from well-known locations.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="order" type="xsd:int">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Specifies the order of the HandlerMapping for the resource handler. The default order is 0.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<xsd:schema
xmlns="http://www.springframework.org/schema/faces"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:beans="http://www.springframework.org/schema/beans"
targetNamespace="http://www.springframework.org/schema/faces"
elementFormDefault="qualified" attributeFormDefault="unqualified"
version="2.2">
<xsd:import namespace="http://www.springframework.org/schema/beans" schemaLocation="http://www.springframework.org/schema/beans/spring-beans-3.0.xsd" />
<xsd:element name="flow-builder-services">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Registers custom implementations of services needed to build flow definitions in a JSF environment.
With this tag, you may configure a custom ConversionService, FormatterFactory, ExpressionParser, and ViewFactoryCreator implementation.
This tag is only needed when you wish to plugin custom implementations.
]]>
</xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:complexContent>
<xsd:extension base="beans:identifiedType">
<xsd:attribute name="conversion-service">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom ConversionService implementation to use to convert from one type to another.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="expression-parser">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom ExpressionParser implementation to use to compile expression strings into Expressions.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="view-factory-creator">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
The custom ViewFactoryCreator implementation to use produce ViewFactories capable of rendering Views.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="enable-managed-beans" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
When this attribute is set to true, a special EL expression parser will be enabled that allows access to JSF-managed beans
from EL expressions in flow definitions.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
<xsd:attribute name="development" type="xsd:boolean">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Puts all flows in development mode.
When set to true, changes to a flow definition will be auto-detected and will result in a flow refresh.
]]>
</xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:extension>
</xsd:complexContent>
</xsd:complexType>
</xsd:element>
<xsd:element name="resources">
<xsd:annotation>
<xsd:documentation
source="java:org.springframework.faces.webflow.JsfResourceRequestHandler"><![CDATA[
Configures a handler that uses the JSF ResourceHandler API introduced in JSF 2 to serve web application and
classpath resources such as images, CSS and JavaScript files from well-known locations.
]]></xsd:documentation>
</xsd:annotation>
<xsd:complexType>
<xsd:attribute name="order" type="xsd:int">
<xsd:annotation>
<xsd:documentation>
<![CDATA[
Specifies the order of the HandlerMapping for the resource handler. The default order is 0.
]]></xsd:documentation>
</xsd:annotation>
</xsd:attribute>
</xsd:complexType>
</xsd:element>
</xsd:schema>

View File

@@ -15,7 +15,11 @@
*/
package org.springframework.faces.webflow;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.js.ajax.AjaxHandler;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.webflow.mvc.servlet.FlowHandlerAdapter;
/**
@@ -39,4 +43,9 @@ public class JsfFlowHandlerAdapter extends FlowHandlerAdapter {
}
}
public ModelAndView handle(HttpServletRequest request, HttpServletResponse response, Object handler)
throws Exception {
return super.handle(request, response, handler);
}
}

View File

@@ -20,6 +20,7 @@ import javax.faces.lifecycle.Lifecycle;
import org.springframework.binding.convert.ConversionService;
import org.springframework.binding.expression.Expression;
import org.springframework.binding.expression.ExpressionParser;
import org.springframework.validation.Validator;
import org.springframework.webflow.engine.builder.BinderConfiguration;
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
import org.springframework.webflow.execution.ViewFactory;
@@ -36,7 +37,7 @@ public class JsfViewFactoryCreator implements ViewFactoryCreator {
private Lifecycle lifecycle;
public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser,
ConversionService conversionService, BinderConfiguration binderConfiguration) {
ConversionService conversionService, BinderConfiguration binderConfiguration, Validator validator) {
return new JsfViewFactory(viewIdExpression, getLifecycle());
}

View File

@@ -1 +1,3 @@
http\://www.springframework.org/schema/faces/spring-faces-2.0.xsd=org/springframework/faces/config/spring-faces-2.0.xsd
http\://www.springframework.org/schema/faces/spring-faces-2.0.xsd=org/springframework/faces/config/spring-faces-2.0.xsd
http\://www.springframework.org/schema/faces/spring-faces-2.2.xsd=org/springframework/faces/config/spring-faces-2.2.xsd
http\://www.springframework.org/schema/faces/spring-faces.xsd=org/springframework/faces/config/spring-faces-2.2.xsd

View File

@@ -17,6 +17,7 @@ import org.springframework.faces.model.converter.FacesConversionService;
import org.springframework.faces.webflow.FacesSpringELExpressionParser;
import org.springframework.faces.webflow.JSFMockHelper;
import org.springframework.faces.webflow.JsfViewFactoryCreator;
import org.springframework.validation.Validator;
import org.springframework.webflow.engine.builder.BinderConfiguration;
import org.springframework.webflow.engine.builder.ViewFactoryCreator;
import org.springframework.webflow.engine.builder.support.FlowBuilderServices;
@@ -78,7 +79,7 @@ public class FacesFlowBuilderServicesBeanDefinitionParserTests extends TestCase
public static class TestViewFactoryCreator implements ViewFactoryCreator {
public ViewFactory createViewFactory(Expression viewIdExpression, ExpressionParser expressionParser,
ConversionService conversionService, BinderConfiguration binderConfiguration) {
ConversionService conversionService, BinderConfiguration binderConfiguration, Validator validator) {
throw new UnsupportedOperationException("Auto-generated method stub");
}

View File

@@ -4,9 +4,9 @@
xmlns:faces="http://www.springframework.org/schema/faces"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/faces
http://www.springframework.org/schema/faces/spring-faces-2.0.xsd">
http://www.springframework.org/schema/faces/spring-faces.xsd">
<faces:flow-builder-services id="flowBuilderServicesDefault"/>

View File

@@ -3,8 +3,8 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:faces="http://www.springframework.org/schema/faces"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces-2.0.xsd">
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces.xsd">
<faces:resources />