velocity-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Geir Magnusson Jr." <ge...@optonline.net>
Subject Re: directives, alternative implementation
Date Sat, 02 Mar 2002 02:36:50 GMT
On 3/1/02 6:59 PM, "Dmitri Colebatch" <dim@nuix.com.au> wrote:

> hey all,
> 
> firstly, this is my first usage of Velocity, so if there's an FAQ I should've
> read that answers this - please point (o;  (I have
> read most of the stuff I've been able to find).  Secondly, I think this is
> probably more a dev question, but by rights, I should ask
> here first, so I am (o:
> 
> ok... I'm trying to implement a javascript powered framework, allowing someone
> to write javascript servlet/action style classes, and
> use them in their pages on the server side.  Velocity seems to be a good
> choice for the pages as javascript being a dynamicaly typed
> interpreted language I need to be able to implement the glue between the pages
> and the javascript classes at runtime, which Velocity
> looks like it'll let me do.
> 

Why do you want to do this?

> What I want to do, is in my servlet, put a couple of Javascript objects
> (implementing the Rhino Scriptable interface) int he
> context.  Thing is, when I call
> 
> $myObject.foo()
> 
> in my template, I need that to call a method
> 
> jsFunction_foo()
> 
> on that object ... essentially every directive will need to change in some
> form for this to work.  So I'm looking in the
> org.apache.velocity.runtime.parser.node package at classes like ASTReference,
> which appear to be responsible for handling all this.

Why do the directives have to change?  Why not wrap the javascript stuff in
a Java class?

> 
> So, onto my questions:
> 
> 1. I've never used jjtree or Javacc before, and want to know how I should
> understand the way the node package is created (from what
> I gather it(/parts of it) is(/are) generated by this.

That really isn't a question.
 
> 2. Has anyone else done this sort of thing, for Rhino, or anyhting else, that
> I might be able to get a head start from?
> 
> 3. The way I'm looking at things so far, is something like this.... for
> ASTIdentifier, I've added the following lines of code to
> doIntrospection() after the last try...
> 
>       if( executor.isAlive() == false)
>       {
>           executor = new ScriptablePropertyExecutor( rsvc, data, identifier );
>       }
> 
> and then made the new ScriptablePropertyExecutor a subclass of
> PropertyExecutor and overridden the discover method.  This seems to
> be the right thing to do, but I think that I'm going to have to get all the
> pieces in the puzzle before it'll work properly.
> 
> ok - so if anyone can offer any feedback, that would be great...  if not, I
> might try the dev list.

My question - why do this by changing velocity?  Why not put a layer in
between the javascript and Velocity via a normal Java class?

-- 
Geir Magnusson Jr.                                     geirm@optonline.net
System and Software Consulting
POC lives!


--
To unsubscribe, e-mail:   <mailto:velocity-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:velocity-user-help@jakarta.apache.org>


Mime
View raw message