Hello friends,

I fix <html:image> tag -
 1. src of image can be retrieved from properties - you can specify
    srckey attribute as key in properties bundle and path as
    additional path to insert before string retrieved from properties.
 2. alt of image can be retrieved from properties - altkey attribute.
 3. New bundle attribute - to specify properties bundle.
 4. New locale attribute - to specify locale key to use as base locale
    when retrieve values from properties bundle.
 5. Change call from deprecated BeanUtils.filter() to
    ResponseUtils.filter()
 
===================================================================
RCS file: 
/home/cvspublic/jakarta-struts/src/share/org/apache/struts/taglib/html/ImgTag.java,v
retrieving revision 1.3
diff -w -r1.3 ImgTag.java
66a67
> import java.util.Locale;
77c78
< import org.apache.struts.util.BeanUtils;
---
> import org.apache.struts.util.ResponseUtils;
396a398,470
>     /**
>      * The bundle to retrive image name.
>      */
>     protected String bundle = Action.MESSAGES_KEY;
> 
>     public String getBundle() {
>         return (this.bundle);
>     }
> 
>     public void setBundle(String bundle) {
>         if( bundle==null )
>          bundle = Action.MESSAGES_KEY;
>         this.bundle = bundle;
>     }
> 
>     /**
>      * The key to retrieve image name.
>      */
>     protected String srcKey = null;
> 
>     public String getSrckey() {
>         return (this.srcKey);
>     }
> 
>     public void setSrckey(String srcKey) {
>         this.srcKey = srcKey;
>     }
> 
>     /**
>      * The key to retrieve alt text.
>      */
>     protected String altKey = null;
> 
>     public String getAltkey() {
>         return (this.altKey);
>     }
> 
>     public void setAltkey(String altKey) {
>         this.altKey = altKey;
>     }
> 
>     /**
>      * Path to use as base for image src.
>      */
>     protected String path = null;
> 
>     public String getPath() {
>         return (this.path);
>     }
> 
>     public void setPath(String path) {
>         this.path = path;
>     }
> 
>     /**
>      * The default Locale for our server.
>      */
>     protected static final Locale defaultLocale = Locale.getDefault();
> 
>     /**
>      * The session scope key under which our Locale is stored.
>      */
>     protected String localeKey = Action.LOCALE_KEY;
> 
>     public String getLocale() {
>         return (this.localeKey);
>     }
> 
>     public void setLocale(String locale) {
>         if( locale==null )
>          locale = Action.LOCALE_KEY;
>         this.localeKey = locale;
>     }
420a495,506
>         MessageResources resources = (MessageResources)
>           pageContext.getAttribute( bundle, PageContext.APPLICATION_SCOPE);
>         Locale locale = null;
>         try {
>            locale = (Locale)
>                pageContext.getAttribute( localeKey, PageContext.SESSION_SCOPE);
>         } catch (IllegalStateException e) {     // Invalidated session
>             locale = null;
>         }
>         if (locale == null)
>             locale = defaultLocale;
> 
427a514
> 
432c519,530
<       else {
---
>         else if (this.srcKey != null) {
>             String fileName = resources.getMessage( locale, srcKey );
>             StringBuffer keySrc = new StringBuffer( request.getContextPath() );
>             keySrc.append( "/" );
>             if( path!=null ) {
>              keySrc.append( path );
>              keySrc.append( "/" );
>             }
>             if( fileName!=null )
>              keySrc.append( fileName );
>             srcurl = keySrc.toString();
>         } else {
442c540
<             results.append(response.encodeURL(BeanUtils.filter(srcurl)));
---
>             results.append(response.encodeURL(ResponseUtils.filter(srcurl)));
447c545
<             results.append(response.encodeURL(BeanUtils.filter(lowsrcurl)));
---
>             results.append(response.encodeURL(ResponseUtils.filter(lowsrcurl)));
449a548,550
>         if( (alt==null) && (altKey!=null) ) {
>             alt = resources.getMessage( locale, altKey );
>         }
544a646,649
>         bundle = Action.MESSAGES_KEY;
>         srcKey = null;
>         altKey = null;
>         localeKey = null;
  

-- 
Best regards,
 Oleg                          mailto:[EMAIL PROTECTED]


Reply via email to