On Tue, Nov 5, 2013 at 11:19 AM, Ladislav DANKO <[email protected]> wrote:

> Martin, thank, I have read it (have the book), but don't find any info why
> this:
>

I am not sure we talk about the same thing.
The blog article is not related to any book. And additionally it shows how
to load images from DB dynamically. It doesn't use shared resources though.
All you have to do is to mount a resource reference that listens at
"/images/${imageName}" and then put <img src="/images/logo.png"/> in your
.html.


> AppStart.get().getSharedResources().add(imagePath, imageData);
> from my code below not working.
>
> Guess that example is for dynamicly loaded images but my example is for
> static
> images in database (website logo etc) not for dynamic loaded images.
> Originaly I have done it in this way:
> mountResource("/images/logo.png", new PackageResourceReference(Images.class,
> "logo.png"));
> and it works smoothly. Now I moved images into database and looking for
> way how to serve them.
> In fact, I have image data but not know hot to mount this data into
> defined path:
> AppStart.get().getSharedResources().add(imagePath, imageData)
>
>
>
>
> On 5.11.2013 9:59, Martin Grigorov wrote:
>
>> Hi,
>>
>> Check http://wicketinaction.com/2011/07/wicket-1-5-mounting-resources/
>>
>>
>> On Tue, Nov 5, 2013 at 10:49 AM, Ladislav DANKO <[email protected]> wrote:
>>
>>  Hi folks!
>>>
>>> I'm using wicket 1.5.10, tomcat 7 and Java 6. In my code i do:
>>> public final class Images{
>>>    public static void mountGlobalStaticImages(){
>>>      //loading images from database works perfect
>>>      List<Object> imagesParams = GlobalTemplatesDAO.getGlobalImages();
>>>      for(Object record : imagesParams){
>>>        Map<String, Object> image = (Map<String, Object>) record;
>>>        //it's path like '/images/mylogo.png'
>>>        String imagePath = (String) image.get("file_mount_point");
>>>        //ComponentDynamicImage is extended DynamicImageResource, looks it
>>> works (it provides required byte[] data)
>>>        ComponentDynamicImage imageData = new
>>> ComponentDynamicImage((byte[])
>>> image.get("file_data"));
>>>        //problem is here: looks that it mount image isn't in app and in
>>> log
>>> is http status code '302'
>>>        //AppStart is extended WebApplication class
>>>        AppStart.get().getSharedResources().add(imagePath, imageData);
>>>      }
>>>    }
>>> }
>>>
>>> Problem is that images isn't here, in localhost_access_log.2013-11-
>>> 04.txt
>>> are lines:
>>> 127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET
>>> /images/images/icon-fb.png
>>> HTTP/1.1" 302 -
>>> 127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET
>>> /images/images/cz-ico.gif?53 HTTP/1.1" 200 9067
>>> 127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET
>>> /images/images/icon-fb.png?54 HTTP/1.1" 200 9068
>>> 127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET /images/images/en-ico.gif
>>> HTTP/1.1" 302 -
>>> 127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET
>>> /images/images/en-ico.gif?55 HTTP/1.1" 200 9067
>>>
>>> How to mount them properly? As far as i know problem is in
>>> 'AppStart.get().
>>> getSharedResources().add(imagePath, imageData)'
>>> but not know how to do it properly.
>>>
>>> --
>>> Ladislav DANKO
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: [email protected]
>>> For additional commands, e-mail: [email protected]
>>>
>>>
>>>
>>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [email protected]
> For additional commands, e-mail: [email protected]
>
>

Reply via email to