dev@javaserverfaces.java.net

[REVIEW] Update convertDateTime locale and timeZone attributes to accept Object

From: Ryan Lubke <Ryan.Lubke_at_Sun.COM>
Date: Fri, 20 May 2005 14:07:41 -0400

The locale and timeZone attributes of dateTime had the expected type of
java.util.Locale
and java.util.TimeZone (respectively). This is incorrect since the docs
for these attributes
state the value can be one of those objects, or a String that is correct
to create on of those objects

SECTION: Modified Files
----------------------------
M conf/share/jsf_core.tld
  - update convertDateTime locale and timeZone attributes to accept Object.

M src/com/sun/faces/taglib/jsf_core/ConvertDateTimeTag.java
  - updated setPropertiesLogic to take the above info into account.

M systest/build-tests.xml
  - added new systest converter05

A systest/web/converter05.jsp
A systest/web/golden/standard/converter05.txt
  - new systest to ensure the locale and timeZone attributes
    accept:
      * literal text
      * VE resolving to a String
      * VE resolving to either a Locale or TimeZone object depending
         on attribute


SECTION: Diffs
----------------------------
Index: conf/share/jsf_core.tld
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/conf/share/jsf_core.tld,v
retrieving revision 1.52
diff -u -r1.52 jsf_core.tld
--- conf/share/jsf_core.tld 20 May 2005 16:10:25 -0000 1.52
+++ conf/share/jsf_core.tld 20 May 2005 18:04:03 -0000
@@ -168,7 +168,7 @@
             <name>locale</name>
             <required>false</required>
             <deferred-value>
- <type>java.util.Locale</type>
+ <type>java.lang.Object</type>
             </deferred-value>
         </attribute>
 
@@ -207,7 +207,7 @@
             </description>
             <name>timeZone</name>
             <deferred-value>
- <type>java.util.TimeZone</type>
+ <type>java.lang.Object</type>
             </deferred-value>
         </attribute>
 
Index: src/com/sun/faces/taglib/jsf_core/ConvertDateTimeTag.java
===================================================================
RCS file:
/cvs/javaserverfaces-sources/jsf-ri/src/com/sun/faces/taglib/jsf_core/ConvertDateTimeTag.java,v
retrieving revision 1.16
diff -u -r1.16 ConvertDateTimeTag.java
--- src/com/sun/faces/taglib/jsf_core/ConvertDateTimeTag.java 19 May
2005 13:26:59 -0000 1.16
+++ src/com/sun/faces/taglib/jsf_core/ConvertDateTimeTag.java 20 May
2005 18:04:03 -0000
@@ -195,11 +195,14 @@
                 locale =
                 new Locale(localeExpression.getExpressionString(), "");
             } else {
- Locale loc = (Locale)
- Util.evaluateValueExpression(localeExpression,
+ Object loc = Util.evaluateValueExpression(localeExpression,
                     elContext);
                 if (loc != null) {
- locale = loc;
+ if (loc instanceof String) {
+ locale = new Locale((String) loc, "");
+ } else {
+ locale = (Locale) loc;
+ }
                 } else {
                     locale = facesContext.getViewRoot().getLocale();
                 }
@@ -211,9 +214,15 @@
                 TimeZone.getTimeZone(
                     timeZoneExpression.getExpressionString());
             } else {
- timeZone = (TimeZone)
- Util.evaluateValueExpression(timeZoneExpression,
+ Object tz =
Util.evaluateValueExpression(timeZoneExpression,
                     elContext);
+ if (tz != null) {
+ if (tz instanceof String) {
+ timeZone = TimeZone.getTimeZone((String) tz);
+ } else {
+ timeZone = (TimeZone) tz;
+ }
+ }
             }
         }
     }
Index: systest/build-tests.xml
===================================================================
RCS file: /cvs/javaserverfaces-sources/jsf-ri/systest/build-tests.xml,v
retrieving revision 1.77
diff -u -r1.77 build-tests.xml
--- systest/build-tests.xml 16 May 2005 20:16:33 -0000 1.77
+++ systest/build-tests.xml 20 May 2005 18:04:03 -0000
@@ -86,6 +86,7 @@
                 test.converter02,
                 test.converter03,
                 test.converter04,
+ test.converter05,
                 test.validator,
                 test.validator01,
                 test.validator02,
@@ -548,7 +549,14 @@
          status="200" failonerror="${failonerror}"/>
   </target>
 
- <target name="test.validator"
+ <target name="test.converter05">
+ <tester host="${host}" port="${port}" protocol="${protocol}"
+ request="${context.path}/faces/converter05.jsp"
+ recordGolden="${local.golden.path}/standard/converter05.txt"
+ golden="${golden.path}/standard/converter05.txt"
failonerror="${failonerror}"/>
+ </target>
+
+ <target name="test.validator"
    description="Test Validator creation facility">
 
     <!-- Test validator creation -->


SECTION: New Files
----------------------------
SEE ATTACHMENTS