You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by "Charles N. Harvey III" <ch...@alloy.com> on 2001/12/27 22:21:23 UTC

Site wide Velocity Deployment

I have been toying with Velocity for the past few weeks.  Different ways
to set it up, how to arrange my servlets, if I should also use struts or
turbine to aid developers.

The thing is, I am not yet a java developer.  I am an admin who knows all
kinds of scripting, just not enough java.  So scratching my way through
velocity and the documentation is a bit difficult.  But that is my problem.
:)

What I am wondering about is how I would use Velocity templates throughout
a site.  Instead of an application with a few pages, I want to have a larger
site.  An entire folder structure of .vm pages.  Most of the pages are
mostly
html, with some user interaction added in like login info: username,
birthday,
and maybe a call to profile specific text.  So what I want are a few
servlets
that hold/extract certain information, and I want these calls to be
accessible
from each page on my site.  Is this feasible or is Velocity really only used
for building applications?

If not I will most likely go with jsp and some taglibs.  And if I do that
I will probably try to use the Velocity taglib just to make sure I am using
Velocity somehow.

Thanks.

Charlie Harvey


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by Bojan Smojver <bo...@binarix.com>.
Quoting "Charles N. Harvey III" <ch...@alloy.com>:

> What I am wondering about is how I would use Velocity templates
> throughout
> a site.  Instead of an application with a few pages, I want to have a
> larger
> site.  An entire folder structure of .vm pages.  Most of the pages are
> mostly
> html, with some user interaction added in like login info: username,
> birthday,
> and maybe a call to profile specific text.  So what I want are a few
> servlets
> that hold/extract certain information, and I want these calls to be
> accessible
> from each page on my site.  Is this feasible or is Velocity really only
> used
> for building applications?

If you want to do all this by having a single servlet (that you never have to
change in any way) and a few Java beans that actually do the real work, you are
welcome to try my PumpServlet (ftp://ftp.binarix.com/pub/pump/pump.tar.gz). You
can use it as either Model 1 (i.e. use VTL + beans for business logic) or as
Model 2 (or MVC, where you define a controller, which is just a Java class
facilitating the interaction between presentation and business logic). More info
is in the README file... PumpServlet is free software (GPL).

Configuration is simple, through an XML file. Deployment is also very simple,
since this is the only servlet you'll need for all your web applications.

You want the information to be accessible from all pages on your site and it
seems like a personalised kind of thing, so you'd probably go with session beans
(and possibly some application beans that are relevant to all users - e.g.
message of the day), which are both supported in PumpServlet. And for temporary
stuff (i.e. something you just render and then forget), you can do request beans
too.

> If not I will most likely go with jsp and some taglibs.

Don't know much about taglibs, but JSP's are rather painful (although they look
very appealing). And you'll have to learn Java with JSP eventually, so why not
do it The Right Way (TM) and use Velocity.

Bojan

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/27/01 4:52 PM, "Tim Colson" <tc...@cisco.com> wrote:

>> So we'll help.  In the next few days
> Ooooh, dag nab it... 'few days'... more taunting! <grin>
> 
>> (it would have been earlier but for a DOA mac...)
> Egad. Okay. I'll shut up now. ;-)

Really - this thing *screams*.  Only run OS X of course, so it's unix with a
great UI...

Give it a look if you get a chance.  I was skeptical too - I was a diehard
linux user - other than booting to NT to use quicken, that's all I would use
at home.

I got an ibook in august, and didn't let go of it since.  So I figure that
this desktop isn't much of a risk :)

> 
> Geir, has anybody ever noted that you seem able to write code & email faster
> than 95% of all humans? Even now when your computer is dead! Hmm.. does this
> mean your brain has ethernet? <wink>
> 

:)

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Site wide Velocity Deployment

Posted by Tim Colson <tc...@cisco.com>.
> So we'll help.  In the next few days
Ooooh, dag nab it... 'few days'... more taunting! <grin>

> (it would have been earlier but for a DOA mac...)
Egad. Okay. I'll shut up now. ;-)

Geir, has anybody ever noted that you seem able to write code & email faster
than 95% of all humans? Even now when your computer is dead! Hmm.. does this
mean your brain has ethernet? <wink>

Cheers,
Timo


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Site wide Velocity Deployment

Posted by David Esposito <es...@newnetco.com>.
I think you might be coming at this from a bad angle ... I arrived at
Velocity and the MVC model from the same background as you ... (Cold Fusion
and PERL) ... those languages / styles / models / mindsets / whatever you
want to call them  are quite different than what you want to do with MVC and
Velocity ... it's almost better if you didn't know them because you will
spend the next few weeks/months doing the inevitable "this is so much harder
to do in a Servlet than in ASP or PHP or whatever" ...

