You are viewing a plain text version of this content. The canonical link for it is here.
Posted to taglibs-dev@jakarta.apache.org by gl...@apache.org on 2002/04/06 20:10:51 UTC

cvs commit: jakarta-taglibs/datetime/src/org/apache/taglibs/datetime AmPmsTag.java ErasTag.java FormatTag.java MonthsTag.java ParseTag.java TimeZoneTag.java TimeZonesTag.java WeekdaysTag.java

glenn       02/04/06 10:10:51

  Modified:    datetime/xml datetime.xml
               datetime/src/org/apache/taglibs/datetime AmPmsTag.java
                        ErasTag.java FormatTag.java MonthsTag.java
                        ParseTag.java TimeZoneTag.java TimeZonesTag.java
                        WeekdaysTag.java
  Log:
  Add localeRef attribute for all tags which had the locale flag
  attribute.
  
  Make sure invocation variables are intialized for containers
  which reuse tag object instances.
  
  Revision  Changes    Path
  1.7       +77 -0     jakarta-taglibs/datetime/xml/datetime.xml
  
  Index: datetime.xml
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/xml/datetime.xml,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- datetime.xml	4 Aug 2001 01:53:59 -0000	1.6
  +++ datetime.xml	6 Apr 2002 18:10:51 -0000	1.7
  @@ -322,6 +322,17 @@
           <availability>1.0</availability>
         </attribute>
   
  +      <attribute>
  +        <name>localeRef</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +        <description> 
  +          Specify the name of a page, session, application, or request scope
  +          attribute of type java.util.Locale to use for locale.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +
         <!-- The entire example section is for usage examples that you want to
              have added to the HTML doc under "Example" for each tag.  The
              example section is also included with a JSP 1.2 TLD.  The
  @@ -435,6 +446,17 @@
           <availability>1.0</availability>
         </attribute>
   
  +      <attribute>
  +        <name>localeRef</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +        <description> 
  +          Specify the name of a page, session, application, or request scope
  +          attribute of type java.util.Locale to use for locale.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +
         <!-- The entire example section is for usage examples that you want to
              have added to the HTML doc under "Example" for each tag.  The
              example section is also included with a JSP 1.2 TLD.  The
  @@ -640,6 +662,17 @@
         </attribute>
   
         <attribute>
  +        <name>localeRef</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +        <description> 
  +          Specify the name of a page, session, application, or request scope
  +          attribute of type java.util.Locale to use for locale.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +
  +      <attribute>
           <name>style</name>
           <required>false</required>
           <rtexprvalue>false</rtexprvalue>
  @@ -758,6 +791,17 @@
           <availability>1.0</availability>
         </attribute>
   
  +      <attribute>
  +        <name>localeRef</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +        <description> 
  +          Specify the name of a page, session, application, or request scope
  +          attribute of type java.util.Locale to use for locale.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +
         <example>
           <usage>
             <comment>
  @@ -866,6 +910,17 @@
           <availability>1.0</availability>
         </attribute>
   
  +      <attribute>
  +        <name>localeRef</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +        <description> 
  +          Specify the name of a page, session, application, or request scope
  +          attribute of type java.util.Locale to use for locale.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +
         <example>
           <usage>
             <comment>
  @@ -956,6 +1011,17 @@
           <availability>1.0</availability>
         </attribute>
   
  +      <attribute>
  +        <name>localeRef</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +        <description>
  +          Specify the name of a page, session, application, or request scope
  +          attribute of type java.util.Locale to use for locale.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +
         <example>
           <usage>
             <comment>
  @@ -1042,6 +1108,17 @@
           <description>
             Set to "<b>true</b>" to use the clients locale, if known,
             when listing the era names.
  +        </description>
  +        <availability>1.0</availability>
  +      </attribute>
  +
  +      <attribute>
  +        <name>localeRef</name>
  +        <required>false</required>
  +        <rtexprvalue>false</rtexprvalue>
  +        <description> 
  +          Specify the name of a page, session, application, or request scope
  +          attribute of type java.util.Locale to use for locale.
           </description>
           <availability>1.0</availability>
         </attribute>
  
  
  
  1.6       +46 -10    jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/AmPmsTag.java
  
  Index: AmPmsTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/AmPmsTag.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AmPmsTag.java	23 Feb 2002 21:04:04 -0000	1.5
  +++ AmPmsTag.java	6 Apr 2002 18:10:51 -0000	1.6
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/AmPmsTag.java,v 1.5 2002/02/23 21:04:04 glenn Exp $
  - * $Revision: 1.5 $
  - * $Date: 2002/02/23 21:04:04 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/AmPmsTag.java,v 1.6 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.6 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -81,6 +81,10 @@
    * If the optional attribute <b>locale</b> is true, the strings
    * are formatted for the clients locale if known.
    * <p>
  + * The optional attribute <b>localeRef</b> can be used to specify
  + * the name of a page, session, application, or request scope attribute
  + * of type java.util.Locale to use.
  + * <p>
    * JSP Tag Lib Descriptor
    * <p><pre>
    * &lt;name&gt;amPms&lt;/name&gt;
  @@ -90,12 +94,17 @@
    * &lt;info&gt;Loop through all the am/pm names.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;id&lt;/name&gt;
  - *     &lt;sessuired&gt;true&lt;/sessuired&gt;
  + *     &lt;required&gt;true&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;locale&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
  + *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  + *   &lt;/attribute&gt;
  + *   &lt;attribute&gt;                             
  + *     &lt;name&gt;localeRef&lt;/name&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  @@ -105,8 +114,12 @@
   
   public class AmPmsTag extends BodyTagSupport
   {
  +    // Static constants
  +    private static String PATTERN = "yyyy";
  +
       // amPms tag attributes
       private boolean locale_flag = false;
  +    private String localeRef = null;
   
       // amPms tag invocation variables
       private String [] amPms = null;
  @@ -119,14 +132,26 @@
        */
       public final int doStartTag() throws JspException
       {
  +        // Initialize variables
  +        count = 0;
  +
           SimpleDateFormat sdf;
  -	String pattern = "yyyy";
           // Get a SimpleDateFormat using locale if necessary
  -        if( !locale_flag )
  -            sdf = new SimpleDateFormat(pattern);
  -        else
  -            sdf = new SimpleDateFormat(pattern,
  +        if( localeRef != null ) {
  +            Locale locale = (Locale)pageContext.findAttribute(localeRef);
  +            if( locale == null ) {
  +                throw new JspException(
  +                    "datetime amPms tag could not find locale for localeRef \"" +
  +                    localeRef + "\".");
  +            }
  +
  +            sdf = new SimpleDateFormat(PATTERN,locale);
  +        } else if( locale_flag ) {
  +            sdf = new SimpleDateFormat(PATTERN,
                         (Locale)pageContext.getRequest().getLocale());
  +        } else {
  +            sdf = new SimpleDateFormat(PATTERN);
  +        }
   
   	DateFormatSymbols dfs = sdf.getDateFormatSymbols();
   	amPms = dfs.getAmPmStrings();
  @@ -191,6 +216,17 @@
       public final void setLocale(boolean flag)
       {
           locale_flag = flag;
  +    }
  +
  +    /**
  +     * Provides a key to search the page context for in order to get the
  +     * java.util.Locale to use.
  +     *
  +     * @param String name of locale attribute to use
  +     */
  +    public void setLocaleRef(String value)
  +    {
  +        localeRef = value;
       }
   
       /**
  
  
  
  1.5       +49 -10    jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ErasTag.java
  
  Index: ErasTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ErasTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- ErasTag.java	23 Feb 2002 21:04:04 -0000	1.4
  +++ ErasTag.java	6 Apr 2002 18:10:51 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ErasTag.java,v 1.4 2002/02/23 21:04:04 glenn Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/23 21:04:04 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ErasTag.java,v 1.5 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -80,6 +80,10 @@
    * <p>
    * If the optional attribute <b>locale</b> is true, the strings
    * are formatted for the clients locale if known.
  + * <p>                                                         
  + * The optional attribute <b>localeRef</b> can be used to specify
  + * the name of a page, session, application, or request scope attribute
  + * of type java.util.Locale to use.
    * <p>
    * JSP Tag Lib Descriptor
    * <p><pre>
  @@ -90,12 +94,17 @@
    * &lt;info&gt;Loop through all the era names.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;id&lt;/name&gt;
  - *     &lt;sessuired&gt;true&lt;/sessuired&gt;
  + *     &lt;required&gt;true&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;locale&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
  + *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  + *   &lt;/attribute&gt;
  + *   &lt;attribute&gt;                             
  + *     &lt;name&gt;localeRef&lt;/name&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  @@ -105,7 +114,14 @@
   
   public class ErasTag extends BodyTagSupport
   {
  +    // Static constants                     
  +    private static String PATTERN = "yyyy";
  +
  +    // eras tag attributes
       private boolean locale_flag = false;
  +    private String localeRef = null;
  +
  +    // eras tag invocation variables
       private String [] eras = null;
       private int count = 0;
   
  @@ -116,14 +132,26 @@
        */
       public final int doStartTag() throws JspException
       {
  +        // Initialize variables                      
  +        count = 0;
  +
           SimpleDateFormat sdf;
  -	String pattern = "yyyy";
           // Get a SimpleDateFormat using locale if necessary
  -        if( !locale_flag )
  -            sdf = new SimpleDateFormat(pattern);
  -        else
  -            sdf = new SimpleDateFormat(pattern,
  +        if( localeRef != null ) {                          
  +            Locale locale = (Locale)pageContext.findAttribute(localeRef);
  +            if( locale == null ) {                                       
  +                throw new JspException(                                  
  +                    "datetime eras tag could not find locale for localeRef \"" +
  +                    localeRef + "\".");                                          
  +            }                                                                    
  + 
  +            sdf = new SimpleDateFormat(PATTERN,locale);
  +        } else if( locale_flag ) {
  +            sdf = new SimpleDateFormat(PATTERN,
                         (Locale)pageContext.getRequest().getLocale());
  +        } else {
  +            sdf = new SimpleDateFormat(PATTERN);
  +        }
   
   	DateFormatSymbols dfs = sdf.getDateFormatSymbols();
   	eras = dfs.getEras();
  @@ -188,6 +216,17 @@
       public final void setLocale(boolean flag)
       {
           locale_flag = flag;
  +    }
  +
  +    /**
  +     * Provides a key to search the page context for in order to get the
  +     * java.util.Locale to use.
  +     *  
  +     * @param String name of locale attribute to use 
  +     */
  +    public void setLocaleRef(String value)
  +    {
  +        localeRef = value;
       }
   
       /**
  
  
  
  1.11      +38 -7     jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/FormatTag.java
  
  Index: FormatTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/FormatTag.java,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -r1.10 -r1.11
  --- FormatTag.java	23 Feb 2002 21:03:11 -0000	1.10
  +++ FormatTag.java	6 Apr 2002 18:10:51 -0000	1.11
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/FormatTag.java,v 1.10 2002/02/23 21:03:11 glenn Exp $
  - * $Revision: 1.10 $
  - * $Date: 2002/02/23 21:03:11 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/FormatTag.java,v 1.11 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.11 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -92,6 +92,10 @@
    * or the tag body is not a valid date.  If no default is set,
    * the string "Invalid Date" is output.
    * <p>
  + * The optional attribute <b>localeRef</b> can be used to specify
  + * the name of a page, session, application, or request scope attribute
  + * of type java.util.Locale to use.
  + * <p>
    * JSP Tag Lib Descriptor
    * <p><pre>
    * &lt;name&gt;format&lt;/name&gt;
  @@ -128,6 +132,11 @@
    *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
  + *   &lt;attribute&gt;
  + *     &lt;name&gt;localeRef&lt;/name&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
  + *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  + *   &lt;/attribute&gt;
    * </pre>
    *
    * @author Glenn Nielsen
  @@ -151,6 +160,8 @@
       private Date date = null;
       // Optional attribute, the default text if the tag body or date given is invalid/null
       private String default_text = "Invalid Date";
  +    // Optional attribute, the name of an attribute which contains the Locale
  +    private String localeRef = null;
   
       // format tag invocation variables
   
  @@ -218,11 +229,20 @@
               }
       
               // Get a SimpleDateFormat using locale if necessary
  -            if( !locale_flag ) {
  +            if( localeRef != null ) {
  +                Locale locale = (Locale)pageContext.findAttribute(localeRef);
  +                if( locale == null ) {                                       
  +                    throw new JspException(                                  
  +                        "datetime format tag could not find locale for localeRef \"" +
  +                        localeRef + "\".");                                          
  +                }                                                                    
  +                                           
  +                sdf = new SimpleDateFormat(pat,locale);
  +            } else if( locale_flag ) {                     
  +                sdf = new SimpleDateFormat(pat,        
  +                          (Locale)pageContext.getRequest().getLocale());
  +            } else {                                                    
                   sdf = new SimpleDateFormat(pat);
  -            } else {
  -                sdf = new SimpleDateFormat(pat,
  -                              (Locale)pageContext.getRequest().getLocale());
               }
   
               // See if there is a timeZone
  @@ -314,6 +334,17 @@
       public final void setDefault(String default_text)
       {
           this.default_text = default_text;
  +    }
  +
  +    /**
  +     * Provides a key to search the page context for in order to get the
  +     * java.util.Locale to use.
  +     *
  +     * @param String name of locale attribute to use
  +     */
  +    public void setLocaleRef(String value)
  +    {
  +        localeRef = value;
       }
   
   }
  
  
  
  1.5       +50 -10    jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/MonthsTag.java
  
  Index: MonthsTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/MonthsTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- MonthsTag.java	23 Feb 2002 21:04:04 -0000	1.4
  +++ MonthsTag.java	6 Apr 2002 18:10:51 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/MonthsTag.java,v 1.4 2002/02/23 21:04:04 glenn Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/23 21:04:04 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/MonthsTag.java,v 1.5 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -81,6 +81,10 @@
    * If the optional attribute <b>locale</b> is true, the month names
    * are formatted for the clients locale if known.
    * <p>
  + * The optional attribute <b>localeRef</b> can be used to specify
  + * the name of a page, session, application, or request scope attribute
  + * of type java.util.Locale to use.
  + * <p>
    * JSP Tag Lib Descriptor
    * <p><pre>
    * &lt;name&gt;months&lt;/name&gt;
  @@ -90,12 +94,17 @@
    * &lt;info&gt;Loop through all the months of the year.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;id&lt;/name&gt;
  - *     &lt;sessuired&gt;true&lt;/sessuired&gt;
  + *     &lt;required&gt;true&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;locale&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
  + *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  + *   &lt;/attribute&gt;
  + *   &lt;attribute&gt;                             
  + *     &lt;name&gt;localeRef&lt;/name&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  @@ -105,7 +114,14 @@
   
   public class MonthsTag extends BodyTagSupport
   {
  +    // Static constants                     
  +    private static String PATTERN = "yyyy";
  +
  +    // months tag attributes
       private boolean locale_flag = false;
  +    private String localeRef = null;
  +
  +    // months tag invocation variables
       private String [] short_months = null;
       private String [] long_months = null;
       private int month = 0;
  @@ -118,14 +134,27 @@
        */
       public final int doStartTag() throws JspException
       {
  +        // Initialize variables
  +        month = 0;
  +        month_num = 1;
  +
           SimpleDateFormat sdf;
  -	String pattern = "yyyy";
           // Get a SimpleDateFormat using locale if necessary
  -        if( !locale_flag )
  -            sdf = new SimpleDateFormat(pattern);
  -        else
  -            sdf = new SimpleDateFormat(pattern,
  +        if( localeRef != null ) {
  +            Locale locale = (Locale)pageContext.findAttribute(localeRef);
  +            if( locale == null ) {
  +                throw new JspException(
  +                    "datetime amPms tag could not find locale for localeRef \"" +
  +                    localeRef + "\".");
  +            }
  + 
  +            sdf = new SimpleDateFormat(PATTERN,locale);
  +        } else if( locale_flag ) {
  +            sdf = new SimpleDateFormat(PATTERN,
                         (Locale)pageContext.getRequest().getLocale());
  +        } else {
  +            sdf = new SimpleDateFormat(PATTERN);
  +        }
   
   	DateFormatSymbols dfs = sdf.getDateFormatSymbols();
   	short_months = dfs.getShortMonths();
  @@ -216,6 +245,17 @@
       public final String getMonth()
       {  
           return long_months[month];
  +    }
  +
  +    /**
  +     * Provides a key to search the page context for in order to get the
  +     * java.util.Locale to use.
  +     *
  +     * @param String name of locale attribute to use
  +     */
  +    public void setLocaleRef(String value)
  +    {
  +        localeRef = value;
       }
   
       /**
  
  
  
  1.7       +45 -10    jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ParseTag.java
  
  Index: ParseTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ParseTag.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- ParseTag.java	15 Jul 2001 16:29:17 -0000	1.6
  +++ ParseTag.java	6 Apr 2002 18:10:51 -0000	1.7
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ParseTag.java,v 1.6 2001/07/15 16:29:17 glenn Exp $
  - * $Revision: 1.6 $
  - * $Date: 2001/07/15 16:29:17 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/ParseTag.java,v 1.7 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.7 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -83,6 +83,10 @@
    * <p>
    * If the optional attribute <b>locale</b> is true, the Date
    * is parsed for the clients locale if known.
  + * <p>                                                        
  + * The optional attribute <b>localeRef</b> can be used to specify
  + * the name of a page, session, application, or request scope attribute
  + * of type java.util.Locale to use.
    * <p>
    * If the date string can not be parsed, 0 is returned.
    * <p>
  @@ -94,7 +98,7 @@
    * &lt;info&gt;Parses a date string and outputs the time in milliseconds since Jan 1, 1970 GMT.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;pattern&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
  @@ -104,12 +108,17 @@
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;timeZone&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;locale&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
  + *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  + *   &lt;/attribute&gt;
  + *   &lt;attribute&gt;                             
  + *     &lt;name&gt;localeRef&lt;/name&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  @@ -128,6 +137,10 @@
       // Optional attribute, timeZone script variable id to use when
       // formatting date
       private String timeZone_string;
  +    // Optional attribute, the name of an attribute which contains the Locale            
  +    private String localeRef = null;                                         
  +                                                                             
  +    // format tag invocation variables
       private TimeZone timeZone = null;
       // Date after parsing tag body
       private Date date = null;
  @@ -171,11 +184,21 @@
           }
   
   	// Get a SimpleDateFormat using locale if necessary
  -	if( !locale_flag )
  -	    sdf = new SimpleDateFormat(pat);
  -	else
  -	    sdf = new SimpleDateFormat(pat,
  +        if( localeRef != null ) {                          
  +            Locale locale = (Locale)pageContext.findAttribute(localeRef);
  +            if( locale == null ) {                                       
  +                throw new JspException(                                  
  +                    "datetime parse tag could not find locale for localeRef \"" +
  +                    localeRef + "\".");                                           
  +            }                                                                     
  +                                       
  +            sdf = new SimpleDateFormat(pat,locale);
  +        } else if( locale_flag ) {                 
  +            sdf = new SimpleDateFormat(pat,        
                         (Locale)pageContext.getRequest().getLocale());
  +        } else {                                                    
  +            sdf = new SimpleDateFormat(pat);                        
  +        }
   
   	// See if there is a timeZone
           if( timeZone_string != null ) {
  @@ -261,4 +284,16 @@
       {
           patternid = str;
       }
  +
  +    /**
  +     * Provides a key to search the page context for in order to get the
  +     * java.util.Locale to use.
  +     *
  +     * @param String name of locale attribute to use
  +     */
  +    public void setLocaleRef(String value)
  +    {
  +        localeRef = value;
  +    }
  +
   }
  
  
  
  1.9       +4 -4      jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZoneTag.java
  
  Index: TimeZoneTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZoneTag.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- TimeZoneTag.java	23 Feb 2002 21:04:04 -0000	1.8
  +++ TimeZoneTag.java	6 Apr 2002 18:10:51 -0000	1.9
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZoneTag.java,v 1.8 2002/02/23 21:04:04 glenn Exp $
  - * $Revision: 1.8 $
  - * $Date: 2002/02/23 21:04:04 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZoneTag.java,v 1.9 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.9 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -83,7 +83,7 @@
    * &lt;info&gt;Creates a SESSION script variable for clients time zone.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;id&lt;/name&gt;
  - *     &lt;sessuired&gt;true&lt;/sessuired&gt;
  + *     &lt;required&gt;true&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  
  
  
  1.5       +43 -8     jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZonesTag.java
  
  Index: TimeZonesTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZonesTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- TimeZonesTag.java	8 Jul 2001 02:31:57 -0000	1.4
  +++ TimeZonesTag.java	6 Apr 2002 18:10:51 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZonesTag.java,v 1.4 2001/07/08 02:31:57 glenn Exp $
  - * $Revision: 1.4 $
  - * $Date: 2001/07/08 02:31:57 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/TimeZonesTag.java,v 1.5 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -79,6 +79,10 @@
    * <p>
    * If the optional attribute <b>locale</b> is <b>true</b>, the Displaynames
    * are formatted for the clients locale if known.
  + * <p>                                                         
  + * The optional attribute <b>localeRef</b> can be used to specify
  + * the name of a page, session, application, or request scope attribute
  + * of type java.util.Locale to use.
    * <p>
    * The optional attribute <b>style</b> can be set to <i>SHORT</i> or
    * <i>LONG</i>.
  @@ -92,17 +96,22 @@
    * &lt;info&gt;Loop through all the timeZone display names.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;id&lt;/name&gt;
  - *     &lt;sessuired&gt;true&lt;/sessuired&gt;
  + *     &lt;required&gt;true&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;locale&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
  + *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  + *   &lt;/attribute&gt;
  + *   &lt;attribute&gt;                             
  + *     &lt;name&gt;localeRef&lt;/name&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;style&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  @@ -112,8 +121,12 @@
   
   public class TimeZonesTag extends BodyTagSupport
   {
  +    // timeZones tag attributes
       private boolean locale_flag = false;
  +    private String localeRef = null;
       private String style_string = "SHORT";
  +
  +    // timeZones tag invocation variables
       private int style = TimeZone.SHORT;
       private String [] timeZones = null;
       private TimeZone timeZone = null;
  @@ -126,6 +139,9 @@
        */
       public final int doStartTag() throws JspException
       {
  +        // Initialize variables                      
  +        zone_num = 0;
  +
           if( style_string == null || style_string.equals("SHORT") )  
               style = TimeZone.SHORT;
           else if( style_string.equals("LONG") )
  @@ -195,6 +211,17 @@
       }
   
       /**
  +     * Provides a key to search the page context for in order to get the
  +     * java.util.Locale to use.
  +     *
  +     * @param String name of locale attribute to use
  +     */
  +    public void setLocaleRef(String value)
  +    {
  +        localeRef = value;
  +    }
  +
  +    /**
        * Set they style of Displaynames to either <b>SHORT</b> or <b>LONG</b>.
        *
        * @param String style, either <b>SHORT</b> or <b>LONG</b>
  @@ -211,7 +238,7 @@
        *
        * @return String - display name
        */
  -    public final String getDisplayName()
  +    public final String getDisplayName() throws JspException
       {
   	String dn = null;
   	Date now = new Date();
  @@ -220,7 +247,15 @@
   	if( timeZone.useDaylightTime() )
   	    daylight = timeZone.inDaylightTime(now);
   
  -	if( locale_flag) {
  +        if( localeRef != null ) {                          
  +            Locale locale = (Locale)pageContext.findAttribute(localeRef);
  +            if( locale == null ) {
  +                throw new JspException(
  +                    "datetime amPms tag could not find locale for localeRef \"" +
  +                    localeRef + "\".");
  +            }
  +            dn = timeZone.getDisplayName(daylight,style,locale);
  +	} else if( locale_flag) {
   	    dn = timeZone.getDisplayName(daylight,style,
                        (Locale)pageContext.getRequest().getLocale());
   	} else {
  
  
  
  1.5       +49 -11    jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/WeekdaysTag.java
  
  Index: WeekdaysTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/WeekdaysTag.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- WeekdaysTag.java	23 Feb 2002 21:04:04 -0000	1.4
  +++ WeekdaysTag.java	6 Apr 2002 18:10:51 -0000	1.5
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/WeekdaysTag.java,v 1.4 2002/02/23 21:04:04 glenn Exp $
  - * $Revision: 1.4 $
  - * $Date: 2002/02/23 21:04:04 $
  + * $Header: /home/cvs/jakarta-taglibs/datetime/src/org/apache/taglibs/datetime/WeekdaysTag.java,v 1.5 2002/04/06 18:10:51 glenn Exp $
  + * $Revision: 1.5 $
  + * $Date: 2002/04/06 18:10:51 $
    *
    * ====================================================================
    *
  @@ -81,6 +81,10 @@
    * If the optional attribute <b>locale</b> is true, the weekday names
    * are formatted for the clients locale if known.
    * <p>
  + * The optional attribute <b>localeRef</b> can be used to specify
  + * the name of a page, session, application, or request scope attribute
  + * of type java.util.Locale to use.
  + * <p>
    * JSP Tag Lib Descriptor
    * <p><pre>
    * &lt;name&gt;weekdays&lt;/name&gt;
  @@ -90,12 +94,17 @@
    * &lt;info&gt;Loop through all the days of the week.&lt;/info&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;id&lt;/name&gt;
  - *     &lt;sessuired&gt;true&lt;/sessuired&gt;
  + *     &lt;required&gt;true&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    *   &lt;attribute&gt;
    *     &lt;name&gt;locale&lt;/name&gt;
  - *     &lt;sessuired&gt;false&lt;/sessuired&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
  + *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
  + *   &lt;/attribute&gt;
  + *   &lt;attribute&gt;
  + *     &lt;name&gt;localeRef&lt;/name&gt;
  + *     &lt;required&gt;false&lt;/required&gt;
    *     &lt;rtexprvalue&gt;false&lt;/rtexprvalue&gt;
    *   &lt;/attribute&gt;
    * </pre>
  @@ -105,7 +114,13 @@
   
   public class WeekdaysTag extends BodyTagSupport
   {
  +    // Static constants                     
  +    private static String PATTERN = "yyyy";
  +                                           
  +    // weekdays tag attributes
       private boolean locale_flag = false;
  +    private String localeRef = null;
  +
       private String [] short_weekdays = null;
       private String [] long_weekdays = null;
       private int day = 0;
  @@ -118,14 +133,26 @@
        */
       public final int doStartTag() throws JspException
       {
  +        // Initialize variables                      
  +        day = 0;
  +        day_num = 1;
  +
           SimpleDateFormat sdf;
  -	String pattern = "yyyy";
  -        // Get a SimpleDateFormat using locale if necessary
  -        if( !locale_flag )
  -            sdf = new SimpleDateFormat(pattern);
  -        else
  -            sdf = new SimpleDateFormat(pattern,
  +        if( localeRef != null ) {                          
  +            Locale locale = (Locale)pageContext.findAttribute(localeRef);
  +            if( locale == null ) {
  +                throw new JspException(
  +                    "datetime amPms tag could not find locale for localeRef \"" +
  +                    localeRef + "\".");
  +            }
  +            
  +            sdf = new SimpleDateFormat(PATTERN,locale);
  +        } else if( locale_flag ) {
  +            sdf = new SimpleDateFormat(PATTERN,
                         (Locale)pageContext.getRequest().getLocale());
  +        } else {
  +            sdf = new SimpleDateFormat(PATTERN);
  +        }
   
   	DateFormatSymbols dfs = sdf.getDateFormatSymbols();
   	short_weekdays = dfs.getShortWeekdays();
  @@ -192,6 +219,17 @@
       public final void setLocale(boolean flag)
       {
           locale_flag = flag;
  +    }
  +
  +    /**
  +     * Provides a key to search the page context for in order to get the
  +     * java.util.Locale to use.
  +     *
  +     * @param String name of locale attribute to use
  +     */
  +    public void setLocaleRef(String value)
  +    {
  +        localeRef = value;
       }
   
       /**
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>