"Geir Magnusson Jr." wrote:
> 
> Jari Worsley wrote:
> >
> 
> The real answer assumes a little about how things like Velocity work.
> See below.
> 
> > Or am i missing something.
> 
> The question is how do you access it?  And for this game, you can't use
> scriptlets in JSP :)
> 

Ok. I haven't looked at Velocity at all.

> In velocity, we never allow 'new' from a template to prevent trouble. It
> also keeps the designer from having to know about the Java API - tools
> are provided.  Some of those tools could be JDK classes, but people tend
> to make them easier to use by wrapping them.
> 
> The controller servlet places all allowed tools in the 'context' that
> the template can access, something like
> 
> context.put("mathtool", new MathTool() );
> 
> and then in the template, you can use it.
> 
> $mathtool.mul( $a, $b )
> 
> and if the MathTool was generously written, then mul() would handle
> different types of input for $a and $b, and deal with them if possible.
> 
> This moves the onus of understanding the Java API's back onto the
> programmer, and not the designer.

This seems to me that you're advocating logic being part of the
template? Doesn't this "break" the whole MVC idea where you try and do
all processing before hitting the page, then just use some template
mechanism (JSP etc) to display data in the page? 

To me 
$sometool.apicall($arg1, $arg2) is just as much a programming call as 
a JSP style <%= request.getAttribute("foo") %>.

I guess I should look at what you are trying to do in Velocity before
commenting further really.

Jari

--
Jari Worsley
Senior Programmer
Hyperlink Interactive Ltd

Reply via email to