Re: T5 - Stream source output to text file

2007-12-03 Thread Christopher Ottley
You could keep it all Java (closer to the App Server is a good idea)
and use the Apache HTTPClient to make the HTTP request.

http://jakarta.apache.org/httpcomponents/httpcomponents-client/index.html

Christopher.

On Dec 3, 2007 11:35 PM, Daniel Jue <[EMAIL PROTECTED]> wrote:
> I guess the next step is to simulate the HTTP request and then grab
> the output from it.  For generating html emails you wouldn't want to
> do any interaction through the web browser to initiate the page
> creation.
>
> Maybe the wget approach is a good angle of attack, but needs to be
> closer to the App Server.  Perhaps there is a website load testing
> tool that simulates requests/allows variables to be set that could be
> run on the same or different application server.  Totally independent
> of Tapestry, like wget.  The response can then be cat'd to the
> emailing service/print ad/fax machine, etc.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 - Stream source output to text file

2007-12-03 Thread Daniel Jue
I guess the next step is to simulate the HTTP request and then grab
the output from it.  For generating html emails you wouldn't want to
do any interaction through the web browser to initiate the page
creation.

Maybe the wget approach is a good angle of attack, but needs to be
closer to the App Server.  Perhaps there is a website load testing
tool that simulates requests/allows variables to be set that could be
run on the same or different application server.  Totally independent
of Tapestry, like wget.  The response can then be cat'd to the
emailing service/print ad/fax machine, etc.

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 - Stream source output to text file

2007-12-03 Thread Christopher Ottley
I did some research on something similar for my Buccoo project.
Although I haven't blogged about it yet, my method it may be of some
use to you.

For Buccoo I wanted all the dynamic Tapestry output to be well formed
XML. It is my understanding that components add their own HTML code at
different stages (like links to stylesheets and javascript for the
form validation) that I can't directly modify (or really want to). To
get the final output in XML no matter what, I had to decorate the page
response in the AppModule, render the page and then convert it to the
output I wanted.

You could stop at the render page part and stream the output to the
text file you wanted.

I'm filtering the pages I want converted using the content type, but
you can use the page name etc. You would not need the TagsoupService I
injected in my code below.

You may also want to look at Tapestry 5's source for the
PageResponseRenderer's renderPageResponse method.

public static PageResponseRenderer decoratePageResponseRenderer(
@InjectService("PageMarkupRenderer") final PageMarkupRenderer
markupRenderer,
@InjectService("MarkupWriterFactory") final
MarkupWriterFactory markupWriterFactory,
@InjectService("MetaDataLocator") final MetaDataLocator metaDataLocator,
@InjectService("TagsoupService") final TagsoupService tagsoupService,
final Object delegate)
{
return new PageResponseRenderer()
{
public void renderPageResponse(Page page, Response
response) throws IOException
{
ComponentResources pageResources =
page.getRootComponent().getComponentResources();

String contentTypeString =
metaDataLocator.findMeta(TapestryConstants.RESPONSE_CONTENT_TYPE,

pageResources);
ContentType contentType = new ContentType(contentTypeString);

// Make sure there's always a charset specified.

String encoding = contentType.getParameter(CHARSET);
if (encoding == null)
{
  encoding =
metaDataLocator.findMeta(TapestryConstants.RESPONSE_ENCODING,
pageResources);
  contentType.setParameter(CHARSET, encoding);
}

MarkupWriter writer = markupWriterFactory.newMarkupWriter();
markupRenderer.renderPageMarkup(page, writer);

String finalContentType = contentType.toString();
finalContentType =
finalContentType.replace("application/xhtml+xml", "text/html");

PrintWriter pw = response.getPrintWriter(finalContentType);


if (contentTypeString.equals("application/xhtml+xml")) {
  StringWriter sw = new StringWriter();
  PrintWriter spw = new PrintWriter(sw);
  writer.toMarkup(spw);
  spw.flush();
  spw.close();
  pw.print(tagsoupService.asXML(sw.toString()));
} else if (contentTypeString.equals("text/xml")) {
  StringWriter sw = new StringWriter();
  PrintWriter spw = new PrintWriter(sw);
  writer.toMarkup(spw);
  spw.flush();
  spw.close();
  pw.print("\r\n" + sw.toString());
} else {
  writer.toMarkup(pw);
}
pw.flush();
}
};
}


