Thomas Bayen | 25 Jun 2006 20:25
Picon

usage of Dataloaders in non-fmpp Java programs

Hello,

I wrote a nice template set to create a big static website from some 
CSV-Files. But now I need to create some of the pages dynamically, so I will 
have to use Tomcat, write a web container and call FMPP (or Freemarker?) 
directly.

As I see it is not easy to access the loaded data from within Java. I can't 
just simply say "load the configuration data into this hash", deal with the 
data in Java and say "use this hash with FMPP and create my output".

The Dataloaders (especially the CsvDataLoader) returns a TemplateModel. Would 
it not be nicer if it returns a simple Java-"Map"? FreeMarker would wrap it 
and work as before. What would happen if we try to change CsvSequence to be a 
Map?

Your very nice configuration Syntax (tdd, reading of csv, ...) would not 
depend on FreeMarker. I could think of many uses of this nice Dataloaders 
apart from FreeMarker.

Ciao,

Thomas Bayen
Linux User Group Krefeld

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
(Continue reading)

Daniel Dekany | 25 Jun 2006 23:17
Picon
Favicon

Re: usage of Dataloaders in non-fmpp Java programs

Sunday, June 25, 2006, 8:25:30 PM, Thomas Bayen wrote:

> Hello,
>
> I wrote a nice template set to create a big static website from some 
> CSV-Files. But now I need to create some of the pages dynamically, so I will
> have to use Tomcat, write a web container and call FMPP (or Freemarker?)
> directly.
>
> As I see it is not easy to access the loaded data from within Java. I can't
> just simply say "load the configuration data into this hash", deal with the
> data in Java and say "use this hash with FMPP and create my output".
>
> The Dataloaders (especially the CsvDataLoader) returns a TemplateModel. Would
> it not be nicer if it returns a simple Java-"Map"? FreeMarker would wrap it
> and work as before. What would happen if we try to change CsvSequence to be a
> Map?

You can't do it in general. The TemplateModel-s (these are the
FreeMarker variables basically) has abilities that java.util/java.lang
suff hasn't. Like I can't create a value that is both a Map and a List
with J2SE classes, but I can with TemplateModel-s. OK, most data
loaders don't utilize these things, but for example the CSV data
loader is one that does.

> Your very nice configuration Syntax (tdd, reading of csv, ...) would not
> depend on FreeMarker. I could think of many uses of this nice Dataloaders
> apart from FreeMarker.

Well, these are something to consider when (and if) I write
(Continue reading)

Thomas Bayen | 26 Jun 2006 11:39
Picon

Re: usage of Dataloaders in non-fmpp Java programs

Am Sonntag, 25. Juni 2006 21:17 schrieb Daniel Dekany:
> Sunday, June 25, 2006, 8:25:30 PM, Thomas Bayen wrote:
[...]
> > Your very nice configuration Syntax (tdd, reading of csv, ...) would not
> > depend on FreeMarker. I could think of many uses of this nice Dataloaders
> > apart from FreeMarker.
>
> Well, these are something to consider when (and if) I write
> preprocessor next time, so thanks for the thoughts. As of FMPP, it's
> practically impossible that I will refactor it to work this way, since
> I'm way too busy with other OSS things that I give higher priority.
> You see, I have to chose which thumb if mine I want to bite...
>
> Anyway, is there any obstacle in doing this what you wanted? I mean,
> if you write data loaders that return non-FreeMarker objects only,
> then it's what you wanted, isn't it?

You say my idea is not totally bad and you say there are no internal technical 
obstacles. That's all I wanted to know. :-) If I find the time to do it I 
will dig into your source and give it a try.

Thanks,

Thomas Bayen
Linux User Group Krefeld

Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642
(Continue reading)


Gmane