You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by Anantha Kumaran <an...@gmail.com> on 2010/04/18 17:20:58 UTC

Re: Image Bundler For Apache Wicket

http://ananthakumaran.github.com/imagebundler-wicket/

version 1.2 released

* localization support added
* style and src of the image is available through the ImageItem interface

your comments are welcome

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

Re: Image Bundler For Apache Wicket

Posted by Daniel Stoch <da...@gmail.com>.
And one more thing:
ImageItem interface (and posiibly ImageItemProvider too) should extend  
Serializable (or maybe better IClusterable?).

--
Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Image Bundler For Apache Wicket

Posted by Daniel Stoch <da...@gmail.com>.
On 2010-04-20, at 19:28, Anantha Kumaran wrote:
>>
>>
>> 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);
>>
>>
> The first option looks good.
> I will add it (may be tomorrow).
>

I thought about it once again and now I think it is not a good  
solution (a method: "ImageItem getSomeImage(Locale locale);") for the  
same reasons as I wrote about Image components. When I get an  
ImageItem instance for specified Locale and pass this instance  
somewhere to components, then any locale changes in session will not  
affect this ImageItem. So it is going to be more complicated :(.

So maybe the second solution (from my previous mail) is better: add a  
Locale argument to getStyle() method (and maybe also to getSrc()).

Or it should be one more interface, eg: ImageItemProvider :) :
interface ImageItemProvider {

   ImageItem getImageItem(Locale locale);

}
and then image bundle should have a methods which return  
ImageItemProvider instead of ImageItem (this interface will not  
change) directly:
ImageItemProvider a();


>
>
>> 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.
>

I will try to prepare a proposal solution for this ;).

--
Daniel

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Image Bundler For Apache Wicket

Posted by Anantha Kumaran <an...@gmail.com>.
>
> 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)

Re: Image Bundler For Apache Wicket

Posted by Daniel Stoch <da...@gmail.com>.
Hi,

Thanks for this change!

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).

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).

--
Daniel


On Sun, Apr 18, 2010 at 5:20 PM, Anantha Kumaran
<an...@gmail.com> wrote:
> http://ananthakumaran.github.com/imagebundler-wicket/
>
> version 1.2 released
>
> * localization support added
> * style and src of the image is available through the ImageItem interface
>
> your comments are welcome
>
> ----
> Anantha Kumaran(http://ananthakumaran.github.com)
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org