You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Bob Stine <bo...@waltonstine.net> on 2004/04/14 18:38:04 UTC

replacing Insert component with RenderBody?

We have an app that uses the �Insert� component to allow a user to download an XML document.  Our IMarkupWriter implementation returns a document type of �text/myXmlDownload� � the important thing is that Internet Explorer doesn�t recognize the type, so it pops up its default �save document� dialog.

 

We�ve hit a problem: with really big XML documents, we are getting a buffer overflow exception in the Insert component.  In particular, the exception occurred during creation of the Insert component, when Tapestry tried to evaluate the �value� object, which we were creating by a String constructor that takes a byte array as input.

 

The Insert component uses the �toString� method to get the text that it renders, so it looks like we need to do something different.

 

I was thinking that Block and RenderBlock would be likely alternatives.  Is this so?

 

Even if using Block and RenderBlock is the way to go, I�m at a bit of a loss on how to start.  Will I need a .jwc file for my implementation of Block?  And do I need to subclass Block and override the �renderComponent� method?  (The documentation on this method suggests that it is never called in Block components.)

 

Also, do I override the getResponseWriter(OutputStream out) method of the DocumentPage that emits the �text/myXmlDownload� content so that it ignores the OutputStream parameter that is passed to it, and instead creates a new instance of our implementation of IMarkupWriter that uses an instance of ByteArrayOutputStream? 

 

I�m using Tapestry 2.3.

 

Thanks!




___
Bob Stine
bob@waltonstine.net 
"Let's roll!"  Todd Beamer, UA flight 93


RE: replacing Insert component with RenderBody? ("Delegate" works for me.)

Posted by Bob Stine <bo...@waltonstine.net>.
Using the "Delegate" component works just fine.  
 
Since I'm actually just using Http as a transport protocol for an XML file, I simply get the HttpResponse instance associated with the request, set its content type to "text/myXmlFormat", get an OutputStream from the reponse, and output the byte[] instance that contains the XML.



___
Bob Stine
bob@waltonstine.net 
"Let's roll!"  Todd Beamer, UA flight 93


RE: replacing Insert component with RenderBody?

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
> -----Original Message-----
> From: jason@obiwan.homelinux.org [mailto:jason@obiwan.homelinux.org] 
> Sent: Wednesday, April 14, 2004 12:43 PM
> To: Tapestry users
> Subject: Re: replacing Insert component with RenderBody?
> 
> 
> Bob,
> 
> Have you tried implementing this as a Service instead of a 
> Page?  I have
> a tapestry app which (among other things) pulls rather large 
> XML docs out
> of a database, and the Service based approach has worked 
> great. (plus, changing
> the content-type is as straight-forward as it would have been 
> in a servlet in the
> first place)  Also, if your XML source can be obtained as a 
> stream, you may see some
> performance/memory usage improvements since you can stream 
> directly out to the
> browser instead of building everything up into a String first.
> 
> -jason
> 
> 

Very good point actually!  It is also common to combine a custom service with a custom component
that creates the link (or whatever) to the service.

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
Creator, HiveMind
http://howardlewisship.com



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


Re: replacing Insert component with RenderBody?

Posted by ja...@obiwan.homelinux.org.
Bob,

Have you tried implementing this as a Service instead of a Page?  I have
a tapestry app which (among other things) pulls rather large XML docs out
of a database, and the Service based approach has worked great. (plus, changing
the content-type is as straight-forward as it would have been in a servlet in the
first place)  Also, if your XML source can be obtained as a stream, you may see some
performance/memory usage improvements since you can stream directly out to the
browser instead of building everything up into a String first.

-jason


