You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Mark Lilly <mi...@tinorb.com> on 2004/08/24 19:30:59 UTC
Including HTML pages within other pages
Hi,
I have been struggling to find a simple equivalent to a JSP or PHP include
statement. I sometimes create content in DocBook, transform it into HTML, and
want that content to be included on a named Tapestry page.
The best way i came up with is to:
1. create a context-asset with a local path to the HTML page
2. create a <span jwcid="@Insert" value="ognl:content" raw="true"/>
3. create a Java getter/setter for content, and in the getContent() method, i
do the following:
a. getAsset by the asset's name
b. call buildURL on the asset to get its local path
c. parse that to create a file system path
d. use Java to open the HTML file directly
e. read the contents of the HTML file into a buffer
f. return the buffer as a string to Tapestry, which renders it on the page.
Compared to a simple "include" statement, this is a lot of work.
Is there a better way? I've searched through the archives and haven't found
one.
Thanks,
mark
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: Including HTML pages within other pages
Posted by Erik Hatcher <er...@ehatchersolutions.com>.
On Aug 24, 2004, at 12:30 PM, Mark Lilly wrote:
> Hi,
> I have been struggling to find a simple equivalent to a JSP or PHP
> include
> statement. I sometimes create content in DocBook, transform it into
> HTML, and
> want that content to be included on a named Tapestry page.
>
> The best way i came up with is to:
> 1. create a context-asset with a local path to the HTML page
> 2. create a <span jwcid="@Insert" value="ognl:content" raw="true"/>
> 3. create a Java getter/setter for content, and in the getContent()
> method, i
> do the following:
> a. getAsset by the asset's name
> b. call buildURL on the asset to get its local path
> c. parse that to create a file system path
> d. use Java to open the HTML file directly
> e. read the contents of the HTML file into a buffer
> f. return the buffer as a string to Tapestry, which renders it on
> the page.
>
> Compared to a simple "include" statement, this is a lot of work.
>
> Is there a better way? I've searched through the archives and haven't
> found
> one.
Look at my Snippet component that I posted. I use Velocity, but it
could pull content to insert in other ways if desired.
You're HTML scraping approach is ok, but how about making a custom
transformation from DocBook that is more suitable for embedding into
Tapestry? I suspect you are stripping off everything outside of <body>
to insert the content anyway - so preprocessing your input into a more
usable fashion would make life easier. You could even make a custom
Tapestry component that did this transformation from the DocBook source
on the fly instead of preprocessing (perhaps with caching).
Erik
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org