You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by bo...@icpnet.pl on 2005/12/08 00:06:25 UTC
How to include a fragment of HTML ?
Hello,
All pages generated by my webapp have the same footer.
How to put the footer into a separate file and include
it in all the pages?
It was pretty basic and easy task in PHP or using
Apache SSI includes, but I don't really understand
how to do this in Tapestry...
Thanks for any
help!
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: How to include a fragment of HTML ?
Posted by Patrick Casey <pa...@adelphia.net>.
I thought he wanted to load arbitary fragments on an as needed
basis? If not then, yah, your approach is infinitely simpler, but if he
already has a library of fragments then he could just @Insert them via the
loader approach.
--- Pat
> -----Original Message-----
> From: Alan Chandler [mailto:alan@chandlerfamily.org.uk]
> Sent: Wednesday, December 07, 2005 4:13 PM
> To: tapestry-user@jakarta.apache.org
> Subject: Re: How to include a fragment of HTML ?
>
> On Wednesday 07 Dec 2005 23:16, Patrick Casey wrote:
> > If you don't want to do it via Tassel, just write a static method
> > that loads it e.g.
>
> Why go to all that trouble. Surely a simple "footer" component that has
> the
> HTML that you want in your footer, and a jwc file
>
> <?xml version="1.0"?>
> <!DOCTYPE component-specification PUBLIC
> "-//Apache Software Foundation//Tapestry Specification 4.0//EN"
> "http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
> <component-specification allow-body="no">
> </component-specification>
>
> then
>
> <span jwcid="@Footer"/>
>
> Will do the trick.
>
> --
> Alan Chandler
> http://www.chandlerfamily.org.uk
> Open Source. It's the difference between trust and antitrust.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
Re: How to include a fragment of HTML ?
Posted by Alan Chandler <al...@chandlerfamily.org.uk>.
On Wednesday 07 Dec 2005 23:16, Patrick Casey wrote:
> If you don't want to do it via Tassel, just write a static method
> that loads it e.g.
Why go to all that trouble. Surely a simple "footer" component that has the
HTML that you want in your footer, and a jwc file
<?xml version="1.0"?>
<!DOCTYPE component-specification PUBLIC
"-//Apache Software Foundation//Tapestry Specification 4.0//EN"
"http://jakarta.apache.org/tapestry/dtd/Tapestry_4_0.dtd">
<component-specification allow-body="no">
</component-specification>
then
<span jwcid="@Footer"/>
Will do the trick.
--
Alan Chandler
http://www.chandlerfamily.org.uk
Open Source. It's the difference between trust and antitrust.
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
RE: How to include a fragment of HTML ?
Posted by Patrick Casey <pa...@adelphia.net>.
If you don't want to do it via Tassel, just write a static method
that loads it e.g.
Public static String load(String asset) {
File f = new File(asset);
FileInputStream fs = new FileInputStream(f);
ByteArrayOutputStream bs = new
ByteArrayOutputStream();
byte[] buffer = new byte[1024];
try {
while (true) {
int length = fs.read(buffer);
if (length < 0) {
break;
}
bs.write(buffer, 0, length);
}
fs.close();
} catch (Exception e) {
Log.error(e);
}
String rc = new String(bs.toByteArray());
Return rc;
}
Then use the @Insert component on your form
<span jwcid="@Insert"
value="ognl:@mypackage.myLoader@load('foo.html')" raw="true"/>
--- Pat
> -----Original Message-----
> From: bogien@icpnet.pl [mailto:bogien@icpnet.pl]
> Sent: Wednesday, December 07, 2005 3:06 PM
> To: tapestry-user@jakarta.apache.org
> Subject: How to include a fragment of HTML ?
>
> Hello,
>
> All pages generated by my webapp have the same footer.
> How to put the footer into a separate file and include
> it in all the pages?
>
> It was pretty basic and easy task in PHP or using
> Apache SSI includes, but I don't really understand
> how to do this in Tapestry...
>
> Thanks for any
> help!
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: tapestry-user-help@jakarta.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: tapestry-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: tapestry-user-help@jakarta.apache.org