myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r930767 - in /myfaces/extensions/cdi/trunk: examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/ examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/ jee-modules/bv-module/impl/src/main/java/o...
Date Mon, 05 Apr 2010 00:12:13 GMT
Author: gpetracek
Date: Mon Apr  5 00:12:13 2010
New Revision: 930767

URL: http://svn.apache.org/viewvc?rev=930767&view=rev
Log:
EXTCDI-8 support for javax.validation.Validator, javax.validation.ConstraintValidatorFactory
and javax.validation.MessageInterpolator

Modified:
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/BeanValidationDemoBean.java
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
    myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareValidatorFactoryProducer.java

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/BeanValidationDemoBean.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/BeanValidationDemoBean.java?rev=930767&r1=930766&r2=930767&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/BeanValidationDemoBean.java
(original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/BeanValidationDemoBean.java
Mon Apr  5 00:12:13 2010
@@ -23,7 +23,7 @@ import org.apache.myfaces.extensions.cdi
 import javax.enterprise.inject.Model;
 import javax.inject.Inject;
 import javax.validation.ConstraintViolation;
-import javax.validation.ValidatorFactory;
+import javax.validation.Validator;
 import javax.validation.constraints.NotNull;
 import javax.faces.context.FacesContext;
 import javax.faces.application.FacesMessage;
@@ -42,7 +42,7 @@ public class BeanValidationDemoBean
     private String forcedViolation;
 
     @Inject @Advanced
-    private ValidatorFactory validatorFactory;
+    private Validator validator;
 
     @Inject
     private FacesContext facesContext;
@@ -53,8 +53,7 @@ public class BeanValidationDemoBean
      */
     public void send()
     {
-        Set<ConstraintViolation<BeanValidationDemoBean>> violations =
-                this.validatorFactory.getValidator().validate(this);
+        Set<ConstraintViolation<BeanValidationDemoBean>> violations = this.validator.validate(this);
 
         if(!violations.isEmpty()) {
             ConstraintViolation violation = violations.iterator().next();

Modified: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp?rev=930767&r1=930766&r2=930767&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
(original)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/webapp/helloMyFacesCodi.jsp
Mon Apr  5 00:12:13 2010
@@ -39,7 +39,7 @@
                 <h:panelGrid columns="3">
                     <h:outputLabel for="txtInfo" value="Bean-value:"/>
                     <h:inputText id="txtInfo" value="#{beanValidationDemoBean.text}" label="Bean-value"/>
-                    <h:message for="txtInfo" showSummary="false" showDetail="true"/>
+                    <h:message for="txtInfo" showSummary="false" showDetail="true" errorStyle="color:
red;"/>
 
                     <h:commandButton value="send" action="#{beanValidationDemoBean.send}"/>
                     <h:panelGroup/>

Modified: myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareValidatorFactoryProducer.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareValidatorFactoryProducer.java?rev=930767&r1=930766&r2=930767&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareValidatorFactoryProducer.java
(original)
+++ myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareValidatorFactoryProducer.java
Mon Apr  5 00:12:13 2010
@@ -23,8 +23,11 @@ import org.apache.myfaces.extensions.cdi
 
 import javax.enterprise.context.Dependent;
 import javax.enterprise.inject.Produces;
+import javax.validation.ConstraintValidatorFactory;
 import javax.validation.Validation;
+import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
+import javax.validation.MessageInterpolator;
 
 /**
  * @author Gerhard Petracek
@@ -55,4 +58,34 @@ public class CdiAwareValidatorFactoryPro
 
         return new CdiAwareValidatorFactory(validatorFactory);
     }
+
+    @Produces
+    @Dependent
+    @Advanced
+    public Validator createValidatorForDependencyInjectionAwareConstraintValidators(
+            ValidatorFactoryResolver validatorFactoryResolver)
+    {
+        return createValidatorFactoryForDependencyInjectionAwareConstraintValidators(
+                validatorFactoryResolver).getValidator();
+    }
+
+    @Produces
+    @Dependent
+    @Advanced
+    public ConstraintValidatorFactory createConstraintValidatorFactoryForDependencyInjectionAwareConstraintValidators(
+            ValidatorFactoryResolver validatorFactoryResolver)
+    {
+        return createValidatorFactoryForDependencyInjectionAwareConstraintValidators(
+                validatorFactoryResolver).getConstraintValidatorFactory();
+    }
+
+    @Produces
+    @Dependent
+    @Advanced
+    public MessageInterpolator createMessageInterpolator(
+            ValidatorFactoryResolver validatorFactoryResolver)
+    {
+        return createValidatorFactoryForDependencyInjectionAwareConstraintValidators(
+                validatorFactoryResolver).getMessageInterpolator();
+    }
 }
\ No newline at end of file



Mime
View raw message