You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Jonathan Meijer <jo...@gmail.com> on 2022/03/01 04:44:14 UTC

Rendering a page without a .tml template?

Hi,

In my tapestry app, in some cases, I want the HTML to be entirely generated
without Tapestry's intervention.

For example, hypothetically, I have MyPage.java but a missing or empty
MyPage.tml whose content does not matter.  Ideally, MyPage.java would
somehow conjure up the contents and my HTML would not be touched by
bootstrap (or however it's done).  I tried multiple things, including
trying to override the rendering steps, but no matter what I do, Tapestry
either complains there's no content (even though there is), or it adds the
<html><head> and all the stuff I really don't need.

Any idea what I should do?

Jonathan

Re: Rendering a page without a .tml template?

Posted by Volker Lamp <vo...@gmail.com>.
Hello Jonathan,

A page's onActivate() page can return something, for example, a
org.apache.tapestry5.StreamResponse or a java.net.URL. (see
https://tapestry.apache.org/page-navigation.html#PageNavigation-ComponentEventRequests&Responses
for more). That way, you could have a page class that serves a static file.
(I understood serving the static file by just putting it into
src/main/webapp is not the way to go as you need that page class for
something).

I was trying to imagine why you would not want a page to generate output.
Perhaps putting that logic into an event handler is a better way to go?

Cheers,

Volker


Am Di., 1. März 2022 um 05:44 Uhr schrieb Jonathan Meijer <
jonny.meijer@gmail.com>:

> Hi,
>
> In my tapestry app, in some cases, I want the HTML to be entirely generated
> without Tapestry's intervention.
>
> For example, hypothetically, I have MyPage.java but a missing or empty
> MyPage.tml whose content does not matter.  Ideally, MyPage.java would
> somehow conjure up the contents and my HTML would not be touched by
> bootstrap (or however it's done).  I tried multiple things, including
> trying to override the rendering steps, but no matter what I do, Tapestry
> either complains there's no content (even though there is), or it adds the
> <html><head> and all the stuff I really don't need.
>
> Any idea what I should do?
>
> Jonathan
>

Re: Rendering a page without a .tml template?

Posted by Jonathan Meijer <jo...@gmail.com>.
Wonderful, works perfectly, thanks!

Jonathan

On Tue, Mar 1, 2022 at 1:36 PM Thiago H. de Paula Figueiredo <
thiagohp@gmail.com> wrote:

> On Tue, Mar 1, 2022 at 1:44 AM Jonathan Meijer <jo...@gmail.com>
> wrote:
>
> > Hi,
> >
>
> Hello!
>
>
> > In my tapestry app, in some cases, I want the HTML to be entirely
> generated
> > without Tapestry's intervention.
> >
>
> As Volker mentioned, your page should have an onActivate() method that
> returns a StreamResponse (maybe a TextStreamResponse if the context is
> text) instance which wraps the content you want returned. The page wouldn't
> have a template at all. That's a completely normal thing to do using this
> framework.
>
> --
> Thiago
>

Re: Rendering a page without a .tml template?

Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Tue, Mar 1, 2022 at 1:44 AM Jonathan Meijer <jo...@gmail.com>
wrote:

> Hi,
>

Hello!


> In my tapestry app, in some cases, I want the HTML to be entirely generated
> without Tapestry's intervention.
>

As Volker mentioned, your page should have an onActivate() method that
returns a StreamResponse (maybe a TextStreamResponse if the context is
text) instance which wraps the content you want returned. The page wouldn't
have a template at all. That's a completely normal thing to do using this
framework.

--
Thiago