[seam-commits] Seam SVN: r12045 - in branches/community/Seam_2_2/src: main/org/jboss/seam/navigation and 1 other directories.

seam-commits at lists.jboss.org seam-commits at lists.jboss.org
Fri Feb 12 06:54:10 EST 2010


Author: manaRH
Date: 2010-02-12 06:54:10 -0500 (Fri, 12 Feb 2010)
New Revision: 12045

Modified:
   branches/community/Seam_2_2/src/main/org/jboss/seam/faces/DateConverter.java
   branches/community/Seam_2_2/src/main/org/jboss/seam/navigation/Param.java
   branches/community/Seam_2_2/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java
Log:
JBSEAM-4413

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/faces/DateConverter.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/faces/DateConverter.java	2010-02-12 11:49:22 UTC (rev 12044)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/faces/DateConverter.java	2010-02-12 11:54:10 UTC (rev 12045)
@@ -12,6 +12,7 @@
 import javax.faces.context.FacesContext;
 import javax.faces.convert.ConverterException;
 
+import org.jboss.seam.Component;
 import org.jboss.seam.annotations.Create;
 import org.jboss.seam.annotations.Install;
 import org.jboss.seam.annotations.Name;
@@ -117,4 +118,10 @@
 		}
 		return super.getAsString(context, component, value);
 	}
+	
+	public static javax.faces.convert.Converter getInstance(){
+
+	   return (javax.faces.convert.Converter) Component.getInstance("org.jboss.seam.faces.dateConverter");
+	   
+	}
 }

Modified: branches/community/Seam_2_2/src/main/org/jboss/seam/navigation/Param.java
===================================================================
--- branches/community/Seam_2_2/src/main/org/jboss/seam/navigation/Param.java	2010-02-12 11:49:22 UTC (rev 12044)
+++ branches/community/Seam_2_2/src/main/org/jboss/seam/navigation/Param.java	2010-02-12 11:54:10 UTC (rev 12045)
@@ -1,5 +1,6 @@
 package org.jboss.seam.navigation;
 
+import java.util.Date;
 import java.util.Map;
 
 import javax.el.ELContext;
@@ -67,15 +68,23 @@
       else if (valueExpression==null)
       {
          return null;
-      }
+      } 
       else
       {
          Class<?> type = valueExpression.getType();
-         if (type==null)
+         if (type == null)
          {
             return null;
          }
-         return FacesContext.getCurrentInstance().getApplication().createConverter(type);           
+         
+         if (type.equals(Date.class))
+         {
+            return org.jboss.seam.faces.DateConverter.getInstance();
+         }
+         else
+         {
+            return FacesContext.getCurrentInstance().getApplication().createConverter(type);
+         }
       }
    }
 

Modified: branches/community/Seam_2_2/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java
===================================================================
--- branches/community/Seam_2_2/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java	2010-02-12 11:49:22 UTC (rev 12044)
+++ branches/community/Seam_2_2/src/test/unit/org/jboss/seam/test/unit/PageParamTest.java	2010-02-12 11:54:10 UTC (rev 12045)
@@ -1,5 +1,7 @@
 package org.jboss.seam.test.unit;
 
+import java.util.Date;
+
 import javax.faces.component.UIComponent;
 import javax.faces.context.FacesContext;
 import javax.faces.convert.IntegerConverter;
@@ -10,6 +12,7 @@
 import org.jboss.seam.contexts.Contexts;
 import org.jboss.seam.core.Expressions;
 import org.jboss.seam.core.Validators;
+import org.jboss.seam.faces.DateConverter;
 import org.jboss.seam.navigation.Param;
 import org.testng.annotations.Test;
 
@@ -45,6 +48,15 @@
    }
    
    @Test
+   public void testDateConverter()
+   {
+      Param param = setupParam(false);
+      
+      assert DateConverter.class.equals(param.getConverter().getClass());
+      
+   }
+   
+   @Test
    public void testGetValidatorById() throws ClassNotFoundException
    {
       String validatorId = "TestValidator";
@@ -84,6 +96,20 @@
       }
       return param;
    }
+
+   protected Param setupParam(boolean disableModelValidator)
+   {
+      installComponent(Contexts.getApplicationContext(), DateConverter.class);
+      Param param = new Param("birthDate");
+      param.setValueExpression(Expressions.instance().createValueExpression("#{bean.birthDate}"));
+      Bean bean = new Bean();
+      bean.setBirthDate(new Date());
+      Contexts.getEventContext().set("bean", bean);
+      if (disableModelValidator) {
+         param.setValidateModel(false);
+      }
+      return param;
+   }
    
    public static class TestValidator implements Validator
    {
@@ -94,6 +120,15 @@
    
    class Bean {
       private String value;
+      private Date birthDate;
+      public Date getBirthDate()
+      {
+         return birthDate;
+      }
+      public void setBirthDate(Date birth)
+      {
+         this.birthDate = birth;
+      }
       @Length(min = 3, max = 10)
       public String getValue() {
          return value;



More information about the seam-commits mailing list