You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by David Canteros <da...@gmail.com> on 2011/08/05 22:39:50 UTC

Re: Uploading then displaying Images

Hi
I have to show a image loaded from database BLOB field. I implemented
Thiago's suggestion, I have created a page with the following code:

public class ShowImagePage {

    @Inject
    private LinkSource linkSource;
     (...)

    public Link *getUploadedFile*(String imageId) {
            return
linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
false, new Object[]{imageId});
    }

    public StreamResponse *onActivate*(String imageId) {
        this.filename = imageId;
        return new StreamResponse() {

            public String *getContentType*() {
                return contentType;
            }

            public InputStream *getStream*() throws IOException {
                User user =
(User)_request.getSession(true).getAttribute("user");
                return user.getImage();
            }

            public void *prepareResponse*(Response response) {
                response.setHeader("Content-Disposition", "inline;
filename=" + filename
                            + ((extension == null) ? "" : ("." +
extension)));
            }
        };
    }
 }
**
In the javacode of the page where i have to show the image, I injected the
above page and wrote this method

public Link *getImageLink*(ImageId){
    return showImagewPage.getUploadedFile(imageId);
}
 and in html code I put this:

<img src="${imageLInk}"/>

It works fine, the image is showed but when I refresh the page (with F5),
the image dissapear. It behavior does not occur if I submit some form placed
in the same page that refresh the page too (the method  "onSubmitFrom..."
returns "this" ). I have debugged the code and everything works fine, do you
have any idea about this behavior?

Thanks!!

------------------------------------------------------------------
David Germán Canteros


2011/3/11 Rich M <ri...@moremagic.com>

> Thanks everyone for the responses so far, conceptually I think this is
> coming together for me.
>
> So, I'm glad the context path was not a good idea, it felt dirty from the
> beginning. Avoiding that, there are two main options: use the database to
> store/retrieve the images, or use a configured system folder from where I
> can load/save files with Java IO.
>
> Regardless of the option chosen there, the image file will be captured as
> an InputStream and returned as a StreamResponse in some form to a
> page/component.
>
> As far as linking the StreamResponse to an HTML IMG tag, I believe I
> understand the various options presented here.
>
> LLTYK suggests using an EventLink. I was looking through my code and found
> a Captcha implementation I have using a propertyExpression in the TML on the
> src attribute of <IMG> to reference a getImageLink function that returns
> ComponentResources.**createActionLink("image",null)**. Then there is an
> onImage() action handler method that returns a StreamResponse. I understand
> this is ActionLink and not EventLink, but I think the concept must be nearly
> identical.
>
> Alternately, Thiago is suggesting that instead of using ComponentResources
> to generate an ActionLink or EventLink, it may be easier to create a
> seperate Page that handles returning just a StreamResponse. In that case the
> EventLink can be replaced with a PageLink and using an activation context
> the ID for the Image can be passed to the Page so it can load the Image,
> build the StreamResponse, and return it.
>
> <30 minutes later> Okay, the PageLink works out, great! I can see the
> biggest issue I was having was setting up the src attribute for IMG
> correctly. I was stuck thinking it was either the URL to the context path or
> the StreamResponse itself, rather than a link to an event or page that
> returns the StreamResponse.
>
> Thanks,
> Rich
>
>
>
> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
>
>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com> wrote:
>>
>>  Nobody's mentioned createEventLink. That's where you get the image url,
>>> create an event link pointing to the event handler that returns the
>>> stream response.
>>>
>>
>> I haven't mentioned it because my preferred approach is to create a page
>> just for returning StreamResponses. It's more reusable, as it can be used to
>> serve images for any page, while an event must be only used inside a give
>> page.
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Uploading then displaying Images

Posted by Josh Canfield <jo...@gmail.com>.
>            public InputStream *getStream*() throws IOException {
>                User user =
> (User)_request.getSession(true).getAttribute("user");
>                return user.getImage();
>            }

It looks like you're pulling the User object from the session and then
getting the InputStream from user.getImage();
If user.getImage is caching the stream reference then the stream will
be empty the second time you try to read from it right? Because it's
the same object stored in the session.

Josh

