[seam-commits] Seam SVN: r13191 - modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/component.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Wed Jun 16 15:23:00 EDT 2010


Author: dan.j.allen
Date: 2010-06-16 15:23:00 -0400 (Wed, 16 Jun 2010)
New Revision: 13191

Modified:
   modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
Log:
null check for Bean Validation code (seems to be a bug in Bean Validation)
merge


Modified: modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java
===================================================================
--- modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java	2010-06-16 18:59:28 UTC (rev 13190)
+++ modules/faces/trunk/api/src/main/java/org/jboss/seam/faces/component/UIInputContainer.java	2010-06-16 19:23:00 UTC (rev 13191)
@@ -44,6 +44,7 @@
 import javax.validation.ValidationException;
 import javax.validation.Validator;
 import javax.validation.ValidatorFactory;
+import javax.validation.metadata.PropertyDescriptor;
 
 /**
  * <strong>UIInputContainer</strong> is a supplemental component for a JSF 2.0
@@ -92,6 +93,13 @@
  * <li>append styleClass "invalid" to label, inputs and messages when invalid</li>
  * </ul>
  * 
+ * <p>
+ * NOTE: Firefox does not properly associate a label with the target input if the input id contains
+ * a colon (:), the default separator character in JSF. JSF 2 allows developers to set the value via
+ * an initialization parameter (context-param in web.xml) keyed to javax.faces.SEPARATOR_CHAR. We
+ * recommend that you override this setting to make the separator an underscore (_).
+ * </p>
+ *
  * @author Dan Allen
  */
 @FacesComponent(UIInputContainer.COMPONENT_TYPE)
@@ -120,8 +128,9 @@
    }
 
    /**
-    * The name of the auto-generated composite component attribute that holds a
-    * boolean indicating whether the the template contains an invalid input.
+    * The name of the auto-generated composite component attribute
+    * that holds a boolean indicating whether the the template contains
+    * an invalid input.
     */
    public String getInvalidAttributeName()
    {
@@ -129,8 +138,9 @@
    }
 
    /**
-    * The name of the auto-generated composite component attribute that holds a
-    * boolean indicating whether the template contains a required input.
+    * The name of the auto-generated composite component attribute
+    * that holds a boolean indicating whether the template contains
+    * a required input.
     */
    public String getRequiredAttributeName()
    {
@@ -138,9 +148,10 @@
    }
 
    /**
-    * The name of the composite component attribute that holds the string label
-    * for this set of inputs. If the label attribute is not provided, one will
-    * be generated from the id of the composite component or, if the id is
+    * The name of the composite component attribute that
+    * holds the string label for this set of inputs. If the
+    * label attribute is not provided, one will be generated
+    * from the id of the composite component or, if the id is
     * defaulted, the name of the property bound to the first input.
     */
    public String getLabelAttributeName()
@@ -149,9 +160,10 @@
    }
 
    /**
-    * The name of the auto-generated composite component attribute that holds
-    * the elements in this input container. The elements include the label, a
-    * list of inputs and a cooresponding list of messages.
+    * The name of the auto-generated composite component attribute
+    * that holds the elements in this input container. The
+    * elements include the label, a list of inputs and a cooresponding
+    * list of messages.
     */
    public String getElementsAttributeName()
    {
@@ -160,8 +172,8 @@
 
    /**
     * The name of the composite component attribute that holds a boolean
-    * indicating whether the component template should be enclosed in an HTML
-    * element, so that it be referenced from JavaScript.
+    * indicating whether the component template should be enclosed in
+    * an HTML element, so that it be referenced from JavaScript.
     */
    public String getEncloseAttributeName()
    {
@@ -209,8 +221,7 @@
          getAttributes().put(getInvalidAttributeName(), true);
       }
 
-      // set the required attribute, but only if the user didn't already assign
-      // it
+      // set the required attribute, but only if the user didn't already assign it
       if (!getAttributes().containsKey(getRequiredAttributeName()) && elements.hasRequiredInput())
       {
          getAttributes().put(getRequiredAttributeName(), true);
@@ -283,10 +294,9 @@
          elements = new InputContainerElements();
       }
 
-      // NOTE we need to walk the tree ignoring rendered attribute because it's
-      // condition
+      // NOTE we need to walk the tree ignoring rendered attribute because it's condition
       // could be based on what we discover
-      if ((elements.getLabel() == null) && (component instanceof HtmlOutputLabel))
+      if (elements.getLabel() == null && component instanceof HtmlOutputLabel)
       {
          elements.setLabel((HtmlOutputLabel) component);
       }
@@ -308,7 +318,7 @@
    }
 
    // assigning ids seems to break form submissions, but I don't know why
-   public void assignIds(final InputContainerElements elements, final FacesContext context)
+   public void assignIds(final InputContainerElements elements, FacesContext context)
    {
       boolean refreshIds = false;
       if (getId().startsWith(UIViewRoot.UNIQUE_ID_PREFIX))
@@ -357,14 +367,13 @@
    /**
     * Wire the label and messages to the input(s)
     */
-   protected void wire(final InputContainerElements elements, final FacesContext context)
+   protected void wire(final InputContainerElements elements, FacesContext context)
    {
       elements.wire(context);
    }
 
    /**
-    * Get the default Bean Validation Validator to read the contraints for a
-    * property.
+    * Get the default Bean Validation Validator to read the contraints for a property.
     */
    private Validator getDefaultValidator(final FacesContext context) throws FacesException
    {
@@ -494,10 +503,12 @@
             return false;
          }
 
-         // NOTE believe it or not, getValueReference on ValueExpression is
-         // broken, so we have to do it ourselves
-         ValueReference vref = new ValueExpressionAnalyzer(((UIComponent) input).getValueExpression("value")).getValueReference(context.getELContext());
-         return validator.getConstraintsForClass(vref.getBase().getClass()).getConstraintsForProperty((String) vref.getProperty()).hasConstraints();
+         // NOTE believe it or not, getValueReference on ValueExpression is broken, so we have to do it ourselves
+         ValueReference vref = new ValueExpressionAnalyzer(((UIComponent) input).getValueExpression("value"))
+               .getValueReference(context.getELContext());
+         PropertyDescriptor d = validator.getConstraintsForClass(vref.getBase().getClass())
+               .getConstraintsForProperty((String) vref.getProperty());
+         return d != null && d.hasConstraints();
       }
 
       public String getPropertyName(final FacesContext context)
@@ -512,7 +523,8 @@
             return null;
          }
 
-         propertyName = (String) new ValueExpressionAnalyzer(((UIComponent) inputs.get(0)).getValueExpression("value")).getValueReference(context.getELContext()).getProperty();
+         propertyName = (String) new ValueExpressionAnalyzer(((UIComponent) inputs.get(0)).getValueExpression("value"))
+               .getValueReference(context.getELContext()).getProperty();
          return propertyName;
       }
 



More information about the seam-commits mailing list