You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Dmitry Shyshkin <sh...@devoler.com> on 2008/03/15 16:11:57 UTC

T5: Now to generate page with binary output

Hello, all

I want to generate image by tapestry page. Follow code successfully set 
Content-Type and output image data, but after that  exception is thrown :
java.lang.RuntimeException: Page resource/Image did not generate any 
markup when rendered. This could be because its template file could not 
be located, or because a render phase method in the page prevented 
rendering.

Is there is a way to tell tapestry that page output is binary and 
ResposeWriter won't be used for generation? I've thought about 
StreamResponse but it accepted only from action events, not from render 
phase events.

    @Inject
    private Response _response;

    @BeginRender
    void render() throws IOException {
        Image image = ...;
        IOUtil.transfer(image.getImage().getBinaryStream(), 
_response.getOutputStream(image.getContentType()));
    }


Thanks,
Dmitry


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


Re: T5: Now to generate page with binary output

Posted by Josh Canfield <jo...@thedailytube.com>.
Take a look at the wiki:
http://wiki.apache.org/tapestry/Tapestry5HowToCreateASimpleGraphComponent

Since you aren't actually going to be injecting the image bytes into
the page your images are going to be loaded in a second request.  You
can create an action link that actually returns the image bytes.

Deciding whether to create the image in the page render request, or in
the action request is up to you. A challenge with doing it in the page
render request is where to hold the bytes until the next request comes
in (that could be a lot of data to hold in the session). Otherwise you
can store the data used to generate the image, which also might be a
lot of data...


Josh

On Tue, Apr 15, 2008 at 3:03 AM, Sven Homburg <ho...@googlemail.com> wrote:
> i developed an component that genereates thumbnails of an gif/jpeg
> via Toolkit graphic methodes.
>
> after that the converted stream should injected into the page.
>
> 2008/4/15, Josh Canfield <jo...@thedailytube.com>:
>
> >
> > Why are you generating a binary stream during the render phase?
> >
> >
> > On Mon, Apr 14, 2008 at 3:55 PM, Sven Homburg <ho...@googlemail.com>
> > wrote:
> > > but how do i return a binary stream, that generated at render phase.
> > >
> > >
> > > 2008/3/17, Josh Canfield <jo...@thedailytube.com>:
> > >
> > > >
> > > > You need to return a StreamResponse
> > > >
> > > >
> > > >
> > http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/StreamResponse.html
> > > >
> > > > Also, check out the following for an example.
> > > >
> > > >
> > http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile
> > > > Josh
> > > >
> > > >
> > > > On Sat, Mar 15, 2008 at 8:11 AM, Dmitry Shyshkin <shyshkin@devoler.com
> > >
> > > > wrote:
> > > > > Hello, all
> > > > >
> > > > > I want to generate image by tapestry page. Follow code successfully
> > set
> > > > > Content-Type and output image data, but after that  exception is
> > thrown
> > > > :
> > > > > java.lang.RuntimeException: Page resource/Image did not generate any
> > > > > markup when rendered. This could be because its template file could
> > not
> > > > > be located, or because a render phase method in the page prevented
> > > > > rendering.
> > > > >
> > > > > Is there is a way to tell tapestry that page output is binary and
> > > > > ResposeWriter won't be used for generation? I've thought about
> > > > > StreamResponse but it accepted only from action events, not from
> > render
> > > > > phase events.
> > > > >
> > > > >    @Inject
> > > > >    private Response _response;
> > > > >
> > > > >    @BeginRender
> > > > >    void render() throws IOException {
> > > > >        Image image = ...;
> > > > >        IOUtil.transfer(image.getImage().getBinaryStream(),
> > > > > _response.getOutputStream(image.getContentType()));
> > > > >    }
> > > > >
> > > > >
> > > > > Thanks,
> > > > > Dmitry
> > > > >
> > > > >
> > > > >
> > ---------------------------------------------------------------------
> > > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > > >
> > > > >
> > > >
> > > >
> > > >
> > > >
> > > > --
> > > >
> > > > --
> > > > TheDailyTube.com. Sign up and get the best new videos on the internet
> > > > delivered fresh to your inbox.
> > > >
> > > >
> > > > ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > > --
> > > with regards
> > > Sven Homburg
> > > http://tapestry5-components.googlecode.com
> > >
> >
> >
> >
> >
> > --
> >
> > --
> > TheDailyTube.com. Sign up and get the best new videos on the internet
> > delivered fresh to your inbox.
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: T5: Now to generate page with binary output