I think the thing you should try to force into your thinking is that
Velocity is really only supposed to be used for display ... business logic
should never be included in your Velocity (VTL) templates ... all logic and
processing should happen in the servlet and, after all is said and done with
your logic, you merge your Context together with the Velocity template and
that's what the user gets to see ... the aforementioned scripting languages
go with a model like this

if(whatever)
	spit some stuff (HTML) out to the screen
	do some querying to the DB
	spit some more stuff out to the screen
else
	query the database
	redirect the user to a different URL
end

with MVC, it's different:

in your servlet (very pseudocoded)

if(whatever)
	stick some content onto the Context for use later
	do some querying to the DB
	stick some of the stuff from the query onto the Context for use later
else
	query the database
	redirect the user to a different URL
end

return mergeTemplate("whatever_my_template_is.vm",myContext);

then, in your template:

#foreach($thing in $myList)
	spit some stuff out to the screen
#end

if($anotherThingIsInMyContext)
	spit this out to the screen
#end


so the VTL language should be viewed as a mechanism to format and
conditionally output data contained in Java objects ... not as a means to
perform business functions ..

there will be a lot of overhead involved in getting a Servlet written for
each "page" that you want to display, but after a while, you'll realize that
you get a lot of cool advantages of having all of the display and formatting
stuff basically "outsourced" ... you can merge the same Context against
several templates on your disk for different "look and feel" without having
to do much more code writing ... and you can reuse a Servlet for several
related functions pretty easily rather than going with the
one-JSP-file-per-page approach that is common to JSP projects ...

anyway, that's my 2 cents ..

-Dave

> -----Original Message-----
> From: Charles N. Harvey III [mailto:charlieh@alloy.com]
> Sent: Friday, December 28, 2001 10:26 AM
> To: Velocity Users List
> Subject: RE: Site wide Velocity Deployment
>
>
> Geir,
> This is really incredible.  To have such incredible support and
> advice on a
> product always within 20 minutes.  And for it to all be free!
>
> I have a few questions about some of the capabilities of jsp and how they
> would be available in vtl.  Things like jsp:forward, jsp:include, and java
> commands like send.responseRedirect() are very useful and I know we use
> techniques like that in our various php, asp, and perl scripts.  What I
> am asking I guess is how easy is it to use/convert some of the built in
> functionality of jsp with Velocity?  Is it just adding contexts to the
> servlet?
>
> Thanks again for the support.  It really gives a guy a warm fuzzy feeling
> when he knows he can get incredible support for his project that is faster
> and better than any encountered before that was paid for!
>
> Charlie
>
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Thursday, December 27, 2001 4:36 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Site wide Velocity Deployment
>
>
> On 12/27/01 4:21 PM, "Charles N. Harvey III" <ch...@alloy.com> wrote:
>
> > I have been toying with Velocity for the past few weeks.  Different ways
> > to set it up, how to arrange my servlets, if I should also use struts or
> > turbine to aid developers.
> >
> > The thing is, I am not yet a java developer.  I am an admin who
> knows all
> > kinds of scripting, just not enough java.  So scratching my way through
> > velocity and the documentation is a bit difficult.  But that is my
> problem.
> > :)
>
> That's true.  Not much we can do for you :)  feel free to ask questions
> though...
>
> > What I am wondering about is how I would use Velocity templates
> throughout
> > a site.  Instead of an application with a few pages, I want to have a
> larger
> > site.  An entire folder structure of .vm pages.  Most of the pages are
> > mostly
> > html, with some user interaction added in like login info: username,
> > birthday,
> > and maybe a call to profile specific text.  So what I want are a few
> > servlets
> > that hold/extract certain information, and I want these calls to be
> > accessible
> > from each page on my site.  Is this feasible or is Velocity really only
> used
> > for building applications?
>
> Velocity is actually most commonly used for web development.
>
> > If not I will most likely go with jsp and some taglibs.  And if
> I do that
> > I will probably try to use the Velocity taglib just to make sure I am
> using
> > Velocity somehow.
>
> Put the JSP down, and back slowly away from the taglibs.... :)
>
>
> Yes, you can build your entire site using Velocity.  The
> 'problem' that you
> will face is that you will need a 'controller', the code that manages app
> flow and loads and saves data (speaking simply...).  This
> requires a little
> extra work up front compared to a  Model1 JSP app, where you just do what
> you want in the pages, but you save a ton on the back end with changes and
> maintenance.
>
> So we'll help.  In the next few days (it would have been earlier but for a
> DOA mac...) I'll check in some of the recent efforts from three of us that
> let you work with Struts an velocity.  Actually, you don't need struts if
> you have a simple enough app, because this servlet will let you
> just render
> velocity 'pages' with some assistance from tools.
>
> --
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> "Whoever would overthrow the liberty of a nation must begin by
> subduing the
> freeness of speech." - Benjamin Franklin
>
>
>
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Turbine or Struts

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/2/02 11:36 AM, "Geir Magnusson Jr." <ge...@optonline.net> wrote:

