You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@turbine.apache.org by Hugh Brien <hu...@novuscg.com> on 2001/10/31 17:13:41 UTC

Using complex classes and Velocity

I have a O-R model with three classes that represent a many to many
relationship.  When is the best way handle complex O-R mapping when
using Velocity as the template engine.  I would have rather used JSP
tempates but I have to work with Velocity
r,
Hugh

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


Re: Using complex classes and Velocity

Posted by Hugh Brien <hp...@home.com>.
Jason,
Thanks for the response.  I will endeavor to be a little more thoughtful in
the future.
I like the code sample much appreciatedr,
Hugh
----- Original Message -----
From: "Jason van Zyl" <jv...@zenplex.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Wednesday, October 31, 2001 7:23 PM
Subject: Re: Using complex classes and Velocity


> On 11/1/01 2:12 AM, "Hugh Brien" <hp...@home.com> wrote:
>
> > Sorry for the stupid question, it's not what I intended.  Let me put it
this
> > way:
> > Is is possible to pass parameters to an object that appears in a
Velocity
> > template.
>
> Yes.
>
> > One that pushed from the Velocity context ?
>
> Yes again!
>
> > How is that?
>
> The magic of reflection :-)
>
> If you place a little math tool in a velocity context, say:
>
> context.put("mathTool", new MathTool());
>
> Than in your template foo.vm you can use it's methods like so:
>
> #set ($firstBorn = 10)
> #set ($armAndLeg = 20)
>
> Your new version of XP will cost $mathTool.add($firstBorn, $armAndLeg)
> bucks!
>
> That's just a simple example. Geir has some great docs which you can find
> on the velocity site that go into much more detail.
>
> http://jakarta.apache.org/velocity/user-guide.html
>
> > r,
> > Hugh
> >
> > ----- Original Message -----
> > From: "Jason van Zyl" <jv...@zenplex.com>
> > To: "Turbine Users List" <tu...@jakarta.apache.org>
> > Sent: Wednesday, October 31, 2001 8:17 AM
> > Subject: Re: Using complex classes and Velocity
> >
> >
> >> On 10/31/01 11:13 AM, "Hugh Brien" <hu...@novuscg.com> wrote:
> >>
> >>> I have a O-R model with three classes that represent a many to many
> >>> relationship.  When is the best way handle complex O-R mapping when
> >>> using Velocity as the template engine.  I would have rather used JSP
> >>> tempates but I have to work with Velocity
> >>> ,
> >>
> >
> >> Yaay! That's the first time I've heard that!
> >
> >>
> >> If your O-R classes are like beans than you can use them in the
velocity
> >> context in a similar way you use your beans in JSP pages. You'll have
to
> >> provide a little more detail for useful help.
> >>
> >>
> >>> Hugh
> >>>
> >>> --
> >>> To unsubscribe, e-mail:
> > <ma...@jakarta.apache.org>
> >>> For additional commands, e-mail:
> > <ma...@jakarta.apache.org>
> >>
> >> --
> >>
> >> jvz.
> >>
> >> Jason van Zyl
> >>
> >> http://tambora.zenplex.org
> >> http://jakarta.apache.org/turbine
> >> http://jakarta.apache.org/velocity
> >> http://jakarta.apache.org/alexandria
> >> http://jakarta.apache.org/commons
> >>
> >>
> >>
> >> --
> >> 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>
>
> --
>
> jvz.
>
> Jason van Zyl
>
> http://tambora.zenplex.org
> http://jakarta.apache.org/turbine
> http://jakarta.apache.org/velocity
> http://jakarta.apache.org/alexandria
> http://jakarta.apache.org/commons
>
>
>
> --
> 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: Using complex classes and Velocity

Posted by Jason van Zyl <jv...@zenplex.com>.
On 11/1/01 2:12 AM, "Hugh Brien" <hp...@home.com> wrote:

> Sorry for the stupid question, it's not what I intended.  Let me put it this
> way:
> Is is possible to pass parameters to an object that appears in a Velocity
> template.

Yes.

> One that pushed from the Velocity context ?

Yes again!

> How is that?

The magic of reflection :-)

If you place a little math tool in a velocity context, say:

context.put("mathTool", new MathTool());

Than in your template foo.vm you can use it's methods like so:

#set ($firstBorn = 10)
#set ($armAndLeg = 20)