Posted by Sven Homburg <ho...@googlemail.com>.
i developed an component that genereates thumbnails of an gif/jpeg
via Toolkit graphic methodes.

after that the converted stream should injected into the page.

2008/4/15, Josh Canfield <jo...@thedailytube.com>:
>
> Why are you generating a binary stream during the render phase?
>
>
> On Mon, Apr 14, 2008 at 3:55 PM, Sven Homburg <ho...@googlemail.com>
> wrote:
> > but how do i return a binary stream, that generated at render phase.
> >
> >
> > 2008/3/17, Josh Canfield <jo...@thedailytube.com>:
> >
> > >
> > > You need to return a StreamResponse
> > >
> > >
> > >
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/StreamResponse.html
> > >
> > > Also, check out the following for an example.
> > >
> > >
> http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile
> > > Josh
> > >
> > >
> > > On Sat, Mar 15, 2008 at 8:11 AM, Dmitry Shyshkin <shyshkin@devoler.com
> >
> > > wrote:
> > > > Hello, all
> > > >
> > > > I want to generate image by tapestry page. Follow code successfully
> set
> > > > Content-Type and output image data, but after that  exception is
> thrown
> > > :
> > > > java.lang.RuntimeException: Page resource/Image did not generate any
> > > > markup when rendered. This could be because its template file could
> not
> > > > be located, or because a render phase method in the page prevented
> > > > rendering.
> > > >
> > > > Is there is a way to tell tapestry that page output is binary and
> > > > ResposeWriter won't be used for generation? I've thought about
> > > > StreamResponse but it accepted only from action events, not from
> render
> > > > phase events.
> > > >
> > > >    @Inject
> > > >    private Response _response;
> > > >
> > > >    @BeginRender
> > > >    void render() throws IOException {
> > > >        Image image = ...;
> > > >        IOUtil.transfer(image.getImage().getBinaryStream(),
> > > > _response.getOutputStream(image.getContentType()));
> > > >    }
> > > >
> > > >
> > > > Thanks,
> > > > Dmitry
> > > >
> > > >
> > > >
> ---------------------------------------------------------------------
> > > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > > For additional commands, e-mail: users-help@tapestry.apache.org
> > > >
> > > >
> > >
> > >
> > >
> > >
> > > --
> > >
> > > --
> > > TheDailyTube.com. Sign up and get the best new videos on the internet
> > > delivered fresh to your inbox.
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> > --
> > with regards
> > Sven Homburg
> > http://tapestry5-components.googlecode.com
> >
>
>
>
>
> --
>
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com

Re: T5: Now to generate page with binary output

Posted by Josh Canfield <jo...@thedailytube.com>.
Why are you generating a binary stream during the render phase?

On Mon, Apr 14, 2008 at 3:55 PM, Sven Homburg <ho...@googlemail.com> wrote:
> but how do i return a binary stream, that generated at render phase.
>
>
> 2008/3/17, Josh Canfield <jo...@thedailytube.com>:
>
> >
> > You need to return a StreamResponse
> >
> >
> > http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/StreamResponse.html
> >
> > Also, check out the following for an example.
> >
> > http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile
> > Josh
> >
> >
> > On Sat, Mar 15, 2008 at 8:11 AM, Dmitry Shyshkin <sh...@devoler.com>
> > wrote:
> > > Hello, all
> > >
> > > I want to generate image by tapestry page. Follow code successfully set
> > > Content-Type and output image data, but after that  exception is thrown
> > :
> > > java.lang.RuntimeException: Page resource/Image did not generate any
> > > markup when rendered. This could be because its template file could not
> > > be located, or because a render phase method in the page prevented
> > > rendering.
> > >
> > > Is there is a way to tell tapestry that page output is binary and
> > > ResposeWriter won't be used for generation? I've thought about
> > > StreamResponse but it accepted only from action events, not from render
> > > phase events.
> > >
> > >    @Inject
> > >    private Response _response;
> > >
> > >    @BeginRender
> > >    void render() throws IOException {
> > >        Image image = ...;
> > >        IOUtil.transfer(image.getImage().getBinaryStream(),
> > > _response.getOutputStream(image.getContentType()));
> > >    }
> > >
> > >
> > > Thanks,
> > > Dmitry
> > >
> > >
> > > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > > For additional commands, e-mail: users-help@tapestry.apache.org
> > >
> > >
> >
> >
> >
> >
> > --
> >
> > --
> > TheDailyTube.com. Sign up and get the best new videos on the internet
> > delivered fresh to your inbox.
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
> --
> with regards
> Sven Homburg
> http://tapestry5-components.googlecode.com
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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