> On 1/2/02 11:21 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:
> 
>> I have been digging through the docs for Turbine and for Struts on
>> the Jakarta site and I am quite unsure of what to do.  I also know
>> that there is talk of a better and well documented integration of
>> Velocity and Struts.
>> 
>> Well, which do I choose?  Turbine is a development platform that
>> is wrapped around Velocity.  And it has the Turbine servlet that
>> acts as the broker.  So far what I am getting out of Struts is
>> a different type of broker servlet (controller).
>> 
>> How does Velocity tie into each of these?  In which one is it easier?
>> Which one will Velocity tie into better for full site development?
>> (I am lead to believe it is Turbine)
>> 
>> These are all powerful tools and I just want to be able to pick the
>> correct one for us.  And I am in the rare position where it is
>> completely clean slate here.  We get to start our java world all
>> over again with whatever I choose.
>> 
>> Thanks so much for the help and advice.
>> 
> 
> I won't recommend one over the other, as I couldn't do that fairly as I use
> neither.
> 
> Real Soon Now is coming a Velocity-Struts integration package that lets you
> use velocity as the view layer in Struts, in the same ways that JSPs are
> used in Struts.
> 

I'm pretty scatterbrained these days - what I meant to add was that this
will be bleeding edge stuff - not rocket science, but just new, so you will
have to take that into consideration.

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"We will be judged not by the monuments we build, but by the monuments we
destroy" - Ada Louise Huxtable


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Turbine or Struts

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 1/2/02 11:21 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> I have been digging through the docs for Turbine and for Struts on
> the Jakarta site and I am quite unsure of what to do.  I also know
> that there is talk of a better and well documented integration of
> Velocity and Struts.
> 
> Well, which do I choose?  Turbine is a development platform that
> is wrapped around Velocity.  And it has the Turbine servlet that
> acts as the broker.  So far what I am getting out of Struts is
> a different type of broker servlet (controller).
> 
> How does Velocity tie into each of these?  In which one is it easier?
> Which one will Velocity tie into better for full site development?
> (I am lead to believe it is Turbine)
> 
> These are all powerful tools and I just want to be able to pick the
> correct one for us.  And I am in the rare position where it is
> completely clean slate here.  We get to start our java world all
> over again with whatever I choose.
> 
> Thanks so much for the help and advice.
> 

I won't recommend one over the other, as I couldn't do that fairly as I use
neither.

Real Soon Now is coming a Velocity-Struts integration package that lets you
use velocity as the view layer in Struts, in the same ways that JSPs are
used in Struts.


-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"We will be judged not by the monuments we build, but by the monuments we
destroy" - Ada Louise Huxtable


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Turbine or Struts

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
I have been digging through the docs for Turbine and for Struts on
the Jakarta site and I am quite unsure of what to do.  I also know
that there is talk of a better and well documented integration of
Velocity and Struts.

Well, which do I choose?  Turbine is a development platform that
is wrapped around Velocity.  And it has the Turbine servlet that
acts as the broker.  So far what I am getting out of Struts is 
a different type of broker servlet (controller).

How does Velocity tie into each of these?  In which one is it easier?
Which one will Velocity tie into better for full site development?
(I am lead to believe it is Turbine)

These are all powerful tools and I just want to be able to pick the
correct one for us.  And I am in the rare position where it is 
completely clean slate here.  We get to start our java world all
over again with whatever I choose.

Thanks so much for the help and advice.

Charlie Harvey

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by Ian Lim <ma...@yahoo.com.sg>.
Hi

Perhaps can try XDoclet to generate the configurations :)

Regards
==========
Ian Lim
email: mallim_sg@yahoo.com.sg
homepage: http://www.webappcabaret.com/mallim