On Fri, Aug 5, 2011 at 1:39 PM, David Canteros
<da...@gmail.com> wrote:
> Hi
> I have to show a image loaded from database BLOB field. I implemented
> Thiago's suggestion, I have created a page with the following code:
>
> public class ShowImagePage {
>
>    @Inject
>    private LinkSource linkSource;
>     (...)
>
>    public Link *getUploadedFile*(String imageId) {
>            return
> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
> false, new Object[]{imageId});
>    }
>
>    public StreamResponse *onActivate*(String imageId) {
>        this.filename = imageId;
>        return new StreamResponse() {
>
>            public String *getContentType*() {
>                return contentType;
>            }
>
>            public InputStream *getStream*() throws IOException {
>                User user =
> (User)_request.getSession(true).getAttribute("user");
>                return user.getImage();
>            }
>
>            public void *prepareResponse*(Response response) {
>                response.setHeader("Content-Disposition", "inline;
> filename=" + filename
>                            + ((extension == null) ? "" : ("." +
> extension)));
>            }
>        };
>    }
>  }
> **
> In the javacode of the page where i have to show the image, I injected the
> above page and wrote this method
>
> public Link *getImageLink*(ImageId){
>    return showImagewPage.getUploadedFile(imageId);
> }
>  and in html code I put this:
>
> <img src="${imageLInk}"/>
>
> It works fine, the image is showed but when I refresh the page (with F5),
> the image dissapear. It behavior does not occur if I submit some form placed
> in the same page that refresh the page too (the method  "onSubmitFrom..."
> returns "this" ). I have debugged the code and everything works fine, do you
> have any idea about this behavior?
>
> Thanks!!
>
> ------------------------------------------------------------------
> David Germán Canteros
>
>
> 2011/3/11 Rich M <ri...@moremagic.com>
>
>> Thanks everyone for the responses so far, conceptually I think this is
>> coming together for me.
>>
>> So, I'm glad the context path was not a good idea, it felt dirty from the
>> beginning. Avoiding that, there are two main options: use the database to
>> store/retrieve the images, or use a configured system folder from where I
>> can load/save files with Java IO.
>>
>> Regardless of the option chosen there, the image file will be captured as
>> an InputStream and returned as a StreamResponse in some form to a
>> page/component.
>>
>> As far as linking the StreamResponse to an HTML IMG tag, I believe I
>> understand the various options presented here.
>>
>> LLTYK suggests using an EventLink. I was looking through my code and found
>> a Captcha implementation I have using a propertyExpression in the TML on the
>> src attribute of <IMG> to reference a getImageLink function that returns
>> ComponentResources.**createActionLink("image",null)**. Then there is an
>> onImage() action handler method that returns a StreamResponse. I understand
>> this is ActionLink and not EventLink, but I think the concept must be nearly
>> identical.
>>
>> Alternately, Thiago is suggesting that instead of using ComponentResources
>> to generate an ActionLink or EventLink, it may be easier to create a
>> seperate Page that handles returning just a StreamResponse. In that case the
>> EventLink can be replaced with a PageLink and using an activation context
>> the ID for the Image can be passed to the Page so it can load the Image,
>> build the StreamResponse, and return it.
>>
>> <30 minutes later> Okay, the PageLink works out, great! I can see the
>> biggest issue I was having was setting up the src attribute for IMG
>> correctly. I was stuck thinking it was either the URL to the context path or
>> the StreamResponse itself, rather than a link to an event or page that
>> returns the StreamResponse.
>>
>> Thanks,
>> Rich
>>
>>
>>
>> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
>>
>>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com> wrote:
>>>
>>>  Nobody's mentioned createEventLink. That's where you get the image url,
>>>> create an event link pointing to the event handler that returns the
>>>> stream response.
>>>>
>>>
>>> I haven't mentioned it because my preferred approach is to create a page
>>> just for returning StreamResponses. It's more reusable, as it can be used to
>>> serve images for any page, while an event must be only used inside a give
>>> page.
>>>
>>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

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


Re: Uploading then displaying Images

Posted by Josh Canfield <jo...@gmail.com>.
Ah, good to hear!

