Re: Render Tapestry pages into a file

2006-07-31 Thread KE Gan

Jesse, thanks for the fast reply (as always :))

If I were to use the ResponseBuilder approach, that means Tapestry will
cache the pages. And since the pages are submitted (and modified) by users
from time to time (as mentioned in earlier post), how can I clear the cache
for a specific pages ? Is that possible ?

Thanks.


On 7/31/06, Jesse Kuhnert [EMAIL PROTECTED] wrote:


I would take a look at the new ResponseBuilder interface provided in 4.1.
Though it's still possible to do in tapestry 4, the new rendering logic
would make it very easy for you to capture the output of a page render and
do whatever you like with it.

It's also something you can control with a hivemind contribution, so
overriding the default html response renderer wouldn't be very hard
either.

http://tapestry.apache.org/tapestry4.1/ajax/ResponseBuilder.html

On 7/30/06, KE Gan [EMAIL PROTECTED] wrote:

 Hi,

 I am working on a Tapestry application that has over hundreds Tapestry
 HTML
 pages, all sharing one single Java class file. These Tapestry HTML pages
 are
 submitted by users from time to time ... so they are not immediately in
 the
 web application, and they may change from time to time.

 The thing is, I would like to render these Tapestry pages into files
 (instead of normally output the the HTTP stream). I have thought of 3
ways
 of doing this, but I feel they may not be the right way or maybe not
 possible, ... so wonder if more experience Tapestry guys here can give
 some
 advice.

 (Method 1) The Tapestry HTML pages submitted by users are put into web
 accessible directory in the web application. Then access the file using
 libraries such as Apache Common HttpClient from the web application
 itself,
 then save the output stream data, and write them to files.

 This approach has one problem. Since the Tapestry HTML pages are cached
by
 Tapestry, and user may submit modified Tapestry HTML pages (with the
same
 filename) in the future, these modified Tapestry HTML pages will not be
 loaded anymore. I could still clear the Tapestry cache, but that would
 clear
 the cache for the whole web application (something not desired).

 So I feel this approach is probably the least possible.

 (Method 2) Instantiate a separate 'Tapestry rendering engine' inside the
 web
 application. Use the object to render the user submitted Tapestry HTML
 pages
 and save the output to files.

 Is this possible? How to do it? I tried to trace into the Tapestry
source
 code, but the complexity of PageLoader is just beyond me. It seems to
 be tightly tied into Tapestry as a whole.

 Then again, how possible is it? I kinda feel this is the best way. Am I
on
 the right path?

 (Method 3) Write my own rendering engine. Since the user submitted
 Tapestry
 HTML Pages will only use minimum set of Tapestry components such as
 Insert,
 TextInsert, and For (these can be made a requirement). So essentially, I
 will have dom4j read the HTML structure, and replace the appropriate
data
 where 'jwcid' appears. And finally write the processed DOM into files.


 If you have read until here for this long post, thank you very much :)
Any
 hint and pointers will be greatly appreciated.

 ~KEGan




--
Jesse Kuhnert
Tacos/Tapestry, team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind.




Re: Render Tapestry pages into a file

2006-07-30 Thread Jesse Kuhnert

I would take a look at the new ResponseBuilder interface provided in 4.1.
Though it's still possible to do in tapestry 4, the new rendering logic
would make it very easy for you to capture the output of a page render and
do whatever you like with it.

It's also something you can control with a hivemind contribution, so
overriding the default html response renderer wouldn't be very hard either.

http://tapestry.apache.org/tapestry4.1/ajax/ResponseBuilder.html

On 7/30/06, KE Gan [EMAIL PROTECTED] wrote:


Hi,

I am working on a Tapestry application that has over hundreds Tapestry
HTML
pages, all sharing one single Java class file. These Tapestry HTML pages
are
submitted by users from time to time ... so they are not immediately in
the
web application, and they may change from time to time.

The thing is, I would like to render these Tapestry pages into files
(instead of normally output the the HTTP stream). I have thought of 3 ways
of doing this, but I feel they may not be the right way or maybe not
possible, ... so wonder if more experience Tapestry guys here can give
some
advice.

(Method 1) The Tapestry HTML pages submitted by users are put into web
accessible directory in the web application. Then access the file using
libraries such as Apache Common HttpClient from the web application
itself,
then save the output stream data, and write them to files.

This approach has one problem. Since the Tapestry HTML pages are cached by
Tapestry, and user may submit modified Tapestry HTML pages (with the same
filename) in the future, these modified Tapestry HTML pages will not be
loaded anymore. I could still clear the Tapestry cache, but that would
clear
the cache for the whole web application (something not desired).

So I feel this approach is probably the least possible.

(Method 2) Instantiate a separate 'Tapestry rendering engine' inside the
web
application. Use the object to render the user submitted Tapestry HTML
pages
and save the output to files.

Is this possible? How to do it? I tried to trace into the Tapestry source
code, but the complexity of PageLoader is just beyond me. It seems to
be tightly tied into Tapestry as a whole.

Then again, how possible is it? I kinda feel this is the best way. Am I on
the right path?

(Method 3) Write my own rendering engine. Since the user submitted
Tapestry
HTML Pages will only use minimum set of Tapestry components such as
Insert,
TextInsert, and For (these can be made a requirement). So essentially, I
will have dom4j read the HTML structure, and replace the appropriate data
where 'jwcid' appears. And finally write the processed DOM into files.


If you have read until here for this long post, thank you very much :) Any
hint and pointers will be greatly appreciated.

~KEGan





--
Jesse Kuhnert
Tacos/Tapestry, team member/developer

Open source based consulting work centered around
dojo/tapestry/tacos/hivemind.