----- Original Message -----
From: "Ted Husted" <hu...@apache.org>
To: "Velocity Users List" <ve...@jakarta.apache.org>
Sent: Saturday, December 29, 2001 11:53 PM
Subject: Re: Site wide Velocity Deployment


> Terry Steichen wrote:
> > ==>You bet you are - very closely.  Even though I'm using the Enhydra
> > framework (where the request handling is done by so-called 'presentation
> > oblects'), I believe that Struts (with Velocity, of course) operates in
a
> > similar fashion (with 'action' objects handling such chores).
>
> Yes. The best practice is to route all the control through an "action"
> first, and let it select the presentation page. The action gathers
> together whatever data the page might need, places an object carrying
> the data into a context, and sends control to the page.
>
> For very simple presentations, it is very easy to setup a generic action
> that can be re-used through the application. Struts uses a configuration
> file that lets you configure the same action class under a different
> action name. This lets you configure the action to send control to a
> different page or initialize different objects, without having to write
> a custom action.
>
> In my applications, I've done a lot of work with queuing business-tier
> helper objects from the Struts configuration. In the config, I include
> the name(s) of the business objects I need to initialize, and have a
> standard action which uses reflection to invoke the objects by name.
> I've written some moderate applications now using only standard actions
> with custom business objects. In practice, this is very similar to what
> is proposed by the workflow initiative in the commons.
>
> There are even now some GUIs available for writing Struts configuration
> files. I believe that is feasible for significant applications to be
> written entirely from templates and the configuration file, using only
> "standard" Struts actions in the background. An API of business objects
> is still required, but writing flexible CRUD API's is familiar
> territory.
>
> So, it comes down to Java engineers providing a reasonable business API,
> and then everything else can be done with a configuration GUI and a
> visual HTML editor (using Velocity templates).
>
>
>
> -- Ted Husted, Husted dot Com, Fairport NY USA.
> -- Custom Software ~ Technical Services.
> -- Tel +1 716 737-3463
> -- http://www.husted.com/struts/
>
> --
> To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by Ted Husted <hu...@apache.org>.
Terry Steichen wrote:
> ==>You bet you are - very closely.  Even though I'm using the Enhydra
> framework (where the request handling is done by so-called 'presentation
> oblects'), I believe that Struts (with Velocity, of course) operates in a
> similar fashion (with 'action' objects handling such chores).

Yes. The best practice is to route all the control through an "action"
first, and let it select the presentation page. The action gathers
together whatever data the page might need, places an object carrying
the data into a context, and sends control to the page. 

For very simple presentations, it is very easy to setup a generic action
that can be re-used through the application. Struts uses a configuration
file that lets you configure the same action class under a different
action name. This lets you configure the action to send control to a
different page or initialize different objects, without having to write
a custom action. 

In my applications, I've done a lot of work with queuing business-tier
helper objects from the Struts configuration. In the config, I include
the name(s) of the business objects I need to initialize, and have a
standard action which uses reflection to invoke the objects by name.
I've written some moderate applications now using only standard actions
with custom business objects. In practice, this is very similar to what
is proposed by the workflow initiative in the commons.

There are even now some GUIs available for writing Struts configuration
files. I believe that is feasible for significant applications to be
written entirely from templates and the configuration file, using only
"standard" Struts actions in the background. An API of business objects
is still required, but writing flexible CRUD API's is familiar
territory.

So, it comes down to Java engineers providing a reasonable business API,
and then everything else can be done with a configuration GUI and a
visual HTML editor (using Velocity templates).



-- Ted Husted, Husted dot Com, Fairport NY USA.
-- Custom Software ~ Technical Services.
-- Tel +1 716 737-3463
-- http://www.husted.com/struts/

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/29/01 9:40 AM, "Terry Steichen" <te...@net-frame.com> wrote:

> Geir,
> 
> Inline (==>) comments below.  In addition, regarding the original question
> about creating a Velocity-based site by people not trained in Java, IMHO
> that's wishful thinking.  On the other hand, if such a site is
> well-designed, it is entirely possible that the site may be *maintained* by
> non-programmer types.

One of the 'disadvantages' of the template approach is that it's hard to
prototype - unlike JSP, where you can just dive in via a Model1 approach,
creating objects willy-nilly (one doesn't often get to use 'willy-nilly' in
a sentence...).  In velocity, which generally forces the model2 approach,
the objects have to be managed by the controller, or you resort to having
some kind of object factory placed in the context.

Now, this actually may not be a disadvantage depending on your world view -
I know in my past it is,  as it seem to be always the case that prototypes
tended to get shipped :)  So by preventing yecchy prototypes, and forcing a
bit of order, a template oriented application had some good engineering
practice forced upon it.

Now, the recent work on the struts integration, and some earlier work by
Bojan and others, shows that it's actually conceivable to have a generic
servlet that can load tools and render templates, w/o the requirement of a
formal controller.  (You could even riff on something Christoph once did and
use a template as the controller).

So what I am getting at is that (real soon now) we will have here, initially
for the struts integration, a tool-loading servlet and a pile of tools - so
we can indeed experiment with the notion of rapid prototyping as well as
letting non-Java developers build a site from scratch using tools.  This
will be fun.

geir
 

> 
> Best regards,
> 
> Terry
> 
> On 12/28/01 11:30 PM "Geir Magnusson Jr." <ge...@optonline.net> wrote:
> 
>> In your case, are those 'page managers' separate servlets, or objects that
>> the master controller has instantiated and uses to deal with the request?
> ==>The latter - objects.
> 
>> In my case, but rather just choosing the object to handle the request, and
>> letting it do it's thing, but from the perspective of the servlet engine,
>> its only one servlet handling the request.
> ==>Yes.
> 
>> I think this is different from doing a 'forward' or 'redirect' server
> side,
>> which seems to me a more heavyweight action.  It may not be, though.
> ==>I agree.  The request-handling objects need the ability to pass the
> request to other objects.  It is common to do this by issuing a client
> redirect.  It is far more efficient and secure to hava a mechanism for doing
> this redirection within the server itself.  There are two levels of such
> server-side redirection - object-to-object (within the controller servlet)
> and object-to-servlet (when you want to include another servlet within your
> control scope).
> 
>> I agree with this.  However, I still think it's different than what a JSP
>> has to do which involves invoking another page, right?  In your case, as I
>> understand it (and my case) the master controller invokes a method on some
>> object that It understands can deal w/ it - it remains 'in the context' of
>> the same servlet, right?
> ==>Yes -see above.  I certainly agree that the JSP redirection of
> servlet-to-servlet is less efficient than object-to-object redirection.
> 
>> One advantage to this is that the master controller is in charge of it's
> own
>> destiny - it doesn't depend on configurataion of the servlet container to
>> ensure that any 'forwards' that it does have something configured to deal
>> with it...
>> 
>> Am I following you?
> ==>You bet you are - very closely.  Even though I'm using the Enhydra
> framework (where the request handling is done by so-called 'presentation
> oblects'), I believe that Struts (with Velocity, of course) operates in a
> similar fashion (with 'action' objects handling such chores).
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"They that can give up essential liberty to obtain a little temporary safety
deserve neither liberty nor safety." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by Terry Steichen <te...@net-frame.com>.
Geir,

Inline (==>) comments below.  In addition, regarding the original question
about creating a Velocity-based site by people not trained in Java, IMHO
that's wishful thinking.  On the other hand, if such a site is
well-designed, it is entirely possible that the site may be *maintained* by
non-programmer types.

Best regards,

Terry

On 12/28/01 11:30 PM "Geir Magnusson Jr." <ge...@optonline.net> wrote:

> In your case, are those 'page managers' separate servlets, or objects that
> the master controller has instantiated and uses to deal with the request?
==>The latter - objects.

> In my case, but rather just choosing the object to handle the request, and
> letting it do it's thing, but from the perspective of the servlet engine,
> its only one servlet handling the request.
==>Yes.

> I think this is different from doing a 'forward' or 'redirect' server
side,
> which seems to me a more heavyweight action.  It may not be, though.
==>I agree.  The request-handling objects need the ability to pass the
request to other objects.  It is common to do this by issuing a client
redirect.  It is far more efficient and secure to hava a mechanism for doing
this redirection within the server itself.  There are two levels of such
server-side redirection - object-to-object (within the controller servlet)
and object-to-servlet (when you want to include another servlet within your
control scope).

> I agree with this.  However, I still think it's different than what a JSP
> has to do which involves invoking another page, right?  In your case, as I
> understand it (and my case) the master controller invokes a method on some
> object that It understands can deal w/ it - it remains 'in the context' of
> the same servlet, right?
==>Yes -see above.  I certainly agree that the JSP redirection of
servlet-to-servlet is less efficient than object-to-object redirection.

> One advantage to this is that the master controller is in charge of it's
own
> destiny - it doesn't depend on configurataion of the servlet container to
> ensure that any 'forwards' that it does have something configured to deal
> with it...
>
> Am I following you?
==>You bet you are - very closely.  Even though I'm using the Enhydra
framework (where the request handling is done by so-called 'presentation
oblects'), I believe that Struts (with Velocity, of course) operates in a
similar fashion (with 'action' objects handling such chores).



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/28/01 11:12 PM, "Terry Steichen" <te...@net-frame.com> wrote:

> 
> On Friday, December 28, 2001 10:42 AM : "Geir Magnusson Jr."
> <ge...@optonline.net>
> 
>> For example, why would a JSP page have to forward?  Isn't that application
>> logic that belongs in the controller?  It's there for controller-less
>> programming, or in the model where a page is the controller (which you can
>> do in Velocity).
> 
> Geir,
> 
> Another term you might apply to using the 'forward' method of the servlet
> runner is 'server-side redirect'.  It is certainly true that relatively few
> applications use it (compared to 'client-side redirect', the 'standard'
> way).  But it makes a lot of sense in terms of efficiency.
> 
> The way that I use Velocity is that I have what might be called a 'master
> controller' that (in effect, and among many other 'framework-type'
> functions) dispatches requests to what might be called the 'page manager'
> (called an 'action' object in Struts, I think).  The 'page manager' is the
> module that sets up the context and invokes the template.  Redirection
> (especially server-side redirection) is implemented in the 'page manager'
> and plays a very significant role (at least in my code).

I do the same thing sometimes, if I undertand you.

In your case, are those 'page managers' separate servlets, or objects that
the master controller has instantiated and uses to deal with the request?

IIn my case, but rather just choosing the object to handle the request, and
letting it do it's thing, but from the perspective of the servlet engine,
its only one servlet handling the request.

I think this is different from doing a 'forward' or 'redirect' server side,
which seems to me a more heavyweight action.  It may not be, though.

> 
> The way I see it, the 'master controller' really needs to be kind of 'dumb'
> as it pertains to the functions that are carried out by each specific
> page-manager/template - otherwise, it would become far too closely coupled.
> I think it is a good practice to include in each 'page' the logic that might
> potentially route the request to a different 'page' (such as a login, access
> deniial, purchase authorization, etc. page).
> 
> Just another perspective.

I agree with this.  However, I still think it's different than what a JSP
has to do which involves invoking another page, right?  In your case, as I
understand it (and my case) the master controller invokes a method on some
object that It understands can deal w/ it - it remains 'in the context' of
the same servlet, right?

One advantage to this is that the master controller is in charge of it's own
destiny - it doesn't depend on configurataion of the servlet container to
ensure that any 'forwards' that it does have something configured to deal
with it...

Am I following you?
 
> Best regards,
> 
> Terry
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
"Now what do we do?"


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by Terry Steichen <te...@net-frame.com>.
On Friday, December 28, 2001 10:42 AM : "Geir Magnusson Jr."
<ge...@optonline.net>

> For example, why would a JSP page have to forward?  Isn't that application
> logic that belongs in the controller?  It's there for controller-less
> programming, or in the model where a page is the controller (which you can
> do in Velocity).

Geir,

Another term you might apply to using the 'forward' method of the servlet
runner is 'server-side redirect'.  It is certainly true that relatively few
applications use it (compared to 'client-side redirect', the 'standard'
way).  But it makes a lot of sense in terms of efficiency.

The way that I use Velocity is that I have what might be called a 'master
controller' that (in effect, and among many other 'framework-type'
functions) dispatches requests to what might be called the 'page manager'
(called an 'action' object in Struts, I think).  The 'page manager' is the
module that sets up the context and invokes the template.  Redirection
(especially server-side redirection) is implemented in the 'page manager'
and plays a very significant role (at least in my code).

The way I see it, the 'master controller' really needs to be kind of 'dumb'
as it pertains to the functions that are carried out by each specific
page-manager/template - otherwise, it would become far too closely coupled.
I think it is a good practice to include in each 'page' the logic that might
potentially route the request to a different 'page' (such as a login, access
deniial, purchase authorization, etc. page).

Just another perspective.

Best regards,

Terry



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/28/01 10:26 AM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> Geir,
> This is really incredible.  To have such incredible support and advice on a
> product always within 20 minutes.  And for it to all be free!
> 
> I have a few questions about some of the capabilities of jsp and how they
> would be available in vtl.  Things like jsp:forward, jsp:include, and java
> commands like send.responseRedirect() are very useful and I know we use
> techniques like that in our various php, asp, and perl scripts.  What I
> am asking I guess is how easy is it to use/convert some of the built in
> functionality of jsp with Velocity?  Is it just adding contexts to the
> servlet?

These are mechanisms that I am not sure apply 100% once you turn to Model2
style development.  I know JSP users might argue, but I think a lot of the
'standard techniques' of the JSP application model seem to be foisted upon
users because of the underlying technology.

For example, why would a JSP page have to forward?  Isn't that application
logic that belongs in the controller?  It's there for controller-less
programming, or in the model where a page is the controller (which you can
do in Velocity).

We do dynamic structuring of content through the #parse() and #include()
directives, which take their argument and include the contents of the file
in-place in the output stream.  The difference is that #parse() will render
the argument contents as a template against the context, whereas #include()
will simply include as is.

Now, the request and response objects (HttpServletRequest,
HttpServletResponse) are included in the Context (or can be, so you can
always access any methods in those classes.  I don't know off the top of my
head what will happen if you arbitrarily do a redirect or request forward
from within a template using the normal rendering model, but it will be fun
to find out :)

> 
> Thanks again for the support.  It really gives a guy a warm fuzzy feeling
> when he knows he can get incredible support for his project that is faster
> and better than any encountered before that was paid for!


Our pleasure.  It is really cool how well the open source model does work :)


 
> Charlie
> 
> -----Original Message-----
> From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
> Sent: Thursday, December 27, 2001 4:36 PM
> To: velocity-user@jakarta.apache.org
> Subject: Re: Site wide Velocity Deployment
> 
> 
> On 12/27/01 4:21 PM, "Charles N. Harvey III" <ch...@alloy.com> wrote:
> 
>> I have been toying with Velocity for the past few weeks.  Different ways
>> to set it up, how to arrange my servlets, if I should also use struts or
>> turbine to aid developers.
>> 
>> The thing is, I am not yet a java developer.  I am an admin who knows all
>> kinds of scripting, just not enough java.  So scratching my way through
>> velocity and the documentation is a bit difficult.  But that is my
> problem.
>> :)
> 
> That's true.  Not much we can do for you :)  feel free to ask questions
> though...
> 
>> What I am wondering about is how I would use Velocity templates throughout
>> a site.  Instead of an application with a few pages, I want to have a
> larger
>> site.  An entire folder structure of .vm pages.  Most of the pages are
>> mostly
>> html, with some user interaction added in like login info: username,
>> birthday,
>> and maybe a call to profile specific text.  So what I want are a few
>> servlets
>> that hold/extract certain information, and I want these calls to be
>> accessible
>> from each page on my site.  Is this feasible or is Velocity really only
> used
>> for building applications?
> 
> Velocity is actually most commonly used for web development.
> 
>> If not I will most likely go with jsp and some taglibs.  And if I do that
>> I will probably try to use the Velocity taglib just to make sure I am
> using
>> Velocity somehow.
> 
> Put the JSP down, and back slowly away from the taglibs.... :)
> 
> 
> Yes, you can build your entire site using Velocity.  The 'problem' that you
> will face is that you will need a 'controller', the code that manages app
> flow and loads and saves data (speaking simply...).  This requires a little
> extra work up front compared to a  Model1 JSP app, where you just do what
> you want in the pages, but you save a ton on the back end with changes and
> maintenance.
> 
> So we'll help.  In the next few days (it would have been earlier but for a
> DOA mac...) I'll check in some of the recent efforts from three of us that
> let you work with Struts an velocity.  Actually, you don't need struts if
> you have a simple enough app, because this servlet will let you just render
> velocity 'pages' with some assistance from tools.
> 
> --
> Geir Magnusson Jr.     geirm@optonline.net
> System and Software Consulting
> "Whoever would overthrow the liberty of a nation must begin by subduing the
> freeness of speech." - Benjamin Franklin
> 
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr.                       geirm@optonline.net
System and Software Consulting
You're going to end up getting pissed at your software
anyway, so you might as well not pay for it. Try Open Source.



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