On Mon, Aug 8, 2011 at 5:52 AM, David Canteros
<da...@gmail.com> wrote:
> Hi again Josh, i had not  seen your first response, there was the solution to
> my problem.
> Thank you!
> David
>
>
>
> ------------------------------------------------------------------
> David Germán Canteros
>
>
> 2011/8/6 David Canteros <da...@gmail.com>
>
>> Yes, user is an object loaded in the setupRender() method, and getImage()
>> returns an InputStream every time the page is loaded.
>>
>>
>> ------------------------------------------------------------------
>> David Germán Canteros
>>
>>
>> 2011/8/5 Josh Canfield <jo...@gmail.com>
>>
>>> The real issue is more likely the first point, you're getting your
>>> InputStream from an object from the session. Does calling getImage()
>>> return a new InputStream every time?
>>>
>>> On Fri, Aug 5, 2011 at 2:44 PM, David Canteros
>>> <da...@gmail.com> wrote:
>>> > Hi Josh;
>>> >           I have already tried with PageRenderLinkSource but It has the
>>> > same behavior.  I did not know the difference between LinkSource and
>>> > PageRenderLinkSource, thanks for the information!
>>> >
>>> > David
>>> >
>>> > ------------------------------------------------------------------
>>> > David Germán Canteros
>>> >
>>> >
>>> > 2011/8/5 Josh Canfield <jo...@gmail.com>
>>> >
>>> >> Also.
>>> >> >    private LinkSource linkSource;
>>> >>
>>> >> This is an internal class, you should be using PageRenderLinkSource.
>>> >> You can replace:
>>> >>
>>> >> >
>>> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
>>> >> false, new Object[]{imageId});
>>> >>
>>> >> with
>>> >>
>>> >>
>>> >>
>>> pageRenderLinkSource.createPageRenderLinkWithContext(DisplayImagePage.class,
>>> >> imageId);
>>> >>
>>> >> Josh
>>> >>
>>> >> On Fri, Aug 5, 2011 at 1:39 PM, David Canteros
>>> >> <da...@gmail.com> wrote:
>>> >> > Hi
>>> >> > I have to show a image loaded from database BLOB field. I implemented
>>> >> > Thiago's suggestion, I have created a page with the following code:
>>> >> >
>>> >> > public class ShowImagePage {
>>> >> >
>>> >> >    @Inject
>>> >> >    private LinkSource linkSource;
>>> >> >     (...)
>>> >> >
>>> >> >    public Link *getUploadedFile*(String imageId) {
>>> >> >            return
>>> >> >
>>> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
>>> >> > false, new Object[]{imageId});
>>> >> >    }
>>> >> >
>>> >> >    public StreamResponse *onActivate*(String imageId) {
>>> >> >        this.filename = imageId;
>>> >> >        return new StreamResponse() {
>>> >> >
>>> >> >            public String *getContentType*() {
>>> >> >                return contentType;
>>> >> >            }
>>> >> >
>>> >> >            public InputStream *getStream*() throws IOException {
>>> >> >                User user =
>>> >> > (User)_request.getSession(true).getAttribute("user");
>>> >> >                return user.getImage();
>>> >> >            }
>>> >> >
>>> >> >            public void *prepareResponse*(Response response) {
>>> >> >                response.setHeader("Content-Disposition", "inline;
>>> >> > filename=" + filename
>>> >> >                            + ((extension == null) ? "" : ("." +
>>> >> > extension)));
>>> >> >            }
>>> >> >        };
>>> >> >    }
>>> >> >  }
>>> >> > **
>>> >> > In the javacode of the page where i have to show the image, I
>>> injected
>>> >> the
>>> >> > above page and wrote this method
>>> >> >
>>> >> > public Link *getImageLink*(ImageId){
>>> >> >    return showImagewPage.getUploadedFile(imageId);
>>> >> > }
>>> >> >  and in html code I put this:
>>> >> >
>>> >> > <img src="${imageLInk}"/>
>>> >> >
>>> >> > It works fine, the image is showed but when I refresh the page (with
>>> F5),
>>> >> > the image dissapear. It behavior does not occur if I submit some form
>>> >> placed
>>> >> > in the same page that refresh the page too (the method
>>>  "onSubmitFrom..."
>>> >> > returns "this" ). I have debugged the code and everything works fine,
>>> do
>>> >> you
>>> >> > have any idea about this behavior?
>>> >> >
>>> >> > Thanks!!
>>> >> >
>>> >> > ------------------------------------------------------------------
>>> >> > David Germán Canteros
>>> >> >
>>> >> >
>>> >> > 2011/3/11 Rich M <ri...@moremagic.com>
>>> >> >
>>> >> >> Thanks everyone for the responses so far, conceptually I think this
>>> is
>>> >> >> coming together for me.
>>> >> >>
>>> >> >> So, I'm glad the context path was not a good idea, it felt dirty
>>> from
>>> >> the
>>> >> >> beginning. Avoiding that, there are two main options: use the
>>> database
>>> >> to
>>> >> >> store/retrieve the images, or use a configured system folder from
>>> where
>>> >> I
>>> >> >> can load/save files with Java IO.
>>> >> >>
>>> >> >> Regardless of the option chosen there, the image file will be
>>> captured
>>> >> as
>>> >> >> an InputStream and returned as a StreamResponse in some form to a
>>> >> >> page/component.
>>> >> >>
>>> >> >> As far as linking the StreamResponse to an HTML IMG tag, I believe I
>>> >> >> understand the various options presented here.
>>> >> >>
>>> >> >> LLTYK suggests using an EventLink. I was looking through my code and
>>> >> found
>>> >> >> a Captcha implementation I have using a propertyExpression in the
>>> TML on
>>> >> the
>>> >> >> src attribute of <IMG> to reference a getImageLink function that
>>> returns
>>> >> >> ComponentResources.**createActionLink("image",null)**. Then there is
>>> an
>>> >> >> onImage() action handler method that returns a StreamResponse. I
>>> >> understand
>>> >> >> this is ActionLink and not EventLink, but I think the concept must
>>> be
>>> >> nearly
>>> >> >> identical.
>>> >> >>
>>> >> >> Alternately, Thiago is suggesting that instead of using
>>> >> ComponentResources
>>> >> >> to generate an ActionLink or EventLink, it may be easier to create a
>>> >> >> seperate Page that handles returning just a StreamResponse. In that
>>> case
>>> >> the
>>> >> >> EventLink can be replaced with a PageLink and using an activation
>>> >> context
>>> >> >> the ID for the Image can be passed to the Page so it can load the
>>> Image,
>>> >> >> build the StreamResponse, and return it.
>>> >> >>
>>> >> >> <30 minutes later> Okay, the PageLink works out, great! I can see
>>> the
>>> >> >> biggest issue I was having was setting up the src attribute for IMG
>>> >> >> correctly. I was stuck thinking it was either the URL to the context
>>> >> path or
>>> >> >> the StreamResponse itself, rather than a link to an event or page
>>> that
>>> >> >> returns the StreamResponse.
>>> >> >>
>>> >> >> Thanks,
>>> >> >> Rich
>>> >> >>
>>> >> >>
>>> >> >>
>>> >> >> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
>>> >> >>
>>> >> >>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com>
>>> >> wrote:
>>> >> >>>
>>> >> >>>  Nobody's mentioned createEventLink. That's where you get the image
>>> >> url,
>>> >> >>>> create an event link pointing to the event handler that returns
>>> the
>>> >> >>>> stream response.
>>> >> >>>>
>>> >> >>>
>>> >> >>> I haven't mentioned it because my preferred approach is to create a
>>> >> page
>>> >> >>> just for returning StreamResponses. It's more reusable, as it can
>>> be
>>> >> used to
>>> >> >>> serve images for any page, while an event must be only used inside
>>> a
>>> >> give
>>> >> >>> page.
>>> >> >>>
>>> >> >>>
>>> >> >>
>>> >> >>
>>> >>
>>> ------------------------------**------------------------------**---------
>>> >> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
>>> >> users-unsubscribe@tapestry.apache.org>
>>> >> >> For additional commands, e-mail: users-help@tapestry.apache.org
>>> >> >>
>>> >> >>
>>> >> >
>>> >>
>>> >> ---------------------------------------------------------------------
>>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>>> >>
>>> >>
>>> >
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>

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


Re: Uploading then displaying Images

Posted by David Canteros <da...@gmail.com>.
Hi again Josh, i had not  seen your first response, there was the solution to
my problem.
Thank you!
David



------------------------------------------------------------------
David Germán Canteros


2011/8/6 David Canteros <da...@gmail.com>

