velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Claude Brisson" <cla...@savoirweb.com>
Subject Re: Velocity + Database
Date Tue, 05 Aug 2003 05:46:08 GMT
Nathan wrote :

> so, yeah, Velosurf already separates SQL from the templates (and in a clean,
> simple way), but it doesn't separate Model *manipulation* from the View.
> therein lies the MVC "no-no."  of course, if your application involves only
> presentation (reports and whatnot), then just tell Velosurf to be read-only,
> and you have a quick and easy way to expose your model to the view for
> presentation.  my understanding is that that would be simple, quick, and
> legitimate MVC.

Good remarks, but since classes mapping database objects can be inherited, you can have your
$mypersistententity.delete() make
anything you want, like generate an event in the framework instead of really deleting the
row from the db (which remains the default
behaviour if not in read-only mode).

In fact, the aim of Velosurf is not to merge the View and Model layers, but to help to expose
(parts of) the Model into the View,
which is more or less needed at some point.

In the next Velosurf release, I'll try to rewrite the docs so as to implicitely drive users
towards a better respect of the MVC
principles.

CloD

----- Original Message -----
From: "Nathan Bubna" <nathan@esha.com>
To: "Velocity Users List" <velocity-user@jakarta.apache.org>
Sent: dimanche 27 juillet 2003 00:05
Subject: Re: Velocity + Database


> Aaron Freeman said:
> ...
> > Ok, I think a very cool way to do what I was talking about, as well as
> > accomplish better MVC practices is to add a new VTL directive called #query
> > that would be placed inside of .vs (velocity SQL [only a best practice
> > requirement]) files.
> >
> > For example inside of a file called user.vs you would have:
> > #query ( name='getUsersByAge')
> > SELECT username
> >   FROM users
> > WHERE age = #age
> >          AND state = #state
> > #end
> >
> > Then in your index.vm you might have:
> > <html>
> > <body>
> > #foreach ($user in $getUsersByAge.username)
> > $velocityCount: $user
> > #end
> > </body>
> > </html>
>
> creating this would be a lot of work and would be not much different from
> Velosurf.  frankly, i think Claude's system (defining the querys and entities
> and whatnot in a separate xml file) is better than this would be, and his
> system is already created.
>
> > By separating the SQL into separate files, that really separates the SQL
> > programming logic from the View logic, and it makes it very easy on the SQL
> > programmer ... he doesn't need to know java.
>
> eh...  i guess i should be clearer.  Velosurf doesn't involve putting SQL in
> templates, but it does have SQL*calls* directly exposed.  so in your template,
> you would do things like $mypersistententity.delete().   in a more typical MVC
> setup, you would not expose things like that to the template (or whatever view
> technology you are using).  that sort of model manipulation would happen in
> Java code (usually in business/model logic code that is called from an
> *action* class of a framework like Struts or Turbine).
>
> so, yeah, Velosurf already separates SQL from the templates (and in a clean,
> simple way), but it doesn't separate Model *manipulation* from the View.
> therein lies the MVC "no-no."  of course, if your application involves only
> presentation (reports and whatnot), then just tell Velosurf to be read-only,
> and you have a quick and easy way to expose your model to the view for
> presentation.  my understanding is that that would be simple, quick, and
> legitimate MVC.
>
> Nathan Bubna
> nathan@esha.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: velocity-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: velocity-user-help@jakarta.apache.org
>
>


Mime
View raw message