You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Josh Canfield <jo...@thedailytube.com> on 2007/09/20 09:06:40 UTC
[T5] Rendering a page into a String
I'm toying with the following code in my app:
@Inject
private PageRenderRequestHandler _pageRenderRequestHandler;
@Inject
private ComponentResources _resources;
@Inject
private RequestGlobals _requestGlobals;
protected void onSend() {
Request request = _requestGlobals.getRequest();
Response response = _requestGlobals.getResponse();
EmailResponse emailResponse = new EmailResponse(_requestGlobals
.getHTTPServletResponse());
_requestGlobals.store(request, emailResponse);
_pageRenderRequestHandler.handle("bestoftoday", null);
_requestGlobals.store(request, response);
System.out.print(emailResponse.getOutputStream(null).toString());
}
At the moment the EmailResponse simply implements the Response interface and
stuffs everything into a ByteArrayOutputStream so I can get them out later.
I need to be able to render a page and send it out via email, I'd rather not
add another templating technology to recreate a page that exists on the
website.
How far off the reservation am I with this? It works, happily prints the
html to the console and then renders the page with the action. I'm only
using public APIs, so am I safe?
Josh
--
--
TheDailyTube.com. Sign up and get the best new videos on the internet
delivered fresh to your inbox.