> Yes, user is an object loaded in the setupRender() method, and getImage()
> returns an InputStream every time the page is loaded.
>
>
> ------------------------------------------------------------------
> David Germán Canteros
>
>
> 2011/8/5 Josh Canfield <jo...@gmail.com>
>
>> The real issue is more likely the first point, you're getting your
>> InputStream from an object from the session. Does calling getImage()
>> return a new InputStream every time?
>>
>> On Fri, Aug 5, 2011 at 2:44 PM, David Canteros
>> <da...@gmail.com> wrote:
>> > Hi Josh;
>> >           I have already tried with PageRenderLinkSource but It has the
>> > same behavior.  I did not know the difference between LinkSource and
>> > PageRenderLinkSource, thanks for the information!
>> >
>> > David
>> >
>> > ------------------------------------------------------------------
>> > David Germán Canteros
>> >
>> >
>> > 2011/8/5 Josh Canfield <jo...@gmail.com>
>> >
>> >> Also.
>> >> >    private LinkSource linkSource;
>> >>
>> >> This is an internal class, you should be using PageRenderLinkSource.
>> >> You can replace:
>> >>
>> >> >
>> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
>> >> false, new Object[]{imageId});
>> >>
>> >> with
>> >>
>> >>
>> >>
>> pageRenderLinkSource.createPageRenderLinkWithContext(DisplayImagePage.class,
>> >> imageId);
>> >>
>> >> Josh
>> >>
>> >> On Fri, Aug 5, 2011 at 1:39 PM, David Canteros
>> >> <da...@gmail.com> wrote:
>> >> > Hi
>> >> > I have to show a image loaded from database BLOB field. I implemented
>> >> > Thiago's suggestion, I have created a page with the following code:
>> >> >
>> >> > public class ShowImagePage {
>> >> >
>> >> >    @Inject
>> >> >    private LinkSource linkSource;
>> >> >     (...)
>> >> >
>> >> >    public Link *getUploadedFile*(String imageId) {
>> >> >            return
>> >> >
>> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
>> >> > false, new Object[]{imageId});
>> >> >    }
>> >> >
>> >> >    public StreamResponse *onActivate*(String imageId) {
>> >> >        this.filename = imageId;
>> >> >        return new StreamResponse() {
>> >> >
>> >> >            public String *getContentType*() {
>> >> >                return contentType;
>> >> >            }
>> >> >
>> >> >            public InputStream *getStream*() throws IOException {
>> >> >                User user =
>> >> > (User)_request.getSession(true).getAttribute("user");
>> >> >                return user.getImage();
>> >> >            }
>> >> >
>> >> >            public void *prepareResponse*(Response response) {
>> >> >                response.setHeader("Content-Disposition", "inline;
>> >> > filename=" + filename
>> >> >                            + ((extension == null) ? "" : ("." +
>> >> > extension)));
>> >> >            }
>> >> >        };
>> >> >    }
>> >> >  }
>> >> > **
>> >> > In the javacode of the page where i have to show the image, I
>> injected
>> >> the
>> >> > above page and wrote this method
>> >> >
>> >> > public Link *getImageLink*(ImageId){
>> >> >    return showImagewPage.getUploadedFile(imageId);
>> >> > }
>> >> >  and in html code I put this:
>> >> >
>> >> > <img src="${imageLInk}"/>
>> >> >
>> >> > It works fine, the image is showed but when I refresh the page (with
>> F5),
>> >> > the image dissapear. It behavior does not occur if I submit some form
>> >> placed
>> >> > in the same page that refresh the page too (the method
>>  "onSubmitFrom..."
>> >> > returns "this" ). I have debugged the code and everything works fine,
>> do
>> >> you
>> >> > have any idea about this behavior?
>> >> >
>> >> > Thanks!!
>> >> >
>> >> > ------------------------------------------------------------------
>> >> > David Germán Canteros
>> >> >
>> >> >
>> >> > 2011/3/11 Rich M <ri...@moremagic.com>
>> >> >
>> >> >> Thanks everyone for the responses so far, conceptually I think this
>> is
>> >> >> coming together for me.
>> >> >>
>> >> >> So, I'm glad the context path was not a good idea, it felt dirty
>> from
>> >> the
>> >> >> beginning. Avoiding that, there are two main options: use the
>> database
>> >> to
>> >> >> store/retrieve the images, or use a configured system folder from
>> where
>> >> I
>> >> >> can load/save files with Java IO.
>> >> >>
>> >> >> Regardless of the option chosen there, the image file will be
>> captured
>> >> as
>> >> >> an InputStream and returned as a StreamResponse in some form to a
>> >> >> page/component.
>> >> >>
>> >> >> As far as linking the StreamResponse to an HTML IMG tag, I believe I
>> >> >> understand the various options presented here.
>> >> >>
>> >> >> LLTYK suggests using an EventLink. I was looking through my code and
>> >> found
>> >> >> a Captcha implementation I have using a propertyExpression in the
>> TML on
>> >> the
>> >> >> src attribute of <IMG> to reference a getImageLink function that
>> returns
>> >> >> ComponentResources.**createActionLink("image",null)**. Then there is
>> an
>> >> >> onImage() action handler method that returns a StreamResponse. I
>> >> understand
>> >> >> this is ActionLink and not EventLink, but I think the concept must
>> be
>> >> nearly
>> >> >> identical.
>> >> >>
>> >> >> Alternately, Thiago is suggesting that instead of using
>> >> ComponentResources
>> >> >> to generate an ActionLink or EventLink, it may be easier to create a
>> >> >> seperate Page that handles returning just a StreamResponse. In that
>> case
>> >> the
>> >> >> EventLink can be replaced with a PageLink and using an activation
>> >> context
>> >> >> the ID for the Image can be passed to the Page so it can load the
>> Image,
>> >> >> build the StreamResponse, and return it.
>> >> >>
>> >> >> <30 minutes later> Okay, the PageLink works out, great! I can see
>> the
>> >> >> biggest issue I was having was setting up the src attribute for IMG
>> >> >> correctly. I was stuck thinking it was either the URL to the context
>> >> path or
>> >> >> the StreamResponse itself, rather than a link to an event or page
>> that
>> >> >> returns the StreamResponse.
>> >> >>
>> >> >> Thanks,
>> >> >> Rich
>> >> >>
>> >> >>
>> >> >>
>> >> >> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
>> >> >>
>> >> >>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com>
>> >> wrote:
>> >> >>>
>> >> >>>  Nobody's mentioned createEventLink. That's where you get the image
>> >> url,
>> >> >>>> create an event link pointing to the event handler that returns
>> the
>> >> >>>> stream response.
>> >> >>>>
>> >> >>>
>> >> >>> I haven't mentioned it because my preferred approach is to create a
>> >> page
>> >> >>> just for returning StreamResponses. It's more reusable, as it can
>> be
>> >> used to
>> >> >>> serve images for any page, while an event must be only used inside
>> a
>> >> give
>> >> >>> page.
>> >> >>>
>> >> >>>
>> >> >>
>> >> >>
>> >>
>> ------------------------------**------------------------------**---------
>> >> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
>> >> users-unsubscribe@tapestry.apache.org>
>> >> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >> >>
>> >> >>
>> >> >
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

