myfaces-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gcrawf...@apache.org
Subject svn commit: r617719 - in /myfaces/trinidad/branches/1.2.4.1-branch: trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/ trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/ trinidad-build/src/main/resources...
Date Sat, 02 Feb 2008 00:25:12 GMT
Author: gcrawford
Date: Fri Feb  1 16:24:54 2008
New Revision: 617719

URL: http://svn.apache.org/viewvc?rev=617719&view=rev
Log:
TRINIDAD-61 patch for branch 1.2.4.1 provided by Yee-Wah Lee.

Modified:
    myfaces/trinidad/branches/1.2.4.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
    myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml
    myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateTimeRange.xml
    myfaces/trinidad/branches/1.2.4.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java

Modified: myfaces/trinidad/branches/1.2.4.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java?rev=617719&r1=617718&r2=617719&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
(original)
+++ myfaces/trinidad/branches/1.2.4.1-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/webapp/UIXComponentELTag.java
Fri Feb  1 16:24:54 2008
@@ -23,9 +23,12 @@
 import java.text.SimpleDateFormat;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.Iterator;
 
+import java.util.TimeZone;
+
 import javax.el.MethodExpression;
 import javax.el.ValueExpression;
 
@@ -259,6 +262,37 @@
     }
   }
 
+    /**
+   * Set a property of type java.util.Date.  If the value
+   * is an EL expression, it will be stored as a ValueBinding.
+   * Otherwise, it will parsed as an ISO 8601 date (yyyy-MM-dd)
+   * and the time components (hour, min, second, millisecond) maximized.
+   * Null values are ignored.
+   */
+    protected void setMaxDateProperty(
+    FacesBean   bean,
+    PropertyKey key,
+    ValueExpression expression)
+  {
+    if (expression == null)
+      return;
+
+    if (expression.isLiteralText())
+    {
+      Date d = _parseISODate(expression.getValue(null));
+      Calendar c = Calendar.getInstance();
+      c.setTime(d);
+      c.set (Calendar.HOUR_OF_DAY, 23);
+      c.set (Calendar.MINUTE, 59);
+      c.set (Calendar.SECOND, 59);
+      c.set (Calendar.MILLISECOND, 999);
+      bean.setProperty(key, c.getTime());
+    }
+    else
+    {
+      bean.setValueExpression(key, expression);
+    }
+  }
 
   protected void setProperties(FacesBean bean)
   {
@@ -393,7 +427,11 @@
   // We rely strictly on ISO 8601 formats
   private static DateFormat _getDateFormat()
   {
-    return new SimpleDateFormat("yyyy-MM-dd");
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+    TimeZone tz = RequestContext.getCurrentInstance().getTimeZone();
+    if (tz != null)
+      sdf.setTimeZone(tz);
+    return sdf;
   }
 
   private MethodExpression  _attributeChangeListener;

Modified: myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml?rev=617719&r1=617718&r2=617719&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml
(original)
+++ myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/components/trinidad/core/CoreChooseDate.xml
Fri Feb  1 16:24:54 2008
@@ -65,6 +65,7 @@
       <property-extension>
         <mfp:property-metadata>
           <mfp:preferred>true</mfp:preferred>
+          <mfp:use-max-time>true</mfp:use-max-time>
         </mfp:property-metadata>
       </property-extension>
     </property>

Modified: myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateTimeRange.xml
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateTimeRange.xml?rev=617719&r1=617718&r2=617719&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateTimeRange.xml
(original)
+++ myfaces/trinidad/branches/1.2.4.1-branch/trinidad-build/src/main/resources/META-INF/maven-faces-plugin/validators/trinidad/DateTimeRange.xml
Fri Feb  1 16:24:54 2008
@@ -39,6 +39,7 @@
       <property-extension>
         <mfp:property-metadata>
           <mfp:preferred>true</mfp:preferred>
+          <mfp:use-max-time>true</mfp:use-max-time>
         </mfp:property-metadata>
       </property-extension>
     </property>

Modified: myfaces/trinidad/branches/1.2.4.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.4.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java?rev=617719&r1=617718&r2=617719&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.4.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
(original)
+++ myfaces/trinidad/branches/1.2.4.1-branch/trinidad-impl/src/main/java/org/apache/myfaces/trinidadinternal/taglib/util/TagUtils.java
Fri Feb  1 16:24:54 2008
@@ -25,6 +25,7 @@
 import java.text.SimpleDateFormat;
 
 import java.util.ArrayList;
+import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.Locale;
@@ -33,6 +34,7 @@
 import javax.faces.application.Application;
 import javax.faces.context.FacesContext;
 
+import org.apache.myfaces.trinidad.context.RequestContext;
 import org.apache.myfaces.trinidad.logging.TrinidadLogger;
 
 import org.apache.myfaces.trinidadinternal.share.xml.XMLUtils;
@@ -184,6 +186,30 @@
   }
 
   /**
+  *  ISO Date String --> Date with time components maximized
+  * @param value
+  * @return
+  */
+  public static Date getDateWithMaxTime(
+    Object value)
+  {
+    if (value == null)
+      return null;
+
+    if (value instanceof Date)
+      return ((Date)value);
+
+    Calendar c = Calendar.getInstance();
+    Date d = _parseISODate(value.toString());
+    c.setTime(d);
+    c.set(Calendar.HOUR_OF_DAY, 23);
+    c.set(Calendar.MINUTE, 59);
+    c.set(Calendar.SECOND, 59);
+    c.set(Calendar.MILLISECOND, 999);
+    return (c.getTime());
+  }
+
+  /**
    * String --> Locale
    * @param value
    * @return
@@ -341,7 +367,11 @@
   // We rely strictly on ISO 8601 formats
   private static DateFormat _getDateFormat()
   {
-    return new SimpleDateFormat("yyyy-MM-dd");
+    SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
+    TimeZone tz = RequestContext.getCurrentInstance().getTimeZone();
+    if (tz != null)
+      sdf.setTimeZone(tz);
+    return sdf;
   }
 
   static private final TrinidadLogger _LOG = TrinidadLogger.createTrinidadLogger(TagUtils.class);



Mime
View raw message