On Dec 3, 2007 2:11 PM, Josh Canfield <[EMAIL PROTECTED]> wrote:
> I've done something like what you are asking in order to generate email
> messages. It's not pretty, and not well supported but it can be done...
>
> Here is the guts of the process:
>
> protected String getHtml(String page, String[] context, EmailContext
> emailContext) {
> Request request = _requestGlobals.getRequest();
> Response response = _requestGlobals.getResponse();
> // response wrapper stores everything written into a buffer
> EmailResponse emailResponse = new
> EmailResponse(_requestGlobals.getHTTPServletResponse());
> _requestGlobals.store(request, emailResponse);
> // email context contains some parameters passed into the rendered
> page
> request.getSession(true).setAttribute("emailContext", emailContext);
> // pageRenderRequestHandler clears the environment... remember
> things to put back later (fragile)...
> Heartbeat heartbeat = _environment.peek(Heartbeat.class);
> FormSupport formSupport = _environment.peek(FormSupport.class);
> try {
> _pageRenderRequestHandler.handle(page, context);
> return emailResponse.toString();
> } catch (Exception e) {
> _log.warn("Failed to send video external " + e.getMessage());
> } finally {
> // Hope no other env vars are stored :(
> _environment.push(Heartbeat.class, heartbeat);
> _environment.push(FormSupport.class, formSupport);

Re: T5 - Stream source output to text file

2007-12-03 Thread Andy Huhn
It's not elegant, but you could use a command-line tool like "wget".

Andy

On Mon, 2007-12-03 at 08:41 -0800, patrick whalen wrote:
> Could anyone give me any pointers or directions on how to stream the html
> output that Tapestry generates out to a text file, which would be stored in
> a specific directory outside the Tapestry project?
> 
> I would also like to be able to do the same with assets such as css and
> javascript files, though this would be less important, and more of a
> convenience.
> 
> Any hints and suggestions are appreciated.
> 
> Thanks much.patrick

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: T5 - Stream source output to text file

2007-12-03 Thread Josh Canfield
I've done something like what you are asking in order to generate email
messages. It's not pretty, and not well supported but it can be done...

Here is the guts of the process:

protected String getHtml(String page, String[] context, EmailContext
emailContext) {
Request request = _requestGlobals.getRequest();
Response response = _requestGlobals.getResponse();
// response wrapper stores everything written into a buffer
EmailResponse emailResponse = new
EmailResponse(_requestGlobals.getHTTPServletResponse());
_requestGlobals.store(request, emailResponse);
// email context contains some parameters passed into the rendered
page
request.getSession(true).setAttribute("emailContext", emailContext);
// pageRenderRequestHandler clears the environment... remember
things to put back later (fragile)...
Heartbeat heartbeat = _environment.peek(Heartbeat.class);
FormSupport formSupport = _environment.peek(FormSupport.class);
try {
_pageRenderRequestHandler.handle(page, context);
return emailResponse.toString();
} catch (Exception e) {
_log.warn("Failed to send video external " + e.getMessage());
} finally {
// Hope no other env vars are stored :(
_environment.push(Heartbeat.class, heartbeat);
_environment.push(FormSupport.class, formSupport);

// Always restore the response
_requestGlobals.store(request, response);
request.getSession(true).setAttribute("emailContext", null);
}
return null;
}
This code is used to generate the html version of all email messages sent by
thedailytube.com

Hope that helps,
Josh




On Dec 3, 2007 8:41 AM, patrick whalen <[EMAIL PROTECTED]> wrote:

>
> Could anyone give me any pointers or directions on how to stream the html
> output that Tapestry generates out to a text file, which would be stored
> in
> a specific directory outside the Tapestry project?
>
> I would also like to be able to do the same with assets such as css and
> javascript files, though this would be less important, and more of a
> convenience.
>
> Any hints and suggestions are appreciated.
>
> Thanks much.patrick
> --
> View this message in context:
> http://www.nabble.com/T5---Stream-source-output-to-text-file-tf4937616.html#a14133292
> Sent from the Tapestry - User mailing list archive at 
> Nabble.com
> .
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>


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


Re: T5 - Stream source output to text file

2007-12-03 Thread Daniel Jue
I don't know if this can be done, although it would be great!  It
would open the doors for sending Tapestry generated html emails, which
others have asked about.  Also it would be easier to do rigorous html
code testing/profiling, since it's outside the browser.

On Dec 3, 2007 11:41 AM, patrick whalen <[EMAIL PROTECTED]> wrote:
>
> Could anyone give me any pointers or directions on how to stream the html
> output that Tapestry generates out to a text file, which would be stored in
> a specific directory outside the Tapestry project?
>
> I would also like to be able to do the same with assets such as css and
> javascript files, though this would be less important, and more of a
> convenience.
>
> Any hints and suggestions are appreciated.
>
> Thanks much.patrick
> --
> View this message in context: 
> http://www.nabble.com/T5---Stream-source-output-to-text-file-tf4937616.html#a14133292
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
>
> -
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
>
>

-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]