RE: Site wide Velocity Deployment

Posted by "Charles N. Harvey III" <ch...@alloy.com>.
Geir,
This is really incredible.  To have such incredible support and advice on a
product always within 20 minutes.  And for it to all be free!

I have a few questions about some of the capabilities of jsp and how they
would be available in vtl.  Things like jsp:forward, jsp:include, and java
commands like send.responseRedirect() are very useful and I know we use
techniques like that in our various php, asp, and perl scripts.  What I
am asking I guess is how easy is it to use/convert some of the built in
functionality of jsp with Velocity?  Is it just adding contexts to the
servlet?

Thanks again for the support.  It really gives a guy a warm fuzzy feeling
when he knows he can get incredible support for his project that is faster
and better than any encountered before that was paid for!

Charlie

-----Original Message-----
From: Geir Magnusson Jr. [mailto:geirm@optonline.net]
Sent: Thursday, December 27, 2001 4:36 PM
To: velocity-user@jakarta.apache.org
Subject: Re: Site wide Velocity Deployment


On 12/27/01 4:21 PM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> I have been toying with Velocity for the past few weeks.  Different ways
> to set it up, how to arrange my servlets, if I should also use struts or
> turbine to aid developers.
>
> The thing is, I am not yet a java developer.  I am an admin who knows all
> kinds of scripting, just not enough java.  So scratching my way through
> velocity and the documentation is a bit difficult.  But that is my
problem.
> :)

