myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gpetra...@apache.org
Subject svn commit: r930769 - in /myfaces/extensions/cdi/trunk: core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/ examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/ jee-modules/bv-module/impl/src/main/jav...
Date Mon, 05 Apr 2010 00:34:23 GMT
Author: gpetracek
Date: Mon Apr  5 00:34:22 2010
New Revision: 930769

URL: http://svn.apache.org/viewvc?rev=930769&view=rev
Log:
EXTCDI-8 minor improvements

Added:
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/TestGroup.java
    myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareBeanValidationProducer.java
      - copied, changed from r930767, myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareValidatorFactoryProducer.java
Removed:
    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/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Advanced.java
    myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/BeanValidationDemoBean.java

Modified: myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Advanced.java
URL: http://svn.apache.org/viewvc/myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Advanced.java?rev=930769&r1=930768&r2=930769&view=diff
==============================================================================
--- myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Advanced.java
(original)
+++ myfaces/extensions/cdi/trunk/core/api/src/main/java/org/apache/myfaces/extensions/cdi/core/api/Advanced.java
Mon Apr  5 00:34:22 2010
@@ -26,11 +26,12 @@ import static java.lang.annotation.Reten
 import static java.lang.annotation.ElementType.PARAMETER;
 import static java.lang.annotation.ElementType.FIELD;
 import static java.lang.annotation.ElementType.METHOD;
+import static java.lang.annotation.ElementType.CONSTRUCTOR;
 
 /**
  * @author Gerhard Petracek
  */
-@Target({PARAMETER, FIELD, METHOD})
+@Target({PARAMETER, FIELD, METHOD, CONSTRUCTOR})
 @Retention(RUNTIME)
 @Documented
 

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=930769&r1=930768&r2=930769&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:34:22 2010
@@ -21,12 +21,12 @@ package org.apache.myfaces.blank.bv;
 import org.apache.myfaces.extensions.cdi.core.api.Advanced;
 
 import javax.enterprise.inject.Model;
+import javax.faces.application.FacesMessage;
+import javax.faces.context.FacesContext;
 import javax.inject.Inject;
 import javax.validation.ConstraintViolation;
 import javax.validation.Validator;
 import javax.validation.constraints.NotNull;
-import javax.faces.context.FacesContext;
-import javax.faces.application.FacesMessage;
 import java.util.Set;
 
 /**
@@ -35,30 +35,45 @@ import java.util.Set;
 @Model
 public class BeanValidationDemoBean
 {
+    @NotNull(groups = TestGroup.class)
+    private String welcomeText = "Hello MyFaces CODI!";
+
     @NotNull
     private String text;
 
     @NotNull
     private String forcedViolation;
 
-    @Inject @Advanced
     private Validator validator;
 
-    @Inject
     private FacesContext facesContext;
 
+    @Inject
+    public BeanValidationDemoBean(@Advanced Validator validator, FacesContext facesContext)
+    {
+        this.validator = validator;
+        this.facesContext = facesContext;
+        performManualValidation(TestGroup.class);
+    }
+
     /**
      * MyFaces ExtVal is used to autom. validate properties bound to the UI
      * This method just illustrates that it's possible to directly use the validator-factory
provided by MyFaces CODI
      */
     public void send()
     {
-        Set<ConstraintViolation<BeanValidationDemoBean>> violations = this.validator.validate(this);
+        performManualValidation();
+    }
+
+    private void performManualValidation(Class... groups)
+    {
+        Set<ConstraintViolation<BeanValidationDemoBean>> violations = this.validator.validate(this,
groups);
 
-        if(!violations.isEmpty()) {
+        if (!violations.isEmpty())
+        {
             ConstraintViolation violation = violations.iterator().next();
             String message = "property: " + violation.getPropertyPath().toString()
-                    + " - message: " +  violation.getMessage();
+                    + " - message: " + violation.getMessage();
             this.facesContext.addMessage(null, new FacesMessage(FacesMessage.SEVERITY_ERROR,
message, message));
         }
     }
@@ -66,6 +81,10 @@ public class BeanValidationDemoBean
     /*
      * generated
      */
+    protected BeanValidationDemoBean()
+    {
+    }
+
     public String getText()
     {
         return text;

Added: myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/TestGroup.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/TestGroup.java?rev=930769&view=auto
==============================================================================
--- myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/TestGroup.java
(added)
+++ myfaces/extensions/cdi/trunk/examples/jsf-examples/hello_myfaces-codi_jsf12/src/main/java/org/apache/myfaces/blank/bv/TestGroup.java
Mon Apr  5 00:34:22 2010
@@ -0,0 +1,26 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.myfaces.blank.bv;
+
+/**
+ * @author Gerhard Petracek
+ */
+public interface TestGroup
+{
+}

Copied: myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareBeanValidationProducer.java
(from r930767, 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/CdiAwareBeanValidationProducer.java?p2=myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareBeanValidationProducer.java&p1=myfaces/extensions/cdi/trunk/jee-modules/bv-module/impl/src/main/java/org/apache/myfaces/extensions/cdi/javaee/bv/impl/CdiAwareValidatorFactoryProducer.java&r1=930767&r2=930769&rev=930769&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/CdiAwareBeanValidationProducer.java
Mon Apr  5 00:34:22 2010
@@ -32,11 +32,11 @@ import javax.validation.MessageInterpola
 /**
  * @author Gerhard Petracek
  */
-public class CdiAwareValidatorFactoryProducer
+public class CdiAwareBeanValidationProducer
 {
     private static ValidatorFactory defaultValidatorFactory;
 
-    protected CdiAwareValidatorFactoryProducer()
+    protected CdiAwareBeanValidationProducer()
     {
     }
 



Mime
View raw message