jakarta-taglibs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject cvs commit: jakarta-taglibs/i18n/src/org/apache/taglibs/i18n FormatTagSupport.java LocaleTag.java
Date Tue, 05 Jun 2001 08:35:48 GMT
jstrachan    01/06/05 01:35:47

  Modified:    i18n/src/org/apache/taglibs/i18n FormatTagSupport.java
                        LocaleTag.java
  Log:
  Patched the <formatXXX> tags to use the response.getLocale() to allow the <i18n:bundle>
to set the Locale used on a page. If the respone.getLocale() returns null then the request.getLocale()
is used instead
  
  Revision  Changes    Path
  1.3       +7 -7      jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java
  
  Index: FormatTagSupport.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- FormatTagSupport.java	2001/04/29 05:27:48	1.2
  +++ FormatTagSupport.java	2001/06/05 08:35:40	1.3
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java,v
1.2 2001/04/29 05:27:48 jstrachan Exp $
  - * $Revision: 1.2 $
  - * $Date: 2001/04/29 05:27:48 $
  + * $Header: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/FormatTagSupport.java,v
1.3 2001/06/05 08:35:40 jstrachan Exp $
  + * $Revision: 1.3 $
  + * $Date: 2001/06/05 08:35:40 $
    *
    * ====================================================================
    * 
  @@ -78,7 +78,7 @@
     * implementation inheritence.
     *
     * @author James Strachan
  -  * @version $Revision: 1.2 $
  +  * @version $Revision: 1.3 $
     */
   public abstract class FormatTagSupport extends TagSupport {
       
  @@ -148,7 +148,7 @@
         */
       public Locale getLocale() {
           if ( locale == null ) {
  -            locale = findLocale();
  +            return findLocale();
           }
           return locale;
       }
  @@ -189,8 +189,8 @@
           if ( localeTag != null ) {
               return localeTag.getLocale();
           }        
  -        // otherwise lets use the ServletRequest
  -        return LocaleTag.getLocaleFromRequest( pageContext.getRequest() );
  +        // otherwise lets determine the Locale from the response, request or default
  +        return LocaleTag.getLocale( pageContext );
       }
       
       
  
  
  
  1.2       +19 -16    jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java
  
  Index: LocaleTag.java
  ===================================================================
  RCS file: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- LocaleTag.java	2001/04/28 15:05:44	1.1
  +++ LocaleTag.java	2001/06/05 08:35:42	1.2
  @@ -1,7 +1,7 @@
   /*
  - * $Header: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java,v
1.1 2001/04/28 15:05:44 jstrachan Exp $
  - * $Revision: 1.1 $
  - * $Date: 2001/04/28 15:05:44 $
  + * $Header: /home/cvs/jakarta-taglibs/i18n/src/org/apache/taglibs/i18n/LocaleTag.java,v
1.2 2001/06/05 08:35:42 jstrachan Exp $
  + * $Revision: 1.2 $
  + * $Date: 2001/06/05 08:35:42 $
    *
    * ====================================================================
    * 
  @@ -79,7 +79,7 @@
     * {@link Locale} is used.
     *
     * @author James Strachan
  -  * @version $Revision: 1.1 $
  +  * @version $Revision: 1.2 $
     */
   public class LocaleTag extends TagSupport {
       
  @@ -158,25 +158,28 @@
                   : new Locale( language, country );
           }
           // otherwise lets use the ServletRequest
  -        return getLocaleFromRequest( pageContext.getRequest() );
  +        return getLocale( pageContext );
       }
       
       /** Extracts the {@link Locale} from the given {@link ServletRequest}
         * or returns the default JVM's {@link Locale} if it could not be found
         */
  -    protected static Locale getLocaleFromRequest(ServletRequest request) {
  -        Locale answer = request.getLocale();
  +    protected static Locale getLocale( PageContext pageContext ) {
  +        Locale answer = pageContext.getResponse().getLocale();
           if ( answer == null ) {
  -            for ( Enumeration enum = request.getLocales(); enum.hasMoreElements(); ) {
  -                answer = (Locale) enum.nextElement();
  -                if ( answer != null ) {
  -                    break;
  -                }
  -            }
  +            ServletRequest request = pageContext.getRequest();
  +            answer = request.getLocale();
               if ( answer == null ) {
  -                // XXXX: should we use the JVM default?
  -                // XXXX: or throw some exception?
  -                answer = Locale.getDefault();
  +                for ( Enumeration enum = request.getLocales(); enum.hasMoreElements();
) {
  +                    answer = (Locale) enum.nextElement();
  +                    if ( answer != null ) {
  +                        break;
  +                    }
  +                }
  +                if ( answer == null ) {
  +                    // XXXX: may wish to log warning?
  +                    answer = Locale.getDefault();
  +                }
               }
           }
           return answer;
  
  
  

Mime
View raw message