Re: Uploading then displaying Images

Posted by David Canteros <da...@gmail.com>.
Yes, user is an object loaded in the setupRender() method, and getImage()
returns an InputStream every time the page is loaded.


------------------------------------------------------------------
David Germán Canteros


2011/8/5 Josh Canfield <jo...@gmail.com>

> The real issue is more likely the first point, you're getting your
> InputStream from an object from the session. Does calling getImage()
> return a new InputStream every time?
>
> On Fri, Aug 5, 2011 at 2:44 PM, David Canteros
> <da...@gmail.com> wrote:
> > Hi Josh;
> >           I have already tried with PageRenderLinkSource but It has the
> > same behavior.  I did not know the difference between LinkSource and
> > PageRenderLinkSource, thanks for the information!
> >
> > David
> >
> > ------------------------------------------------------------------
> > David Germán Canteros
> >
> >
> > 2011/8/5 Josh Canfield <jo...@gmail.com>
> >
> >> Also.
> >> >    private LinkSource linkSource;
> >>
> >> This is an internal class, you should be using PageRenderLinkSource.
> >> You can replace:
> >>
> >> >
> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
> >> false, new Object[]{imageId});
> >>
> >> with
> >>
> >>
> >>
> pageRenderLinkSource.createPageRenderLinkWithContext(DisplayImagePage.class,
> >> imageId);
> >>
> >> Josh
> >>
> >> On Fri, Aug 5, 2011 at 1:39 PM, David Canteros
> >> <da...@gmail.com> wrote:
> >> > Hi
> >> > I have to show a image loaded from database BLOB field. I implemented
> >> > Thiago's suggestion, I have created a page with the following code:
> >> >
> >> > public class ShowImagePage {
> >> >
> >> >    @Inject
> >> >    private LinkSource linkSource;
> >> >     (...)
> >> >
> >> >    public Link *getUploadedFile*(String imageId) {
> >> >            return
> >> >
> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
> >> > false, new Object[]{imageId});
> >> >    }
> >> >
> >> >    public StreamResponse *onActivate*(String imageId) {
> >> >        this.filename = imageId;
> >> >        return new StreamResponse() {
> >> >
> >> >            public String *getContentType*() {
> >> >                return contentType;
> >> >            }
> >> >
> >> >            public InputStream *getStream*() throws IOException {
> >> >                User user =
> >> > (User)_request.getSession(true).getAttribute("user");
> >> >                return user.getImage();
> >> >            }
> >> >
> >> >            public void *prepareResponse*(Response response) {
> >> >                response.setHeader("Content-Disposition", "inline;
> >> > filename=" + filename
> >> >                            + ((extension == null) ? "" : ("." +
> >> > extension)));
> >> >            }
> >> >        };
> >> >    }
> >> >  }
> >> > **
> >> > In the javacode of the page where i have to show the image, I injected
> >> the
> >> > above page and wrote this method
> >> >
> >> > public Link *getImageLink*(ImageId){
> >> >    return showImagewPage.getUploadedFile(imageId);
> >> > }
> >> >  and in html code I put this:
> >> >
> >> > <img src="${imageLInk}"/>
> >> >
> >> > It works fine, the image is showed but when I refresh the page (with
> F5),
> >> > the image dissapear. It behavior does not occur if I submit some form
> >> placed
> >> > in the same page that refresh the page too (the method
>  "onSubmitFrom..."
> >> > returns "this" ). I have debugged the code and everything works fine,
> do
> >> you
> >> > have any idea about this behavior?
> >> >
> >> > Thanks!!
> >> >
> >> > ------------------------------------------------------------------
> >> > David Germán Canteros
> >> >
> >> >
> >> > 2011/3/11 Rich M <ri...@moremagic.com>
> >> >
> >> >> Thanks everyone for the responses so far, conceptually I think this
> is
> >> >> coming together for me.
> >> >>
> >> >> So, I'm glad the context path was not a good idea, it felt dirty from
> >> the
> >> >> beginning. Avoiding that, there are two main options: use the
> database
> >> to
> >> >> store/retrieve the images, or use a configured system folder from
> where
> >> I
> >> >> can load/save files with Java IO.
> >> >>
> >> >> Regardless of the option chosen there, the image file will be
> captured
> >> as
> >> >> an InputStream and returned as a StreamResponse in some form to a
> >> >> page/component.
> >> >>
> >> >> As far as linking the StreamResponse to an HTML IMG tag, I believe I
> >> >> understand the various options presented here.
> >> >>
> >> >> LLTYK suggests using an EventLink. I was looking through my code and
> >> found
> >> >> a Captcha implementation I have using a propertyExpression in the TML
> on
> >> the
> >> >> src attribute of <IMG> to reference a getImageLink function that
> returns
> >> >> ComponentResources.**createActionLink("image",null)**. Then there is
> an
> >> >> onImage() action handler method that returns a StreamResponse. I
> >> understand
> >> >> this is ActionLink and not EventLink, but I think the concept must be
> >> nearly
> >> >> identical.
> >> >>
> >> >> Alternately, Thiago is suggesting that instead of using
> >> ComponentResources
> >> >> to generate an ActionLink or EventLink, it may be easier to create a
> >> >> seperate Page that handles returning just a StreamResponse. In that
> case
> >> the
> >> >> EventLink can be replaced with a PageLink and using an activation
> >> context
> >> >> the ID for the Image can be passed to the Page so it can load the
> Image,
> >> >> build the StreamResponse, and return it.
> >> >>
> >> >> <30 minutes later> Okay, the PageLink works out, great! I can see the
> >> >> biggest issue I was having was setting up the src attribute for IMG
> >> >> correctly. I was stuck thinking it was either the URL to the context
> >> path or
> >> >> the StreamResponse itself, rather than a link to an event or page
> that
> >> >> returns the StreamResponse.
> >> >>
> >> >> Thanks,
> >> >> Rich
> >> >>
> >> >>
> >> >>
> >> >> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
> >> >>
> >> >>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com>
> >> wrote:
> >> >>>
> >> >>>  Nobody's mentioned createEventLink. That's where you get the image
> >> url,
> >> >>>> create an event link pointing to the event handler that returns the
> >> >>>> stream response.
> >> >>>>
> >> >>>
> >> >>> I haven't mentioned it because my preferred approach is to create a
> >> page
> >> >>> just for returning StreamResponses. It's more reusable, as it can be
> >> used to
> >> >>> serve images for any page, while an event must be only used inside a
> >> give
> >> >>> page.
> >> >>>
> >> >>>
> >> >>
> >> >>
> >>
> ------------------------------**------------------------------**---------
> >> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
> >> users-unsubscribe@tapestry.apache.org>
> >> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >> >>
> >> >>
> >> >
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Uploading then displaying Images

