Sorry, it's just macro in my text editor which replace one uccurence with two
when I copy-paste
from log. One is correct and in log is just one.
On 5.11.2013 12:13, Martin Grigorov wrote:
On Tue, Nov 5, 2013 at 1:09 PM, Ladislav DANKO <[email protected]> wrote:
One more info - in tomact log there is:
Calculating context relative path from: context path '', filterPrefix '',
uri '/images/images/headerbackground.png'
One compatible mapper found for URL '/images/images/headerbackground.png?53'
-> 'Mapper: org.apache.wicket.request.mapper.BufferedResponseMapper;
Score: 2147483647'
I think the problem is that there are two times 'images' in the uri.
-------- Original Message --------
Subject: Re: mount images
Date: Tue, 05 Nov 2013 11:17:11 +0100
From: Ladislav DANKO <[email protected]>
To: [email protected]
With size isn't problem, it's around 20 images with total size max 1,5MB.
For me this is point that somethink is going wrong with mounting:
127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET
/images/images/headerbackground.png
HTTP/1.1" 302 -
127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET
/images/images/headerbackground.png?52
HTTP/1.1" 200 9077
Same image, some time but first path return HTTP response code 302 and
second 200 with wrong size (image
has 417 bytes).
On 5.11.2013 10:52, Martin Grigorov wrote:
On Tue, Nov 5, 2013 at 11:42 AM, Ladislav DANKO <[email protected]> wrote:
I don't need to mount images "dynamicaly" (at the moment of the user
click). For example
I have image logo.png and it's loaded just once when app start and
mounted
at some url path. This path
is still same, not needed to be loaded dynamicaly "when user click". For
this
purpose this 'mountResource("/images/logo.png", new
PackageResourceReference(Images.class, "logo.png"))'
works perfect. Now this image is in DB and I need to do same think. I
have
data (from DB), I have mount
point (from DB), but can't mount on url: AppStart.get().
getSharedResources().add(imagePath, imageData);
Looks that wicket "somethink do" because this events about images in log:
127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET /images/images/
headerbackground.png
HTTP/1.1" 302 -
127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET /images/images/
headerbackground.png?52
HTTP/1.1" 200 9077
127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET /images/images/cz-ico.gif
HTTP/1.1" 302 -
127.0.0.1 - - [04/Nov/2013:23:52:09 +0100] "GET
/images/images/icon-fb.png
HTTP/1.1" 302 -
but don't know what's wrong with 'WebApplication.get().
getSharedResources().add(imagePath, imageData)'
I also don't have idea what is wrong with this approach.
But I believe this approach is sub-optimal. Your read from DB at
application start time, then you put the images (byte[]) in instances of
IResource in a Map. I.e. you put some data (how much i cannot say. it
depends on how much images you have) in the heap memory for no good
reason,
IMO.
The article describes how to mount a single resource that dynamically
loads
the byte[] per request.
You should decide which one is better for you.
If you still prefer the shared resources approach then you can put a
breakpoint in SharedResource to see that your ComponentDynamicImage are
properly resolved and their #getImageData() is called and what gets wrong.
On 5.11.2013 10:24, Martin Grigorov wrote:
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]
---------------------------------------------------------------------
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]