Re: T5: Now to generate page with binary output

Posted by Thiago HP <th...@gmail.com>.
On 4/14/08, Sven Homburg <ho...@googlemail.com> wrote:
> but how do i return a binary stream, that generated at render phase.

Return your StreamResponse, just like in the wiki example cited
earlier, in an onActivate() method. ;)

-- 
Thiago

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


Re: T5: Now to generate page with binary output

Posted by Sven Homburg <ho...@googlemail.com>.
but how do i return a binary stream, that generated at render phase.


2008/3/17, Josh Canfield <jo...@thedailytube.com>:
>
> You need to return a StreamResponse
>
>
> http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/StreamResponse.html
>
> Also, check out the following for an example.
>
> http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile
> Josh
>
>
> On Sat, Mar 15, 2008 at 8:11 AM, Dmitry Shyshkin <sh...@devoler.com>
> wrote:
> > Hello, all
> >
> > I want to generate image by tapestry page. Follow code successfully set
> > Content-Type and output image data, but after that  exception is thrown
> :
> > java.lang.RuntimeException: Page resource/Image did not generate any
> > markup when rendered. This could be because its template file could not
> > be located, or because a render phase method in the page prevented
> > rendering.
> >
> > Is there is a way to tell tapestry that page output is binary and
> > ResposeWriter won't be used for generation? I've thought about
> > StreamResponse but it accepted only from action events, not from render
> > phase events.
> >
> >    @Inject
> >    private Response _response;
> >
> >    @BeginRender
> >    void render() throws IOException {
> >        Image image = ...;
> >        IOUtil.transfer(image.getImage().getBinaryStream(),
> > _response.getOutputStream(image.getContentType()));
> >    }
> >
> >
> > Thanks,
> > Dmitry
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> > For additional commands, e-mail: users-help@tapestry.apache.org
> >
> >
>
>
>
>
> --
>
> --
> TheDailyTube.com. Sign up and get the best new videos on the internet
> delivered fresh to your inbox.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>


-- 
with regards
Sven Homburg
http://tapestry5-components.googlecode.com

Re: T5: Now to generate page with binary output

Posted by Josh Canfield <jo...@thedailytube.com>.
You need to return a StreamResponse

http://tapestry.apache.org/tapestry5/apidocs/org/apache/tapestry/StreamResponse.html

Also, check out the following for an example.

http://wiki.apache.org/tapestry/Tapestry5HowToStreamAnExistingBinaryFile
Josh

On Sat, Mar 15, 2008 at 8:11 AM, Dmitry Shyshkin <sh...@devoler.com> wrote:
> Hello, all
>
> I want to generate image by tapestry page. Follow code successfully set
> Content-Type and output image data, but after that  exception is thrown :
> java.lang.RuntimeException: Page resource/Image did not generate any
> markup when rendered. This could be because its template file could not
> be located, or because a render phase method in the page prevented
> rendering.
>
> Is there is a way to tell tapestry that page output is binary and
> ResposeWriter won't be used for generation? I've thought about
> StreamResponse but it accepted only from action events, not from render
> phase events.
>
>    @Inject
>    private Response _response;
>
>    @BeginRender
>    void render() throws IOException {
>        Image image = ...;
>        IOUtil.transfer(image.getImage().getBinaryStream(),
> _response.getOutputStream(image.getContentType()));
>    }
>
>
> Thanks,
> Dmitry
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.

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