Posted by Josh Canfield <jo...@gmail.com>.
The real issue is more likely the first point, you're getting your
InputStream from an object from the session. Does calling getImage()
return a new InputStream every time?

On Fri, Aug 5, 2011 at 2:44 PM, David Canteros
<da...@gmail.com> wrote:
> Hi Josh;
>           I have already tried with PageRenderLinkSource but It has the
> same behavior.  I did not know the difference between LinkSource and
> PageRenderLinkSource, thanks for the information!
>
> David
>
> ------------------------------------------------------------------
> David Germán Canteros
>
>
> 2011/8/5 Josh Canfield <jo...@gmail.com>
>
>> Also.
>> >    private LinkSource linkSource;
>>
>> This is an internal class, you should be using PageRenderLinkSource.
>> You can replace:
>>
>> > linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
>> false, new Object[]{imageId});
>>
>> with
>>
>>
>> pageRenderLinkSource.createPageRenderLinkWithContext(DisplayImagePage.class,
>> imageId);
>>
>> Josh
>>
>> On Fri, Aug 5, 2011 at 1:39 PM, David Canteros
>> <da...@gmail.com> wrote:
>> > Hi
>> > I have to show a image loaded from database BLOB field. I implemented
>> > Thiago's suggestion, I have created a page with the following code:
>> >
>> > public class ShowImagePage {
>> >
>> >    @Inject
>> >    private LinkSource linkSource;
>> >     (...)
>> >
>> >    public Link *getUploadedFile*(String imageId) {
>> >            return
>> > linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
>> > false, new Object[]{imageId});
>> >    }
>> >
>> >    public StreamResponse *onActivate*(String imageId) {
>> >        this.filename = imageId;
>> >        return new StreamResponse() {
>> >
>> >            public String *getContentType*() {
>> >                return contentType;
>> >            }
>> >
>> >            public InputStream *getStream*() throws IOException {
>> >                User user =
>> > (User)_request.getSession(true).getAttribute("user");
>> >                return user.getImage();
>> >            }
>> >
>> >            public void *prepareResponse*(Response response) {
>> >                response.setHeader("Content-Disposition", "inline;
>> > filename=" + filename
>> >                            + ((extension == null) ? "" : ("." +
>> > extension)));
>> >            }
>> >        };
>> >    }
>> >  }
>> > **
>> > In the javacode of the page where i have to show the image, I injected
>> the
>> > above page and wrote this method
>> >
>> > public Link *getImageLink*(ImageId){
>> >    return showImagewPage.getUploadedFile(imageId);
>> > }
>> >  and in html code I put this:
>> >
>> > <img src="${imageLInk}"/>
>> >
>> > It works fine, the image is showed but when I refresh the page (with F5),
>> > the image dissapear. It behavior does not occur if I submit some form
>> placed
>> > in the same page that refresh the page too (the method  "onSubmitFrom..."
>> > returns "this" ). I have debugged the code and everything works fine, do
>> you
>> > have any idea about this behavior?
>> >
>> > Thanks!!
>> >
>> > ------------------------------------------------------------------
>> > David Germán Canteros
>> >
>> >
>> > 2011/3/11 Rich M <ri...@moremagic.com>
>> >
>> >> Thanks everyone for the responses so far, conceptually I think this is
>> >> coming together for me.
>> >>
>> >> So, I'm glad the context path was not a good idea, it felt dirty from
>> the
>> >> beginning. Avoiding that, there are two main options: use the database
>> to
>> >> store/retrieve the images, or use a configured system folder from where
>> I
>> >> can load/save files with Java IO.
>> >>
>> >> Regardless of the option chosen there, the image file will be captured
>> as
>> >> an InputStream and returned as a StreamResponse in some form to a
>> >> page/component.
>> >>
>> >> As far as linking the StreamResponse to an HTML IMG tag, I believe I
>> >> understand the various options presented here.
>> >>
>> >> LLTYK suggests using an EventLink. I was looking through my code and
>> found
>> >> a Captcha implementation I have using a propertyExpression in the TML on
>> the
>> >> src attribute of <IMG> to reference a getImageLink function that returns
>> >> ComponentResources.**createActionLink("image",null)**. Then there is an
>> >> onImage() action handler method that returns a StreamResponse. I
>> understand
>> >> this is ActionLink and not EventLink, but I think the concept must be
>> nearly
>> >> identical.
>> >>
>> >> Alternately, Thiago is suggesting that instead of using
>> ComponentResources
>> >> to generate an ActionLink or EventLink, it may be easier to create a
>> >> seperate Page that handles returning just a StreamResponse. In that case
>> the
>> >> EventLink can be replaced with a PageLink and using an activation
>> context
>> >> the ID for the Image can be passed to the Page so it can load the Image,
>> >> build the StreamResponse, and return it.
>> >>
>> >> <30 minutes later> Okay, the PageLink works out, great! I can see the
>> >> biggest issue I was having was setting up the src attribute for IMG
>> >> correctly. I was stuck thinking it was either the URL to the context
>> path or
>> >> the StreamResponse itself, rather than a link to an event or page that
>> >> returns the StreamResponse.
>> >>
>> >> Thanks,
>> >> Rich
>> >>
>> >>
>> >>
>> >> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
>> >>
>> >>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com>
>> wrote:
>> >>>
>> >>>  Nobody's mentioned createEventLink. That's where you get the image
>> url,
>> >>>> create an event link pointing to the event handler that returns the
>> >>>> stream response.
>> >>>>
>> >>>
>> >>> I haven't mentioned it because my preferred approach is to create a
>> page
>> >>> just for returning StreamResponses. It's more reusable, as it can be
>> used to
>> >>> serve images for any page, while an event must be only used inside a
>> give
>> >>> page.
>> >>>
>> >>>
>> >>
>> >>
>> ------------------------------**------------------------------**---------
>> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
>> users-unsubscribe@tapestry.apache.org>
>> >> For additional commands, e-mail: users-help@tapestry.apache.org
>> >>
>> >>
>> >
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

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


