Happy new year everybody :),

Setup: Wicket 1.3.5

Situation:
I have a DynamicImageResource subclass that is mounted as a shared
resource. Based on a request parameter it returns a dynamic image.

Besides that there is a subclass of Image that points the Image
to a ResourceReference with a parameter in a ValueMap that indicates
the image that need to be loaded by the shared image resource.

What works fine:
Accessing the shared resource under /images?name=blabla.jpg works fine.

Problem:
When I point an Image to a resource using a ResourceReference with 
a ValueMap having "name" it creates a URL for the image like 
        ../images/name/20090102130806-402427017.jpg/

My DynamicImageResource however seems to expect "normal" URI parameters.
It is not able to find the "name" parameter when using the URI as created by 
Image.

Code summary:

public class ImageResource extends DynamicImageResource {

        ...
        public static final Object PARAM_IMAGE_NAME = "name";

        private ThreadLocal<String> imageName = new ThreadLocal<String>();
        private ExtranetApplication application;

        @Override
        public IResourceStream getResourceStream() {

                String imageName = ((String[]) 
getParameters().get(PARAM_IMAGE_NAME))[0];
                this.imageName.set( imageName );

                return super.getResourceStream();
        }

        @Override
        protected byte[] getImageData() {

                // get byte[]
                byte[] res = ....
                return res;

        }

        ...
}

Application.init() :

        getSharedResources().add(
                ImageResource.IMAGE_RESOURCE_NAME, new ImageResource() );

        mountSharedResource("images",
                new 
ResourceReference(ImageResource.IMAGE_RESOURCE_NAME).getSharedResourceKey() );


And the usage to fill an Image object:

public class ImageDisplayer extends Image {
        public ImageDisplayer(String id, String image) {
                super(id);

                ValueMap parameters = new ValueMap();
                parameters.put( ImageResource.PARAM_IMAGE_NAME, image);

                setImageResourceReference(
                        new 
ResourceReference(ImageResource.IMAGE_RESOURCE_NAME), parameters );

        }
}

usage: new ImageDisplayer("id", "imagename");

The <image> src-attribute is rendered by the ImageDisplayer as:
        ../images/name/20090102130806-402427017.jpg/

Causing the ImageResource to be unable to find the name parameter.

I don't have an explicit URL Encoding Strategy configured.
Is this a bug or a feature, is there a work-around?

Thanks a lot,

Janno de Wit

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to