Components

"Luther Baker" <[email protected]>
Newsgroups gmane.comp.web.freemarker.user
Message-ID <[email protected]>
One additional question.

As you might have noted from previous emails - I am using FreeMarker in a
web application context.

I am trying to build a framework to make it easy to create 'components'. One
of my previous questions revolved around implementing a Macro in Java code
(I was looking for the webapplication context). Now, to do this, I am using
TemplateDirectiveModel. That is all well and fine but I have a question, the
"void execute" method is a bit verbose and I'm really using things like
annotations and reflection to make the final client code dead simple ..

So, one of the things I'd like to investigate would be to write my own
TemplateDirectiveModel ... so, I think I'd like to look one step back at the
class invoking TemplateDirectiveModel.execute and see if I'd like to alter
the processing logic depending on things like annotations etc in the
implementing class.

IE: is this reasonable and expected that I'd want to write my own ...
'macro' handler to invoke the TemplateDirectiveModel in a certain way. For
instance, I might want to break execute out into (pre, exec, and post)
processing. Granted, I could also build an Abstract class and possibly mimic
this behavior as the TemplateDirectiveModel being the super ... but I wanted
to ask if it made sense to alter the logic invoking the
TemplateDirectiveModel itself.

Also, I'd like to, in my existing TemplateDirectiveModel from the last post,
use a template. Basically, I want to write a POJO and tie it to a template
so that the template can reference object directly in the bean. I don't mind
writing the skeleton work here - but it starts with the basic ability from
the execute method - to load and process a template and somehow return that
as a nested component of a larger template. I'm working through it - but any
suggestions would be appreciated.

Finally, TemplateDirectiveModel.execute has a Map object ... not JDK 1.5 ...
so in my other framework code I've been casting or using a
HashMap<String,Object> to push things into template. That has worked so for
--- as in the execute method, I have successfully retrieved things like
SimpleScalar from the params argument. So, is this the correct way to
retrieve a string argument from the macro invocation when the macro is
implemented in Java?

         SimpleScalar page = (SimpleScalar) params.get("page");

It seems to work for me - and I use page.getAsString() to echo the contents
... etc.

Well - thanks for any help to these questions. I will soon be posting my
freemarker based web framework when I iron out a few more of the basic
funtionality I need - but so far, so good.

Thanks again - any suggestions are very appreciated.

-Luther

-------------------------------------------------------------------------
This SF.Net email is sponsored by the Moblin Your Move Developer's challenge
Build the coolest Linux based applications with Moblin SDK & win great prizes
Grand prize is a trip for two to an Open Source event anywhere in the world
http://moblin-contest.org/redirect.php?banner_id=100&url=/

_______________________________________________
FreeMarker-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/freemarker-user
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.