Re: Uploading then displaying Images

Posted by David Canteros <da...@gmail.com>.
Hi Josh;
           I have already tried with PageRenderLinkSource but It has the
same behavior.  I did not know the difference between LinkSource and
PageRenderLinkSource, thanks for the information!

David

------------------------------------------------------------------
David Germán Canteros


2011/8/5 Josh Canfield <jo...@gmail.com>

> Also.
> >    private LinkSource linkSource;
>
> This is an internal class, you should be using PageRenderLinkSource.
> You can replace:
>
> > linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
> false, new Object[]{imageId});
>
> with
>
>
> pageRenderLinkSource.createPageRenderLinkWithContext(DisplayImagePage.class,
> imageId);
>
> Josh
>
> On Fri, Aug 5, 2011 at 1:39 PM, David Canteros
> <da...@gmail.com> wrote:
> > Hi
> > I have to show a image loaded from database BLOB field. I implemented
> > Thiago's suggestion, I have created a page with the following code:
> >
> > public class ShowImagePage {
> >
> >    @Inject
> >    private LinkSource linkSource;
> >     (...)
> >
> >    public Link *getUploadedFile*(String imageId) {
> >            return
> > linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
> > false, new Object[]{imageId});
> >    }
> >
> >    public StreamResponse *onActivate*(String imageId) {
> >        this.filename = imageId;
> >        return new StreamResponse() {
> >
> >            public String *getContentType*() {
> >                return contentType;
> >            }
> >
> >            public InputStream *getStream*() throws IOException {
> >                User user =
> > (User)_request.getSession(true).getAttribute("user");
> >                return user.getImage();
> >            }
> >
> >            public void *prepareResponse*(Response response) {
> >                response.setHeader("Content-Disposition", "inline;
> > filename=" + filename
> >                            + ((extension == null) ? "" : ("." +
> > extension)));
> >            }
> >        };
> >    }
> >  }
> > **
> > In the javacode of the page where i have to show the image, I injected
> the
> > above page and wrote this method
> >
> > public Link *getImageLink*(ImageId){
> >    return showImagewPage.getUploadedFile(imageId);
> > }
> >  and in html code I put this:
> >
> > <img src="${imageLInk}"/>
> >
> > It works fine, the image is showed but when I refresh the page (with F5),
> > the image dissapear. It behavior does not occur if I submit some form
> placed
> > in the same page that refresh the page too (the method  "onSubmitFrom..."
> > returns "this" ). I have debugged the code and everything works fine, do
> you
> > have any idea about this behavior?
> >
> > Thanks!!
> >
> > ------------------------------------------------------------------
> > David Germán Canteros
> >
> >
> > 2011/3/11 Rich M <ri...@moremagic.com>
> >
> >> Thanks everyone for the responses so far, conceptually I think this is
> >> coming together for me.
> >>
> >> So, I'm glad the context path was not a good idea, it felt dirty from
> the
> >> beginning. Avoiding that, there are two main options: use the database
> to
> >> store/retrieve the images, or use a configured system folder from where
> I
> >> can load/save files with Java IO.
> >>
> >> Regardless of the option chosen there, the image file will be captured
> as
> >> an InputStream and returned as a StreamResponse in some form to a
> >> page/component.
> >>
> >> As far as linking the StreamResponse to an HTML IMG tag, I believe I
> >> understand the various options presented here.
> >>
> >> LLTYK suggests using an EventLink. I was looking through my code and
> found
> >> a Captcha implementation I have using a propertyExpression in the TML on
> the
> >> src attribute of <IMG> to reference a getImageLink function that returns
> >> ComponentResources.**createActionLink("image",null)**. Then there is an
> >> onImage() action handler method that returns a StreamResponse. I
> understand
> >> this is ActionLink and not EventLink, but I think the concept must be
> nearly
> >> identical.
> >>
> >> Alternately, Thiago is suggesting that instead of using
> ComponentResources
> >> to generate an ActionLink or EventLink, it may be easier to create a
> >> seperate Page that handles returning just a StreamResponse. In that case
> the
> >> EventLink can be replaced with a PageLink and using an activation
> context
> >> the ID for the Image can be passed to the Page so it can load the Image,
> >> build the StreamResponse, and return it.
> >>
> >> <30 minutes later> Okay, the PageLink works out, great! I can see the
> >> biggest issue I was having was setting up the src attribute for IMG
> >> correctly. I was stuck thinking it was either the URL to the context
> path or
> >> the StreamResponse itself, rather than a link to an event or page that
> >> returns the StreamResponse.
> >>
> >> Thanks,
> >> Rich
> >>
> >>
> >>
> >> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
> >>
> >>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com>
> wrote:
> >>>
> >>>  Nobody's mentioned createEventLink. That's where you get the image
> url,
> >>>> create an event link pointing to the event handler that returns the
> >>>> stream response.
> >>>>
> >>>
> >>> I haven't mentioned it because my preferred approach is to create a
> page
> >>> just for returning StreamResponses. It's more reusable, as it can be
> used to
> >>> serve images for any page, while an event must be only used inside a
> give
> >>> page.
> >>>
> >>>
> >>
> >>
> ------------------------------**------------------------------**---------
> >> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<
> users-unsubscribe@tapestry.apache.org>
> >> For additional commands, e-mail: users-help@tapestry.apache.org
> >>
> >>
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>

