You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Thilo Tanner <tt...@astina.ch> on 2008/12/03 23:38:30 UTC

[T5]: RESTful "File" Extensions (Multiple Templates per Page)

Hi All,

I have a question concerning T5 and RESTful URLs:
We'd like to create RESTful URLs with virtual "file" extension like:

/articles/1.html
/articles/1.json
/articles/1.pdf

It would be perfect to have just one page class (e.g. pages/articles/ 
Edit.java) and several templates like:

articles/Edit.tml or articles/Edit.html.tml
articles/Edit.json.tml
articles/Edit.pdf.tml

and the possibility to define handlers for the different content  
types, so for example if the user wants to load 1.pdf the template  
Edit.pdf.tml gets executed (and creates for example a xsl-fo xml) and  
before deliviering to the browser a handler takes the xml and convert  
it with apache fop to PDF and streams the result to the browser.

Is something like this possible with Tapestry 5? I'm quiet new to T5  
but if someone can give me a hint where to start, I appreciate to  
write an extension and contribute it to the community.

Thanks a lot for your help!

Best,
Thilo

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org


Re: [T5]: RESTful "File" Extensions (Multiple Templates per Page)

Posted by Howard Lewis Ship <hl...@gmail.com>.
This is not a feature of Tapestry currently. A URL such as "1.html"
would indicate (to Tapestry) a page named "1"  (an illegal name) and a
component with id "html".  Tapestry will pass on such URLs and let the
servlet container handle them (with a 404).

I think a later release of Tapestry will "open up" the generation of
links, and the corresponding dispatch code, to provide more Rails-like
ability to control URL format.

On Wed, Dec 3, 2008 at 2:38 PM, Thilo Tanner <tt...@astina.ch> wrote:
> Hi All,
>
> I have a question concerning T5 and RESTful URLs:
> We'd like to create RESTful URLs with virtual "file" extension like:
>
> /articles/1.html
> /articles/1.json
> /articles/1.pdf
>
> It would be perfect to have just one page class (e.g.
> pages/articles/Edit.java) and several templates like:
>
> articles/Edit.tml or articles/Edit.html.tml
> articles/Edit.json.tml
> articles/Edit.pdf.tml

I this one page or three?  As Tapestry exists today, this could be
pages Edit, EditJSON and EditPDF, and you could use subclassing to
enable consistency of behavior between them.  Page navigation will be
somewhat tricky as Tapestry doesn't have a mechanism for
distinguishing pages except by name, which must be unique.

Many people take it as a given than it is desirable to be able to
more-or-less seamlessly output in different formats (i.e., HTML, PDF,
HTML-for-iPhone, Sanscrit, etc.).  However, when I've challenged
people about this "requirement" in person, nobodies been able to say
"yes, we absolutely need this".

As far as I'm concerned, if you translate from one medium (HTML) to
another (PDF, etc.). it's an entirely different application, with
different user interactions, navigation and flow, look & feel, etc.
The various pipelines I've seen with XML and XSLT and side processing
& etc. were always a disaster (Neal Ford has some great horror
stories) and they always box you in, coding for the least common
denominator and a ton of special cases.  I call it "coding inside a
case statement". It's ugly.

All the very succesful iPhone apps, for example, don't try to shoehorn
in the main application; they provide simplified navigation and
limited options appropriate to someone in between locations, reserving
all the more involved interactions for a real desktop.

Take this on head on and generate good UIs for the different mediums.

>
> and the possibility to define handlers for the different content types, so
> for example if the user wants to load 1.pdf the template Edit.pdf.tml gets
> executed (and creates for example a xsl-fo xml) and before deliviering to
> the browser a handler takes the xml and convert it with apache fop to PDF
> and streams the result to the browser.
>
> Is something like this possible with Tapestry 5? I'm quiet new to T5 but if
> someone can give me a hint where to start, I appreciate to write an
> extension and contribute it to the community.

Learn the framework first, then worry about major extensions.
People's energies could be better spent on unequivocably useful tasks,
such as helping with documentation, or improving Ajax support or
general look & feel.

>
> Thanks a lot for your help!
>
> Best,
> Thilo
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>



-- 
Howard M. Lewis Ship

Creator Apache Tapestry and Apache HiveMind

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org