velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Rickard Öberg <rick...@xpedio.com>
Subject Re: Velocity macros and pass-by-reference
Date Tue, 07 Aug 2001 12:31:29 GMT
Hey

"Geir Magnusson Jr." wrote:
> so clearly, assigning the string in the VM did work. Hm...

Weird, I tried again, and now it works. I must have made some typo the
first time.

Anyway, all is well now. :-)

> I think that strictly speaking, this is a non-Velocity way to do things
> if you are a MVC fundamentalist, but I don't speak strictly, nor am I a
> fundamentalist of any sort.

You mean the Model-1/Model-2 thingy? Well, I've been thinking about
this, and in a sense what I'm doing right now is basically a short-hand
for Model-2.

Example. A page has a sub-component:
..foo.
#include ("myaction.action")
..blah..
where the include will call the action (=controller code) and include
it's view, which may be a Velocity template.

But this could do the same:
..foo..
#action ("myaction" $action)
#execute ($action)
Action result:${action.result}
..blah..

Basically the second, the Model-1 way, is just a shorthand for the
Model-2 way, i.e. no separate file has been created for it, with the
difference that it cannot be reused in other templates. Sometimes that's
ok though.

Is this what you were thinking/worried about?

> However, I will admit I am suspicous of this - because you are
> distributing object creation across your pages again, rather than
> restricting to some sort of data 'factory', be it the front controller
> or something else...

The #bean macro should only be used for formatting or other
view-specific stuff, which is something that you don't really want to
put into your controller code (IMHO anyway).

The #action macro is, as mentioned above, more of a shorthand for using
Model-2.

> So if all of a sudden you don't want to use a class that you have
> specified in your web pages, you have a small maintenance issue.   I
> guess you could get cute and look them up by name :)

Yup, that's a valid concern. It's a tradeoff though.

/Rickard

-- 
Rickard Öberg
Software Development Specialist
xlurc - Xpedio Linköping Ubiquitous Research Center
Author of "Mastering RMI"
Email: rickard@xpedio.com

Mime
View raw message