Bookmarkable images from db

View: New views
9 Messages — Rating Filter:   Alert me  

Bookmarkable images from db

by Peter Dotchev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

My app allows users to upload images and I store them in JCR
<http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
get InputStream for each one of them.
I want to display images in specific pages and I want image URLs to be
stable/bookmarkable. Also I don't want these pages to use the session in
any way.
I checked again chapter 9 about images from Wicket In Action but such
use case is not addressed there.

I found that SharedResources allows for stable URLs, but I cannot
register each individual image.

What approach would you suggest?

Best regards,
Peter



Re: Bookmarkable images from db

by igor.vaynberg :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

i would write a servlet.

-igor

On Sun, Nov 1, 2009 at 1:41 PM, Peter Dotchev <dotchev@...> wrote:

> Hi,
>
> My app allows users to upload images and I store them in JCR
> <http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can get
> InputStream for each one of them.
> I want to display images in specific pages and I want image URLs to be
> stable/bookmarkable. Also I don't want these pages to use the session in any
> way.
> I checked again chapter 9 about images from Wicket In Action but such use
> case is not addressed there.
>
> I found that SharedResources allows for stable URLs, but I cannot register
> each individual image.
>
> What approach would you suggest?
>
> Best regards,
> Peter
>
>
>

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


Re: Bookmarkable images from db

by Alexandru Objelean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Besides the servlet, there is also a wicket way of do it:

- Use shared resource, which is stateless and bookmarkable

If you need more informations about this approach, search on forum or just ask... and I'll provide you with some examples of how I do it..

Alex Objelean

Peter Dotchev wrote:
Hi,

My app allows users to upload images and I store them in JCR
<http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
get InputStream for each one of them.
I want to display images in specific pages and I want image URLs to be
stable/bookmarkable. Also I don't want these pages to use the session in
any way.
I checked again chapter 9 about images from Wicket In Action but such
use case is not addressed there.

I found that SharedResources allows for stable URLs, but I cannot
register each individual image.

What approach would you suggest?

Best regards,
Peter


Re: Bookmarkable images from db

by Vytautas Racelis-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 you may find this class useful for your requirements:

http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-repository/src/main/java/org/xaloon/wicket/component/resource/ImageLink.java

This class takes image from JCR and shows as image.

Peter Dotchev wrote:

> Hi,
>
> My app allows users to upload images and I store them in JCR
> <http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
> get InputStream for each one of them.
> I want to display images in specific pages and I want image URLs to be
> stable/bookmarkable. Also I don't want these pages to use the session
> in any way.
> I checked again chapter 9 about images from Wicket In Action but such
> use case is not addressed there.
>
> I found that SharedResources allows for stable URLs, but I cannot
> register each individual image.
>
> What approach would you suggest?
>
> Best regards,
> Peter
>
>
>


--
Regards,
Vytautas Racelis
-----------------------------------
phone:+370-600-34389
e-mail: turisto@...
www.xaloon.org
www.leenle.com


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


Re: Bookmarkable images from db

by Peter Dotchev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi Alex,

I check SharedResources, but as I understand it I would have to add there a Resource object for each image.

After checking again the javadoc there might be another way.
Display each image with Image constructor that takes ValueMap and provide there some image identification.
Add a single Resource object for all images and from getResourceStream() implementation to call getParameters() which will return the same parameters passed to Image constructor and tell me which image to return.
Will this work?

Best regards,
Petar


Besides the servlet, there is also a wicket way of do it:

- Use shared resource, which is stateless and bookmarkable

If you need more informations about this approach, search on forum or just ask... and I'll provide you with some examples of how I do it..

Alex Objelean

Peter Dotchev wrote:
Hi,

My app allows users to upload images and I store them in JCR
<http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
get InputStream for each one of them.
I want to display images in specific pages and I want image URLs to be
stable/bookmarkable. Also I don't want these pages to use the session in
any way.
I checked again chapter 9 about images from Wicket In Action but such
use case is not addressed there.

I found that SharedResources allows for stable URLs, but I cannot
register each individual image.

What approach would you suggest?

Best regards,
Peter



Re: Bookmarkable images from db

by James Carman-3 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Just write a servlet (or Spring Web MVC "handler").

On Mon, Nov 2, 2009 at 10:52 AM, Peter Dotchev <dotchev@...> wrote:

>
> Hi Alex,
>
> I check SharedResources, but as I understand it I would have to add there a
> Resource object for each image.
>
> After checking again the javadoc there might be another way.
> Display each image with Image constructor that takes ValueMap and provide
> there some image identification.
> Add a single Resource object for all images and from getResourceStream()
> implementation to call getParameters() which will return the same parameters
> passed to Image constructor and tell me which image to return.
> Will this work?
>
> Best regards,
> Petar
>
>
> Alexandru Objelean wrote:
>>
>> Besides the servlet, there is also a wicket way of do it:
>>
>> - Use shared resource, which is stateless and bookmarkable
>>
>> If you need more informations about this approach, search on forum or just
>> ask... and I'll provide you with some examples of how I do it..
>>
>> Alex Objelean
>>
>>
>> Peter Dotchev wrote:
>>>
>>> Hi,
>>>
>>> My app allows users to upload images and I store them in JCR
>>> <http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
>>> get InputStream for each one of them.
>>> I want to display images in specific pages and I want image URLs to be
>>> stable/bookmarkable. Also I don't want these pages to use the session in
>>> any way.
>>> I checked again chapter 9 about images from Wicket In Action but such
>>> use case is not addressed there.
>>>
>>> I found that SharedResources allows for stable URLs, but I cannot
>>> register each individual image.
>>>
>>> What approach would you suggest?
>>>
>>> Best regards,
>>> Peter
>>>
>>>
>>>
>>>
>>
>>
>
> --
> View this message in context: http://old.nabble.com/Bookmarkable-images-from-db-tp26154577p26157711.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

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


Re: Bookmarkable images from db

by Alexandru Objelean :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Exactly. You can see the example posted by Vytautas Racelis earlier at this link:
http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-repository/src/main/java/org/xaloon/wicket/component/resource/ImageLink.java

I prefer to do it this way:
http://pastebin.com/m328e21ff

The first example allow you to use directly an Image component, while the second allows you to build the url of any resource by name..

Alex Objelean


Hi Alex,

I check SharedResources, but as I understand it I would have to add there a Resource object for each image.

After checking again the javadoc there might be another way.
Display each image with Image constructor that takes ValueMap and provide there some image identification.
Add a single Resource object for all images and from getResourceStream() implementation to call getParameters() which will return the same parameters passed to Image constructor and tell me which image to return.
Will this work?

Best regards,
Petar

Alexandru Objelean wrote:
Besides the servlet, there is also a wicket way of do it:

- Use shared resource, which is stateless and bookmarkable

If you need more informations about this approach, search on forum or just ask... and I'll provide you with some examples of how I do it..

Alex Objelean

Peter Dotchev wrote:
Hi,

My app allows users to upload images and I store them in JCR
<http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
get InputStream for each one of them.
I want to display images in specific pages and I want image URLs to be
stable/bookmarkable. Also I don't want these pages to use the session in
any way.
I checked again chapter 9 about images from Wicket In Action but such
use case is not addressed there.

I found that SharedResources allows for stable URLs, but I cannot
register each individual image.

What approach would you suggest?

Best regards,
Peter


Re: Bookmarkable images from db

by Juan Pablo Picasso :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi, I've implemented this by mounting a bookmarkable page and writing into
the response. I've imagine this bypasses some useful wicket features, but
was the only way I use bookmarkable urls like "/image/someImageName" for
mapping user uploaded images:

#Application
this.mount(new IndexedParamUrlCodingStrategy("/image", ImagePage.class));

#ImagePage class
public class ImagePage extends WebPage {

    private static Logger logger = LoggerFactory.getLogger(ImagePage.class);

    @Override
    protected void onRender(MarkupStream markupStream) {
        String imageName = (String)
this.getRequest().getParameterMap().get("0");

            byte[] fileContents = PersistenceFacade.readFile(imageName);
            try {
                this.getResponse().getOutputStream().write(fileContents);
            } catch (IOException e) {
                logger.error("Could not write image [" + imageName + "] into
the response", e);
            }
        }
    }
}

Any suggestions are welcome,
regards!
Juan

On Mon, Nov 2, 2009 at 3:00 PM, Alex Objelean <alex_objelean@...>wrote:

>
> Exactly. You can see the example posted by Vytautas Racelis earlier at this
> link:
>
> http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-repository/src/main/java/org/xaloon/wicket/component/resource/ImageLink.java
>
> I prefer to do it this way:
> http://pastebin.com/m328e21ff
>
> The first example allow you to use directly an Image component, while the
> second allows you to build the url of any resource by name..
>
> Alex Objelean
>
>
> Peter Dotchev wrote:
> >
> > Hi Alex,
> >
> > I check SharedResources, but as I understand it I would have to add there
> > a Resource object for each image.
> >
> > After checking again the javadoc there might be another way.
> > Display each image with Image constructor that takes ValueMap and provide
> > there some image identification.
> > Add a single Resource object for all images and from getResourceStream()
> > implementation to call getParameters() which will return the same
> > parameters passed to Image constructor and tell me which image to return.
> > Will this work?
> >
> > Best regards,
> > Petar
> >
> >
> > Alexandru Objelean wrote:
> >>
> >> Besides the servlet, there is also a wicket way of do it:
> >>
> >> - Use shared resource, which is stateless and bookmarkable
> >>
> >> If you need more informations about this approach, search on forum or
> >> just ask... and I'll provide you with some examples of how I do it..
> >>
> >> Alex Objelean
> >>
> >>
> >> Peter Dotchev wrote:
> >>>
> >>> Hi,
> >>>
> >>> My app allows users to upload images and I store them in JCR
> >>> <http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
> >>> get InputStream for each one of them.
> >>> I want to display images in specific pages and I want image URLs to be
> >>> stable/bookmarkable. Also I don't want these pages to use the session
> in
> >>> any way.
> >>> I checked again chapter 9 about images from Wicket In Action but such
> >>> use case is not addressed there.
> >>>
> >>> I found that SharedResources allows for stable URLs, but I cannot
> >>> register each individual image.
> >>>
> >>> What approach would you suggest?
> >>>
> >>> Best regards,
> >>> Peter
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Bookmarkable-images-from-db-tp26154577p26157757.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@...
> For additional commands, e-mail: users-help@...
>
>

Re: Bookmarkable images from db

by Peter Dotchev :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

Actually there is a clean and easy Wicket way to do this.
No servlets, no URL hand writing.
It is achieved by using a shared resource with parameters as mentioned above.
I have described it here.

Best regards,
Peter

Juan Pablo Picasso wrote:
Hi, I've implemented this by mounting a bookmarkable page and writing into
the response. I've imagine this bypasses some useful wicket features, but
was the only way I use bookmarkable urls like "/image/someImageName" for
mapping user uploaded images:

#Application
this.mount(new IndexedParamUrlCodingStrategy("/image", ImagePage.class));

#ImagePage class
public class ImagePage extends WebPage {

    private static Logger logger = LoggerFactory.getLogger(ImagePage.class);

    @Override
    protected void onRender(MarkupStream markupStream) {
        String imageName = (String)
this.getRequest().getParameterMap().get("0");

            byte[] fileContents = PersistenceFacade.readFile(imageName);
            try {
                this.getResponse().getOutputStream().write(fileContents);
            } catch (IOException e) {
                logger.error("Could not write image [" + imageName + "] into
the response", e);
            }
        }
    }
}

Any suggestions are welcome,
regards!
Juan

On Mon, Nov 2, 2009 at 3:00 PM, Alex Objelean <alex_objelean@yahoo.com>wrote:

>
> Exactly. You can see the example posted by Vytautas Racelis earlier at this
> link:
>
> http://xaloon.googlecode.com/svn/trunk/xaloon-wicket-repository/src/main/java/org/xaloon/wicket/component/resource/ImageLink.java
>
> I prefer to do it this way:
> http://pastebin.com/m328e21ff
>
> The first example allow you to use directly an Image component, while the
> second allows you to build the url of any resource by name..
>
> Alex Objelean
>
>
> Peter Dotchev wrote:
> >
> > Hi Alex,
> >
> > I check SharedResources, but as I understand it I would have to add there
> > a Resource object for each image.
> >
> > After checking again the javadoc there might be another way.
> > Display each image with Image constructor that takes ValueMap and provide
> > there some image identification.
> > Add a single Resource object for all images and from getResourceStream()
> > implementation to call getParameters() which will return the same
> > parameters passed to Image constructor and tell me which image to return.
> > Will this work?
> >
> > Best regards,
> > Petar
> >
> >
> > Alexandru Objelean wrote:
> >>
> >> Besides the servlet, there is also a wicket way of do it:
> >>
> >> - Use shared resource, which is stateless and bookmarkable
> >>
> >> If you need more informations about this approach, search on forum or
> >> just ask... and I'll provide you with some examples of how I do it..
> >>
> >> Alex Objelean
> >>
> >>
> >> Peter Dotchev wrote:
> >>>
> >>> Hi,
> >>>
> >>> My app allows users to upload images and I store them in JCR
> >>> <http://en.wikipedia.org/wiki/Content_repository_API_for_Java>. I can
> >>> get InputStream for each one of them.
> >>> I want to display images in specific pages and I want image URLs to be
> >>> stable/bookmarkable. Also I don't want these pages to use the session
> in
> >>> any way.
> >>> I checked again chapter 9 about images from Wicket In Action but such
> >>> use case is not addressed there.
> >>>
> >>> I found that SharedResources allows for stable URLs, but I cannot
> >>> register each individual image.
> >>>
> >>> What approach would you suggest?
> >>>
> >>> Best regards,
> >>> Peter
> >>>
> >>>
> >>>
> >>>
> >>
> >>
> >
> >
>
> --
> View this message in context:
> http://old.nabble.com/Bookmarkable-images-from-db-tp26154577p26157757.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>