>
> My suggestions and optimalization notes:
> 1. In some cases there is no necessary to create an anonymous class
> for each ImageItem (using AbstractImageItem). When @ImageBundle
> interface has not locale specified, then SimpleImageItem(String
> imageSrc, String imageStyle) can be used.
>
> 2. The call:
> String locale = RequestCycle.get().getSession().getLocale().toString();
> does not look very good for me :). Now you cannot call any method
> outside of a Wicket thread.
>
> Maybe for methods returning an ImageItem a Locale should be a method
> argument (but only if image is locale relative). So:
> // for not locale relative images
> ImageItem getSomeImage();
> // for locale related
> ImageItem getSomeImage(Locale locale);
>
> Then implementation will be more clear:
>
> @Override
> public ImageItem a(Locale locale) {
>  if ((locale != null) && "ta_IN".equals(locale.toString()) {
>    return new SimpleImageItem("images/clear.gif", " background-image
> :url(resources/org.imagebundler.wicket.examples.SampleImageBundle
> /SampleImageBundle_ta_IN.png) ; background-position:-50px -0px;
> width:25px; height:25px;  ") ;
>    }
>    // default
>    return new SimpleImageItem("images/clear.gif", "background-image
>
> :url(resources/org.imagebundler.wicket.examples.SampleImageBundle/SampleImageBundle.png)
> ; background-position:-48px -0px; width:24px; height:24px;  ") ;
>  }
>
>
> Another solution is to add a Locale argument to getStyle() method (but
> then maybe getSrc() should also have a Locale argument, so maybe the
> first option with "ImageItem getSomeImage(Locale locale);" is better).
>
>
The first option looks good.
I will add it (may be tomorrow).



> For methods returning Image component maybe it would be better to get
> Locale during the rendering, not when creating an Image. So maybe it
> should be a special AttributeModifier which calculates a proper style
> in eg. beforeRender() method?
> For now when user changes a locale in application and images are not
> recreated (eg. page will be not created again, but only refreshed in a
> non-bookmarkable request), they will be still using a style from an
> old locale (assigned in creation time).
>
>
I am not sure how to handle this.



----
Anantha Kumaran(http://ananthakumaran.github.com)

Reply via email to