Your new version of XP will cost $mathTool.add($firstBorn, $armAndLeg)
bucks!

That's just a simple example. Geir has some great docs which you can find
on the velocity site that go into much more detail.

http://jakarta.apache.org/velocity/user-guide.html

> r,
> Hugh
> 
> ----- Original Message -----
> From: "Jason van Zyl" <jv...@zenplex.com>
> To: "Turbine Users List" <tu...@jakarta.apache.org>
> Sent: Wednesday, October 31, 2001 8:17 AM
> Subject: Re: Using complex classes and Velocity
> 
> 
>> On 10/31/01 11:13 AM, "Hugh Brien" <hu...@novuscg.com> wrote:
>> 
>>> I have a O-R model with three classes that represent a many to many
>>> relationship.  When is the best way handle complex O-R mapping when
>>> using Velocity as the template engine.  I would have rather used JSP
>>> tempates but I have to work with Velocity
>>> ,
>> 
> 
>> Yaay! That's the first time I've heard that!
> 
>> 
>> If your O-R classes are like beans than you can use them in the velocity
>> context in a similar way you use your beans in JSP pages. You'll have to
>> provide a little more detail for useful help.
>> 
>> 
>>> Hugh
>>> 
>>> --
>>> To unsubscribe, e-mail:
> <ma...@jakarta.apache.org>
>>> For additional commands, e-mail:
> <ma...@jakarta.apache.org>
>> 
>> --
>> 
>> jvz.
>> 
>> Jason van Zyl
>> 
>> http://tambora.zenplex.org
>> http://jakarta.apache.org/turbine
>> http://jakarta.apache.org/velocity
>> http://jakarta.apache.org/alexandria
>> http://jakarta.apache.org/commons
>> 
>> 
>> 
>> --
>> 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>

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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


Re: Using complex classes and Velocity

Posted by Hugh Brien <hp...@home.com>.
Sorry for the stupid question, it's not what I intended.  Let me put it this
way:
Is is possible to pass parameters to an object that appears in a Velocity
template.
One that pushed from the Velocity context ?
How is that?
r,
Hugh

----- Original Message -----
From: "Jason van Zyl" <jv...@zenplex.com>
To: "Turbine Users List" <tu...@jakarta.apache.org>
Sent: Wednesday, October 31, 2001 8:17 AM
Subject: Re: Using complex classes and Velocity


> On 10/31/01 11:13 AM, "Hugh Brien" <hu...@novuscg.com> wrote:
>
> > I have a O-R model with three classes that represent a many to many
> > relationship.  When is the best way handle complex O-R mapping when
> > using Velocity as the template engine.  I would have rather used JSP
> > tempates but I have to work with Velocity
> > ,
>

> Yaay! That's the first time I've heard that!

>
> If your O-R classes are like beans than you can use them in the velocity
> context in a similar way you use your beans in JSP pages. You'll have to
> provide a little more detail for useful help.
>
>
> > Hugh
> >
> > --
> > To unsubscribe, e-mail:
<ma...@jakarta.apache.org>
> > For additional commands, e-mail:
<ma...@jakarta.apache.org>
>
> --
>
> jvz.
>
> Jason van Zyl
>
> http://tambora.zenplex.org
> http://jakarta.apache.org/turbine
> http://jakarta.apache.org/velocity
> http://jakarta.apache.org/alexandria
> http://jakarta.apache.org/commons
>
>
>
> --
> 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: Using complex classes and Velocity

Posted by Jason van Zyl <jv...@zenplex.com>.
On 10/31/01 11:13 AM, "Hugh Brien" <hu...@novuscg.com> wrote:

> I have a O-R model with three classes that represent a many to many
> relationship.  When is the best way handle complex O-R mapping when
> using Velocity as the template engine.  I would have rather used JSP
> tempates but I have to work with Velocity
> ,

Yaay! That's the first time I've heard that!

If your O-R classes are like beans than you can use them in the velocity
context in a similar way you use your beans in JSP pages. You'll have to
provide a little more detail for useful help.


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

-- 

jvz.

Jason van Zyl

http://tambora.zenplex.org
http://jakarta.apache.org/turbine
http://jakarta.apache.org/velocity
http://jakarta.apache.org/alexandria
http://jakarta.apache.org/commons



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