You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by RXZ JLo <ru...@yahoo.com> on 2002/10/08 10:30:32 UTC

Velocity Vs JavaScript

>From my first look at Velocity, it seems to follow
EcmaScript style - you predefine objects, with the
properties accessible via get/set methods.

Why not just use JavaScript instead? 

thanks,
rf

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

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


RE: Velocity Vs JavaScript

Posted by Kevin Baynes <kb...@seagullsw.com>.
Bill wrote:

> However, it could make sense to use JavaScript with Velocity.  Instead of
> coding objects in Java, they could be coded in JavaScript and exposed to
> Velocity as Java objects.  Some of the web frameworks support
> this such as
> WebWork and one other that escapes my mind.  I also recall
> someone on this
> list who wrote their own framework that used JavaScript to expose objects
> in Velocity templates.

The JPublish web framework uses BSF and comes with Python and BeanShell -
you can add JavaScript, etc.

Having Java, a Script language and Velocity in a web framework is a great
combination. You get powerful development with Java, fast development with
Script (to quickly glue Java objects together and prepare them for
Velocity), and easy to use VTL in the templates.

~k


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


Re: Velocity Vs JavaScript

Posted by Bill Burton <bi...@progress.com>.
Hello,

RXZ JLo wrote:
> From my first look at Velocity, it seems to follow
> EcmaScript style - you predefine objects, with the
> properties accessible via get/set methods.
> 
> Why not just use JavaScript instead? 

As others have pointed out, JavaScript is not a template language but a 
programming language.  Velocity is designed for writing templates so what 
logic this is is very minumal (but sufficent) for template applications.

However, it could make sense to use JavaScript with Velocity.  Instead of 
coding objects in Java, they could be coded in JavaScript and exposed to 
Velocity as Java objects.  Some of the web frameworks support this such as 
WebWork and one other that escapes my mind.  I also recall someone on this 
list who wrote their own framework that used JavaScript to expose objects 
in Velocity templates.

The same thing applies to BeanShell (http://www.beanshell.org/) and other 
scripting languages written in Java.  Or using the Bean Scripting 
Framework (BSF) at 
http://oss.software.ibm.com/developerworks/projects/bsf, you can code to 
an API that would let you plug any any of the supported scripting languages.

-Bill


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


Re: Velocity Vs JavaScript

Posted by RXZ JLo <ru...@yahoo.com>.
Thanks to all who replied in this thread. yeah
velocity's purpose is no doubt good, it is only that
the script engine design and implementation seemed to
be similar in Rhino and Velocity - both have the
concept of context, you put named objects(which rhino
calls scriptable) in the scope of the context. The
difference is in the syntax, velocity templates
require a different parser but in the back end may be
it can use Rhino to access the java Objects instead of
reinventing the wheel. I agree with somebody who said
the power of Velocity is its ability to limit things,
I think this gives good mileage over using JavaScript
directly.

Atually I have not looked at Velocity templates and
examples in detail, may be I should do that first. 

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

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


Re: Velocity Vs JavaScript

Posted by Martin Jacobson <ma...@libero.it>.
RXZ JLo wrote:

>>>From my first look at Velocity, it seems to follow
> EcmaScript style - you predefine objects, with the
> properties accessible via get/set methods.
> 
> Why not just use JavaScript instead? 
> 
> thanks,
> rf
> 


It wasn't clear from my look at Rhino that it was capable of doing what 
Velocity does - and does very well!
What does Velocity do for me? It means that I don't have to write JSPs, 
while separating the View from the Model & Controller in a clean and 
efficient way. To generate an HTML page, I simply populate the Velocity 
Context with the data I need, and tell Velocity to merge the context 
with the template. The template is just HTML with embedded Velocity 
commands that can reference the data in the context (amongst other things).

Does Rhino do that?

I'm not anti-JavaScript - I use it client-side a lot - but I don't see 
how it would do what Velocity does.

Martin.



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


Re: Velocity Vs JavaScript

Posted by "Geir Magnusson Jr." <ge...@earthlink.net>.
On 10/8/02 4:30 AM, "RXZ JLo" <ru...@yahoo.com> wrote:

> From my first look at Velocity, it seems to follow
> EcmaScript style - you predefine objects, with the
> properties accessible via get/set methods.

It's more than that - you 'predefine' by placing your objects in the
context.  But you can access more than properties - you are able to call any
public method on the object or interface implemented by the object.  This is
what makes Velocity extensible, in that you can make the tools available to
the designer as rich as you want, and it's always in your control.

Geir

> 
> Why not just use JavaScript instead?
> 
> thanks,
> rf
> 
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
> 
> --
> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
> 

-- 
Geir Magnusson Jr. 
geirm@adeptra.com                                    +1-203-355-2219 (w)
Adeptra Inc.                                         +1-203-247-1713 (m)



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


RE: Velocity Vs JavaScript

Posted by Kevin Baynes <kb...@seagullsw.com>.
rf~

VTL is intentionally programmer crippled. It has the barest minimum of
functions, statements, methods and operators needed perform its job. This
makes it easy for designers to learn and use, and discourages placing any
programming logic into the templates. This concept is at the heart of Model
2 design and is the reason Template Engines exist.

JavaScript is a programming language. Using a programming language in
Velocity templates would defeat its mission of enforcing the
Model-View-Controller architecture.

~k

> -----Original Message-----
> From: RXZ JLo [mailto:rufoo2001@yahoo.com]
> Sent: Tuesday, October 08, 2002 4:31 AM
> To: velocity-user@jakarta.apache.org
> Subject: Velocity Vs JavaScript
>
>
> From my first look at Velocity, it seems to follow
> EcmaScript style - you predefine objects, with the
> properties accessible via get/set methods.
>
> Why not just use JavaScript instead?
>
> thanks,
> rf
>
> __________________________________________________
> Do you Yahoo!?
> Faith Hill - Exclusive Performances, Videos & More
> http://faith.yahoo.com
>
> --
> 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: Velocity Vs JavaScript

Posted by RXZ JLo <ru...@yahoo.com>.
--- Emyr James <em...@OrbisUK.com> wrote:
> Is that a joke ?
> Javascript is client side. Velocity is server side.
> How do you merge the details of an sql query into a
> page with javascript ?
> 


JavaScript is a general purpose scripting language.
People often use it in HTML pages, but that doesnt
mean Javascript is client side only. Have a look at
http://www.mozilla.org/rhino/ 

thanks,
rf

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

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


RE: Velocity Vs JavaScript

Posted by Emyr James <em...@OrbisUK.com>.
Is that a joke ?
Javascript is client side. Velocity is server side.
How do you merge the details of an sql query into a page with javascript ?

-----Original Message-----
From: RXZ JLo [mailto:rufoo2001@yahoo.com]
Sent: 08 October 2002 09:31
To: velocity-user@jakarta.apache.org
Subject: Velocity Vs JavaScript


>From my first look at Velocity, it seems to follow
EcmaScript style - you predefine objects, with the
properties accessible via get/set methods.

Why not just use JavaScript instead?

thanks,
rf

__________________________________________________
Do you Yahoo!?
Faith Hill - Exclusive Performances, Videos & More
http://faith.yahoo.com

--
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>