That's true.  Not much we can do for you :)  feel free to ask questions
though...

> What I am wondering about is how I would use Velocity templates throughout
> a site.  Instead of an application with a few pages, I want to have a
larger
> site.  An entire folder structure of .vm pages.  Most of the pages are
> mostly
> html, with some user interaction added in like login info: username,
> birthday,
> and maybe a call to profile specific text.  So what I want are a few
> servlets
> that hold/extract certain information, and I want these calls to be
> accessible
> from each page on my site.  Is this feasible or is Velocity really only
used
> for building applications?

Velocity is actually most commonly used for web development.

> If not I will most likely go with jsp and some taglibs.  And if I do that
> I will probably try to use the Velocity taglib just to make sure I am
using
> Velocity somehow.

Put the JSP down, and back slowly away from the taglibs.... :)


Yes, you can build your entire site using Velocity.  The 'problem' that you
will face is that you will need a 'controller', the code that manages app
flow and loads and saves data (speaking simply...).  This requires a little
extra work up front compared to a  Model1 JSP app, where you just do what
you want in the pages, but you save a ton on the back end with changes and
maintenance.

So we'll help.  In the next few days (it would have been earlier but for a
DOA mac...) I'll check in some of the recent efforts from three of us that
let you work with Struts an velocity.  Actually, you don't need struts if
you have a simple enough app, because this servlet will let you just render
velocity 'pages' with some assistance from tools.

