You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@tapestry.apache.org by Guillaume Bodet <gb...@financeactive.com> on 2012/01/20 09:27:48 UTC
Programmatical page/component rendering
Hi all,
I need to send mails from my application, and I would like to use Tapestry's templating to create the body of the mail.
Is there any way to programmatically get the rendering of a page or component (in an output stream, for instance) ?
Regards
Guillaume
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Programmatical page/component rendering
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
I guess you could solve the problem another way: process the macros before
the content is sent for Tapestry to render. Once I had a similar problem
to solve (macros) and that's how I solved it. Tapestry templates were
never meant to be used by users, just by developers. So, if you need
templates and macros, you use a template engine (FreeMarker is quite good)
and pass its output to OutputRaw. If Tapestry components are needed, I
used to following trick: I've put them in pages inside a block. To render
them, I use ComponentSource.getPage() to get the page, then
getComponentResources().findBlock() to get the block, add information
needed by the block through the Environment, then used Delegate to render
the block. Works quite well. :)
Another option is to use Tapestry DOM rewriting in @AfterRender.
On Thu, 08 Mar 2012 21:16:14 -0300, Charles Roth <ro...@thedance.net> wrote:
> Could someone expand (expound?) more on rendering a Tapestry 5 component
> *inside* a java class?
>
> For example, I have an application I'm rewriting (from an
> ancient-god-help-me-C-program) in Tapestry. It's a venerable forum tool
> that lets users put "macros" in their posts. Each macro is rather like a
> Tapestry component.
>
> So as I'm rendering the page in the normal Tapestry way, I also want to
> parse the users's posts, and be able to evaluate (render) the macros
> (components) in the posts, and then spit the output, probably via
> outputraw(?), to the Tapestry page.
>
> So for example, a user's post might have something like:
> "Hey, I'm living now at %googleMap(latitude,longitude), and it's
> really
> %blink(cool)!"
>
> I want to be able to parse out the %googleMap and evaluate it (render
> it) as
> a component (that I will write), then parse out the %blink and evaluate
> it
> as another component (say, ye olde HTML blink tag)... accumulate all of
> the
> user's text plus the rendered components, and THEN spit out all of the
> text.
>
> Trying to do this with a (large!) collection of blocks would be tedious,
> and
> maybe even impossible. But this thread suggests that there are other
> ways
> to do it, programmatically inside the Java class for a page.
>
> Any hints or pointers are most welcome. Thanks in advance!
>
> --
> View this message in context:
> http://tapestry.1045711.n5.nabble.com/Programmatical-page-component-rendering-tp5159795p5549303.html
> Sent from the Tapestry - User mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
Consultor, desenvolvedor e instrutor em Java, Tapestry e Hibernate
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Programmatical page/component rendering
Posted by Charles Roth <ro...@thedance.net>.
Could someone expand (expound?) more on rendering a Tapestry 5 component
*inside* a java class?
For example, I have an application I'm rewriting (from an
ancient-god-help-me-C-program) in Tapestry. It's a venerable forum tool
that lets users put "macros" in their posts. Each macro is rather like a
Tapestry component.
So as I'm rendering the page in the normal Tapestry way, I also want to
parse the users's posts, and be able to evaluate (render) the macros
(components) in the posts, and then spit the output, probably via
outputraw(?), to the Tapestry page.
So for example, a user's post might have something like:
"Hey, I'm living now at %googleMap(latitude,longitude), and it's really
%blink(cool)!"
I want to be able to parse out the %googleMap and evaluate it (render it) as
a component (that I will write), then parse out the %blink and evaluate it
as another component (say, ye olde HTML blink tag)... accumulate all of the
user's text plus the rendered components, and THEN spit out all of the text.
Trying to do this with a (large!) collection of blocks would be tedious, and
maybe even impossible. But this thread suggests that there are other ways
to do it, programmatically inside the Java class for a page.
Any hints or pointers are most welcome. Thanks in advance!
--
View this message in context: http://tapestry.1045711.n5.nabble.com/Programmatical-page-component-rendering-tp5159795p5549303.html
Sent from the Tapestry - User mailing list archive at Nabble.com.
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Programmatical page/component rendering
Posted by "Thiago H. de Paula Figueiredo" <th...@gmail.com>.
On Fri, 20 Jan 2012 08:47:00 -0200, Lance Java <la...@googlemail.com>
wrote:
> Otherwise, I would use freemarker, a tempting engine with localisation
> support.
>
> Another option is velocity but I find freemarker to be much better than
> velocity.
Having experience with both, I can tell you to use Freemarker. Way better
than Velocity being almost as simple but more powerful and without some
bad implementation decisions.
--
Thiago H. de Paula Figueiredo
Independent Java, Apache Tapestry 5 and Hibernate consultant, developer,
and instructor
Owner, Ars Machina Tecnologia da Informação Ltda.
http://www.arsmachina.com.br
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Programmatical page/component rendering
Posted by Lance Java <la...@googlemail.com>.
Since you are generating plain text, not HTML, I would probably not use
tapestry templating to generate the text.
Depending on how simple your email is, you may find that using the message
catalog and a find-and-replace is easy enough.
Otherwise, I would use freemarker, a tempting engine with localisation
support.
Another option is velocity but I find freemarker to be much better than
velocity.
On Friday, 20 January 2012, Markus Grell <ta...@military.de> wrote:
> Great idea!
>
> Which approach do you recommend if I want to sent out a mail that does not
> need to look like a web page but just contains plain text? I somehow feel
> uncomfortable to put a complete mail text into a message catalog file.
>
> Markus
>
>> http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-
>> Tapestry-td5075717.html
>>
>>
>> On Jan 20, 2012, at 3:27 AM, Guillaume Bodet wrote:
>>
>>
>>> Hi all,
>>>
>>>
>>> I need to send mails from my application, and I would like to use
>>> Tapestry's templating to create the body of the mail.
>>> Is there any way to programmatically get the rendering of a page or
>>> component (in an output stream, for instance) ?
>>>
>>> Regards
>>>
>>>
>>> Guillaume
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>>> For additional commands, e-mail: users-help@tapestry.apache.org
>>>
>>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>>
>>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
Re: Programmatical page/component rendering
Posted by Markus Grell <ta...@military.de>.
Great idea!
Which approach do you recommend if I want to sent out a mail that does not
need to look like a web page but just contains plain text? I somehow feel
uncomfortable to put a complete mail text into a message catalog file.
Markus
> http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-
> Tapestry-td5075717.html
>
>
> On Jan 20, 2012, at 3:27 AM, Guillaume Bodet wrote:
>
>
>> Hi all,
>>
>>
>> I need to send mails from my application, and I would like to use
>> Tapestry's templating to create the body of the mail.
>> Is there any way to programmatically get the rendering of a page or
>> component (in an output stream, for instance) ?
>>
>> Regards
>>
>>
>> Guillaume
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
>> For additional commands, e-mail: users-help@tapestry.apache.org
>>
>>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org
Re: Programmatical page/component rendering
Posted by Lenny Primak <lp...@hope.nyc.ny.us>.
http://tapestry.1045711.n5.nabble.com/Generating-HTML-email-content-with-Tapestry-td5075717.html
On Jan 20, 2012, at 3:27 AM, Guillaume Bodet wrote:
> Hi all,
>
> I need to send mails from my application, and I would like to use Tapestry's templating to create the body of the mail.
> Is there any way to programmatically get the rendering of a page or component (in an output stream, for instance) ?
>
> Regards
>
> Guillaume
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
> For additional commands, e-mail: users-help@tapestry.apache.org
>
---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@tapestry.apache.org
For additional commands, e-mail: users-help@tapestry.apache.org