On Wed, Apr 14, 2004 at 09:38:04AM -0700, Bob Stine wrote:
> 
> We have an app that uses the ?Insert? component to allow a user to download an XML document.  Our IMarkupWriter implementation returns a document type of ?text/myXmlDownload? ? the important thing is that Internet Explorer doesn?t recognize the type, so it pops up its default ?save document? dialog.
> 
>  
> 
> We?ve hit a problem: with really big XML documents, we are getting a buffer overflow exception in the Insert component.  In particular, the exception occurred during creation of the Insert component, when Tapestry tried to evaluate the ?value? object, which we were creating by a String constructor that takes a byte array as input.
> 
>  
> 
> The Insert component uses the ?toString? method to get the text that it renders, so it looks like we need to do something different.
> 
>  
> 
> I was thinking that Block and RenderBlock would be likely alternatives.  Is this so?
> 
>  
> 
> Even if using Block and RenderBlock is the way to go, I?m at a bit of a loss on how to start.  Will I need a .jwc file for my implementation of Block?  And do I need to subclass Block and override the ?renderComponent? method?  (The documentation on this method suggests that it is never called in Block components.)
> 
>  
> 
> Also, do I override the getResponseWriter(OutputStream out) method of the DocumentPage that emits the ?text/myXmlDownload? content so that it ignores the OutputStream parameter that is passed to it, and instead creates a new instance of our implementation of IMarkupWriter that uses an instance of ByteArrayOutputStream? 
> 
>  
> 
> I?m using Tapestry 2.3.
> 
>  
> 
> Thanks!
> 
> 
> 
> 
> ___
> Bob Stine
> bob@waltonstine.net 
> "Let's roll!"  Todd Beamer, UA flight 93
> 

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


RE: replacing Insert component with RenderBody?

Posted by "Howard M. Lewis Ship" <hl...@comcast.net>.
I would suggest Delegator, you delegate object (which implements IRender) and do a more controlled,
incremental navigation of your DOM tree to generate the final output streamed to the client.

--
Howard M. Lewis Ship
Independent J2EE / Open-Source Java Consultant
Creator, Tapestry: Java Web Components 
Creator, HiveMind
http://howardlewisship.com


> -----Original Message-----
> From: Bob Stine [mailto:bob@waltonstine.net] 
> Sent: Wednesday, April 14, 2004 12:38 PM
> To: tapestry-user@jakarta.apache.org
> Subject: replacing Insert component with RenderBody?
> 
> 
> 
> We have an app that uses the "Insert" component to allow a 
> user to download an XML document.  Our IMarkupWriter 
> implementation returns a document type of 
> "text/myXmlDownload" - the important thing is that Internet 
> Explorer doesn't recognize the type, so it pops up its 
> default "save document" dialog.
> 
>  
> 
> We've hit a problem: with really big XML documents, we are 
> getting a buffer overflow exception in the Insert component.  
> In particular, the exception occurred during creation of the 
> Insert component, when Tapestry tried to evaluate the "value" 
> object, which we were creating by a String constructor that 
> takes a byte array as input.
> 
>  
> 
> The Insert component uses the "toString" method to get the 
> text that it renders, so it looks like we need to do 
> something different.
> 
>  
> 
> I was thinking that Block and RenderBlock would be likely 
> alternatives.  Is this so?
> 
>  
> 
> Even if using Block and RenderBlock is the way to go, I'm at 
> a bit of a loss on how to start.  Will I need a .jwc file for 
> my implementation of Block?  And do I need to subclass Block 
> and override the "renderComponent" method?  (The 
> documentation on this method suggests that it is never called 
> in Block components.)
> 
>  
> 
> Also, do I override the getResponseWriter(OutputStream out) 
> method of the DocumentPage that emits the 
> "text/myXmlDownload" content so that it ignores the 
> OutputStream parameter that is passed to it, and instead 
> creates a new instance of our implementation of IMarkupWriter 
> that uses an instance of ByteArrayOutputStream? 
> 
>  
> 
> I'm using Tapestry 2.3.
> 
>  
> 
> Thanks!
> 
> 
> 
> 
> ___
> Bob Stine
> bob@waltonstine.net 
> "Let's roll!"  Todd Beamer, UA flight 93
> 
> 


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