--
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
For additional commands, e-mail:
<ma...@jakarta.apache.org>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: Site wide Velocity Deployment

Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
On 12/27/01 4:21 PM, "Charles N. Harvey III" <ch...@alloy.com> wrote:

> I have been toying with Velocity for the past few weeks.  Different ways
> to set it up, how to arrange my servlets, if I should also use struts or
> turbine to aid developers.
> 
> The thing is, I am not yet a java developer.  I am an admin who knows all
> kinds of scripting, just not enough java.  So scratching my way through
> velocity and the documentation is a bit difficult.  But that is my problem.
> :)

That's true.  Not much we can do for you :)  feel free to ask questions
though...
 
> What I am wondering about is how I would use Velocity templates throughout
> a site.  Instead of an application with a few pages, I want to have a larger
> site.  An entire folder structure of .vm pages.  Most of the pages are
> mostly
> html, with some user interaction added in like login info: username,
> birthday,
> and maybe a call to profile specific text.  So what I want are a few
> servlets
> that hold/extract certain information, and I want these calls to be
> accessible
> from each page on my site.  Is this feasible or is Velocity really only used
> for building applications?

Velocity is actually most commonly used for web development.
 
> If not I will most likely go with jsp and some taglibs.  And if I do that
> I will probably try to use the Velocity taglib just to make sure I am using
> Velocity somehow.

Put the JSP down, and back slowly away from the taglibs.... :)


Yes, you can build your entire site using Velocity.  The 'problem' that you
will face is that you will need a 'controller', the code that manages app
flow and loads and saves data (speaking simply...).  This requires a little
extra work up front compared to a  Model1 JSP app, where you just do what
you want in the pages, but you save a ton on the back end with changes and
maintenance.

So we'll help.  In the next few days (it would have been earlier but for a
DOA mac...) I'll check in some of the recent efforts from three of us that
let you work with Struts an velocity.  Actually, you don't need struts if
you have a simple enough app, because this servlet will let you just render
velocity 'pages' with some assistance from tools.

-- 
Geir Magnusson Jr.     geirm@optonline.net
System and Software Consulting
"Whoever would overthrow the liberty of a nation must begin by subduing the
freeness of speech." - Benjamin Franklin



--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>