Re: Uploading then displaying Images

Posted by Josh Canfield <jo...@gmail.com>.
Also.
>    private LinkSource linkSource;

This is an internal class, you should be using PageRenderLinkSource.
You can replace:

> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(), false, new Object[]{imageId});

with

pageRenderLinkSource.createPageRenderLinkWithContext(DisplayImagePage.class,
imageId);

Josh

On Fri, Aug 5, 2011 at 1:39 PM, David Canteros
<da...@gmail.com> wrote:
> Hi
> I have to show a image loaded from database BLOB field. I implemented
> Thiago's suggestion, I have created a page with the following code:
>
> public class ShowImagePage {
>
>    @Inject
>    private LinkSource linkSource;
>     (...)
>
>    public Link *getUploadedFile*(String imageId) {
>            return
> linkSource.createPageRenderLink(DisplayImagePage.class.getSimpleName(),
> false, new Object[]{imageId});
>    }
>
>    public StreamResponse *onActivate*(String imageId) {
>        this.filename = imageId;
>        return new StreamResponse() {
>
>            public String *getContentType*() {
>                return contentType;
>            }
>
>            public InputStream *getStream*() throws IOException {
>                User user =
> (User)_request.getSession(true).getAttribute("user");
>                return user.getImage();
>            }
>
>            public void *prepareResponse*(Response response) {
>                response.setHeader("Content-Disposition", "inline;
> filename=" + filename
>                            + ((extension == null) ? "" : ("." +
> extension)));
>            }
>        };
>    }
>  }
> **
> In the javacode of the page where i have to show the image, I injected the
> above page and wrote this method
>
> public Link *getImageLink*(ImageId){
>    return showImagewPage.getUploadedFile(imageId);
> }
>  and in html code I put this:
>
> <img src="${imageLInk}"/>
>
> It works fine, the image is showed but when I refresh the page (with F5),
> the image dissapear. It behavior does not occur if I submit some form placed
> in the same page that refresh the page too (the method  "onSubmitFrom..."
> returns "this" ). I have debugged the code and everything works fine, do you
> have any idea about this behavior?
>
> Thanks!!
>
> ------------------------------------------------------------------
> David Germán Canteros
>
>
> 2011/3/11 Rich M <ri...@moremagic.com>
>
>> Thanks everyone for the responses so far, conceptually I think this is
>> coming together for me.
>>
>> So, I'm glad the context path was not a good idea, it felt dirty from the
>> beginning. Avoiding that, there are two main options: use the database to
>> store/retrieve the images, or use a configured system folder from where I
>> can load/save files with Java IO.
>>
>> Regardless of the option chosen there, the image file will be captured as
>> an InputStream and returned as a StreamResponse in some form to a
>> page/component.
>>
>> As far as linking the StreamResponse to an HTML IMG tag, I believe I
>> understand the various options presented here.
>>
>> LLTYK suggests using an EventLink. I was looking through my code and found
>> a Captcha implementation I have using a propertyExpression in the TML on the
>> src attribute of <IMG> to reference a getImageLink function that returns
>> ComponentResources.**createActionLink("image",null)**. Then there is an
>> onImage() action handler method that returns a StreamResponse. I understand
>> this is ActionLink and not EventLink, but I think the concept must be nearly
>> identical.
>>
>> Alternately, Thiago is suggesting that instead of using ComponentResources
>> to generate an ActionLink or EventLink, it may be easier to create a
>> seperate Page that handles returning just a StreamResponse. In that case the
>> EventLink can be replaced with a PageLink and using an activation context
>> the ID for the Image can be passed to the Page so it can load the Image,
>> build the StreamResponse, and return it.
>>
>> <30 minutes later> Okay, the PageLink works out, great! I can see the
>> biggest issue I was having was setting up the src attribute for IMG
>> correctly. I was stuck thinking it was either the URL to the context path or
>> the StreamResponse itself, rather than a link to an event or page that
>> returns the StreamResponse.
>>
>> Thanks,
>> Rich
>>
>>
>>
>> On 03/11/2011 08:08 AM, Thiago H. de Paula Figueiredo wrote:
>>
>>> On Fri, 11 Mar 2011 09:24:35 -0300, LLTYK <LL...@mailinator.com> wrote:
>>>
>>>  Nobody's mentioned createEventLink. That's where you get the image url,
>>>> create an event link pointing to the event handler that returns the
>>>> stream response.
>>>>
>>>
>>> I haven't mentioned it because my preferred approach is to create a page
>>> just for returning StreamResponses. It's more reusable, as it can be used to
>>> serve images for any page, while an event must be only used inside a give
>>> page.
>>>
>>>
>>
>> ------------------------------**------------------------------**---------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.**apache.org<us...@tapestry.apache.org>
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>

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