You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Alexander Zimmer <al...@unycom.com> on 2008/01/21 14:58:32 UTC

AW: AW: Using Turbine's tools for assembling PDF output (using FOP):how to?

This was exactly the hint I was looking for! Thanx a lot, I got it to work with no problem at all.

@Tony Oslund: since the deadline is this week I will not be able to switch away from FOP. But I definitely will have a look at pd4ml, I just peeked a little inside the examples and it seems promising ...
Besides, your point with asynchronous generation is right, however, in my case (again, the close deadline make my skin rise with goose bumps) I'm better off with a synchronous solution. If performance should be a problem, I will offer the customer to switch to asynchr. generation, but beforehand I will have to spend a few thoughts on this (how to notifiy when the PDF is complete, ...).

Thank you all for your help!

Cheers,
Alex

-----Ursprüngliche Nachricht-----
Von: Thomas Vandahl [mailto:tv@apache.org] 
Gesendet: Samstag, 19. Jänner 2008 18:42
An: Turbine Users List
Betreff: Re: AW: Using Turbine's tools for assembling PDF output (using FOP):how to?

Alexander Zimmer wrote:
> How can I use template functionality? The problem involved are:
> 1. I want to use the Velocity engine and capture its output in a String/ByteArray. The output will be a valid FO file.
> 2. I want to be able to use all (at least: some) pull tools Turbine provides for screen templates
> I think that I've solved the other problems (how to do the streaming, how to convert into PDF, ...).
> I try to dive into the VelocityOnlyLayout (as Peter Courcoux pointed out), but if you have additional clues for me, I would be very happy to hear from you!

You have TurbineVelocity at your disposal. 
TurbineVelocity.handleRequest(Context context, String template) is 
probably what you want. The service is used by Turbine itself so the 
Velocity engine used is completely configured and ready to use.

The service will provide you with a new context 
(TurbineVelocity.getContext(RunData data)) which is already 
pre-populated with all the pull tools you configured, but you can also 
pass it an existing, pre-populated context.

Don't forget to call TurbineVelocity.requestFinished() when you're done.


Bye, Thomas.

---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org


Re: AW: Using Turbine's tools for assembling PDF output (using FOP):how to?

Posted by Tony Oslund <ao...@bevcomm.net>.
One trick that I have used (for notifying pdf completion) is to embed a 
hidden iframe within the parent web form...

This iframe references a seperate Velocity form whose sole purpose in life 
is to check for completion of the generation by simply refreshing the hidden 
contents of the iframe once every few seconds (during the refresh the iframe 
Turbine doBuildTemplate code polls the status of the generation).   Once 
generation is complete the iframe Turbine doBuildTemplate code loads a 
different flag into the context that specifies that different java script 
should be included in the form.  This different scripting signals the parent 
form that it should refresh itself once generation is complete.

It sounds complex, but is actually a fairly small amount of javascript 
combined with some very basic Velocity form logic (yes I know that I am off 
topic).

The reason for putting the polling in the iframe is that it avoids 
unnecessary refreshes to the parent form which results in a smoother more 
pleasant experience for the user.

Also, the asynchronous generation (in my case) is just a java process 
running as a Linux crontab process that checks for logged requests, 
generates the report, and flags the request as complete.  The nice thing 
about this is that the process can exist on a server that is entirely 
seperate from the app server.

Best of luck

----- Original Message ----- 
From: "Alexander Zimmer" <al...@unycom.com>
To: "Turbine Users List" <us...@turbine.apache.org>
Sent: Monday, January 21, 2008 7:58 AM
Subject: AW: AW: Using Turbine's tools for assembling PDF output (using 
FOP):how to?


> This was exactly the hint I was looking for! Thanx a lot, I got it to work 
> with no problem at all.
>
> @Tony Oslund: since the deadline is this week I will not be able to switch 
> away from FOP. But I definitely will have a look at pd4ml, I just peeked a 
> little inside the examples and it seems promising ...
> Besides, your point with asynchronous generation is right, however, in my 
> case (again, the close deadline make my skin rise with goose bumps) I'm 
> better off with a synchronous solution. If performance should be a 
> problem, I will offer the customer to switch to asynchr. generation, but 
> beforehand I will have to spend a few thoughts on this (how to notifiy 
> when the PDF is complete, ...).
>
> Thank you all for your help!
>
> Cheers,
> Alex
>
> -----Ursprüngliche Nachricht-----
> Von: Thomas Vandahl [mailto:tv@apache.org]
> Gesendet: Samstag, 19. Jänner 2008 18:42
> An: Turbine Users List
> Betreff: Re: AW: Using Turbine's tools for assembling PDF output (using 
> FOP):how to?
>
> Alexander Zimmer wrote:
>> How can I use template functionality? The problem involved are:
>> 1. I want to use the Velocity engine and capture its output in a 
>> String/ByteArray. The output will be a valid FO file.
>> 2. I want to be able to use all (at least: some) pull tools Turbine 
>> provides for screen templates
>> I think that I've solved the other problems (how to do the streaming, how 
>> to convert into PDF, ...).
>> I try to dive into the VelocityOnlyLayout (as Peter Courcoux pointed 
>> out), but if you have additional clues for me, I would be very happy to 
>> hear from you!
>
> You have TurbineVelocity at your disposal.
> TurbineVelocity.handleRequest(Context context, String template) is
> probably what you want. The service is used by Turbine itself so the
> Velocity engine used is completely configured and ready to use.
>
> The service will provide you with a new context
> (TurbineVelocity.getContext(RunData data)) which is already
> pre-populated with all the pull tools you configured, but you can also
> pass it an existing, pre-populated context.
>
> Don't forget to call TurbineVelocity.requestFinished() when you're done.
>
>
> Bye, Thomas.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
> For additional commands, e-mail: user-help@turbine.apache.org
>
> 


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@turbine.apache.org
For additional commands, e-mail: user-help@turbine.apache.org