you would mount one image resource and read the image id from the url, there
is an article on this somewhere in the wiki and if you want you can look at
the pastebin code (papernapkin.com), its hosted on berlious.de i believe.

-igor


On 5/8/07, Rüdiger Schulz <[EMAIL PROTECTED]> wrote:

Hello,

thanks a lot for both suggestions :)

A mounted DynamicImageResource looks interesting, but as I see it,
there would be a mount for every single image? Or is it somehow
possible to mount a shared resource in a way that a parameter can be
passed? I have a lot of images, and user can create new ones...

So going the way Jeremy provided, I would do the following:

1. Extend an AbstractRequestUrlCodingStrategy, where I will define how
the path will be interpreted (quite similar to how I do it in my
servlet a.t.m.).

2. decode() would return a ResourceStreamRequestTarget, which uses a
IResourceStream, which will deliver the image data.

3. Implement a WebComponent, where in onComponentTag() the src
attribute will be generated to match my strategy from above.

Are there any objections on this, or should it work? This thread
promises an example, but I couldn't find one in the wiki:
http://www.nabble.com/Joost-uses-Wicket-tf3390296.html#a9791575
(Jean-Baptiste seems to work on some kind of picture gallery as well :)

I'm actually not sure what to do in
RequestUrlCodingStrategy.encode(IRequestTarget), and where it would be
called in this case.


.Rüdiger

2007/5/8, Igor Vaynberg <[EMAIL PROTECTED]>:
> you can also implement your own DynamicImageResource, and add it to
shared
> resources
>
> webapp.getsharedresources().add("images", new MyDynamicImageResource());
>
> urls for shared resources are stable, and you can also mount them.
>
> -igor
>
>
>
>
> On 5/7/07, Jeremy Thomerson <[EMAIL PROTECTED]> wrote:
> > I've done a lot of custom URL encoding / decoding to keep very clean,
> search-engine friendly URLs in our application.  The place I would start
> would be to mount a custom IRequestTargetUrlCodingStrategy in your
WebApp
> class.
> >
> > Here's some code that might help as a starting point:
> >
> >         private final Pattern mRequestPattern =
> Pattern.compile(getMountPath() + "/([0-9]*)/.*");
> >
> >         public boolean matches(RequestParameters rp) {
> >             return mRequestPattern.matcher(rp.getPath()).matches();
> >         }
> >
> >         public IRequestTarget decode(RequestParameters rp) {
> >             Matcher matcher = mRequestPattern.matcher(rp.getPath ());
> >             matcher.find();
> >             String strID = matcher.group(1);
> >             int id = -1;
> >             try {
> >                 id = Integer.parseInt(strID);
> >             } catch (NumberFormatException nfe) {
> >                 throw new IllegalArgumentException(strID + " is not a
> valid ID");
> >             }
> >
> >             IFooService svc = getBean(IFooService.class);
> >             return new PageRequestTarget(new FooPage( svc.findByID
(id)));
> >         }
> >
> >
> > Jeremy Thomerson
> >
> >
> >
> > On 5/7/07, Rüdiger Schulz <[EMAIL PROTECTED] > wrote:
> > > Hello everybody,
> > >
> > > in my application, I'm currently serving images with a special
> > > servlet. It accepts request paths like /app/images/42.gif. The
images
> > > themself are stored in a database. I like this approach, because the
> > > image URLs are static, and by that they can be cached by proxies and
> > > stored as bookmarks in browsers.
> > >
> > > I integrate this servlet with a custom WebComponent in my Wicket
> > > pages, where I compile the correct path.
> > >
> > > This all works very well, but now I'd like to convert this servlet
> > > into a Wicket component. It needs the same behavior (static urls),
but
> > > I'd like to restrict access according to data in the current Wicket
> > > session.
> > >
> > > I think I know how to do this with a DynamicWebResource and all, but
I
> > > have no idea how to do the URL binding. I don't know where to start
at
> > > all. For pages there is the IndexedParamUrlCodingStrategy, but that
> > > won't do for images I guess...
> > >
> > > So, any help would be very welcome. Oh, and I'm still using Wicket
> > > 1.2.6; an update to 1.3 is planned, but cannot be done right now. If
a
> > > solution would be much more easier in 1.3 than in 1.2, however, we
> > > might do it earlier or at least wait with the conversion of the
> > > Servlet until then.
> > >
> > >
> > > --
> > > greetings from Berlin,
> > >
> > > Rüdiger Schulz
> > >
> > > www.2rue.de
> > >
> > >
>
-------------------------------------------------------------------------
> > > This SF.net email is sponsored by DB2 Express
> > > Download DB2 Express C - the FREE version of DB2 express and take
> > > control of your XML. No limits. Just data. Click to get it now.
> > > http://sourceforge.net/powerbar/db2/
> > > _______________________________________________
> > > Wicket-user mailing list
> > > Wicket-user@lists.sourceforge.net
> > >
> https://lists.sourceforge.net/lists/listinfo/wicket-user
> > >
> > >
> >
> >
> >
>
-------------------------------------------------------------------------
> > This SF.net email is sponsored by DB2 Express
> > Download DB2 Express C - the FREE version of DB2 express and take
> > control of your XML. No limits. Just data. Click to get it now.
> > http://sourceforge.net/powerbar/db2/
> > _______________________________________________
> > Wicket-user mailing list
> > Wicket-user@lists.sourceforge.net
> > https://lists.sourceforge.net/lists/listinfo/wicket-user
> >
> >
>
>
>
-------------------------------------------------------------------------
> This SF.net email is sponsored by DB2 Express
> Download DB2 Express C - the FREE version of DB2 express and take
> control of your XML. No limits. Just data. Click to get it now.
> http://sourceforge.net/powerbar/db2/
> _______________________________________________
> Wicket-user mailing list
> Wicket-user@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/wicket-user
>
>


--
greetings from Berlin,

Rüdiger Schulz

www.2rue.de

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

-------------------------------------------------------------------------
This SF.net email is sponsored by DB2 Express
Download DB2 Express C - the FREE version of DB2 express and take
control of your XML. No limits. Just data. Click to get it now.
http://sourceforge.net/powerbar/db2/
_______________________________________________
Wicket-user mailing list
Wicket-user@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/wicket-user

Reply via email to