You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Tim Colson <tc...@cisco.com> on 2001/08/18 22:57:03 UTC
Can a Hash be created in #set?
I just figured out that one of the $biz objects was returning a String
rather than an int...which is why the following barfed:
#set ( $monthname = ["Jan", "Feb", "Mar"] )
$monthname.get($biz.month) ##$biz.month would be "1" instead of 1
I fixed the biz object to provide a method to return ints for now; but this
just got me wondering. The docs note creating an ArrayList, and how to use a
Hash from the context, but no mention of Hash creation.
Can a Hash be created in #set?
Cheers,
Timo
Re: Can a Hash be created in #set?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Christoph Reck wrote:
>
> > > Geir,
> > > an 'util' commons package was now created by jvz. It would be good to
> > > merge the 'ruppert' branch into this. The only contract there is that
> > > they should be of general use and shall not have any external
> > > dependencies (except java.*). I'm willing to do the required proposal
> > > and changes if I'm voted for as a comitter.
> >
> > That's 'Rupert' :)
> >
> > I guess util would be fine. Is this kind of stuff along the lines of
> > util? I was thinking also that we could drag it back here.
> >
> > geir
> >
> > >
> > > :) Christoph
>
> It's more than 90% along the 'util' line. That's why I originally posted
> it to land under org.apache.commons.util, but some people thought this
> sounded to general. Now that the contract was proposed in a proper manner,
> it makes more sense and 'util' should be fine for most of it.
>
> Since it is usable also away from velocity, it does not make sense
> to take it back here. It will make sense for many applications to
> include a commons_util.jar in the runtime.
>
> I might need to ensure the interfaces are proper (e.g. correct
> parameter and return types, etc. - Nathan's MathTool is good at this
> point). Very few other methods could then flow back into Vel.
Sounds good.
I will put some docs here pointing there then. We can also have some
examples here that show how to use them.
geir
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
Well done is better than well said - New England Proverb
Re: Can a Hash be created in #set?
Posted by Christoph Reck <Ch...@dlr.de>.
> > Geir,
> > an 'util' commons package was now created by jvz. It would be good to
> > merge the 'ruppert' branch into this. The only contract there is that
> > they should be of general use and shall not have any external
> > dependencies (except java.*). I'm willing to do the required proposal
> > and changes if I'm voted for as a comitter.
>
> That's 'Rupert' :)
>
> I guess util would be fine. Is this kind of stuff along the lines of
> util? I was thinking also that we could drag it back here.
>
> geir
>
> >
> > :) Christoph
It's more than 90% along the 'util' line. That's why I originally posted
it to land under org.apache.commons.util, but some people thought this
sounded to general. Now that the contract was proposed in a proper manner,
it makes more sense and 'util' should be fine for most of it.
Since it is usable also away from velocity, it does not make sense
to take it back here. It will make sense for many applications to
include a commons_util.jar in the runtime.
I might need to ensure the interfaces are proper (e.g. correct
parameter and return types, etc. - Nathan's MathTool is good at this
point). Very few other methods could then flow back into Vel.
:) Christoph
Re: Can a Hash be created in #set?
Posted by "Geir Magnusson Jr." <ge...@optonline.net>.
Christoph Reck wrote:
>
> Tim Colson wrote:
> >
> > I just figured out that one of the $biz objects was returning a String
> > rather than an int...which is why the following barfed:
> >
> > #set ( $monthname = ["Jan", "Feb", "Mar"] )
> > $monthname.get($biz.month) ##$biz.month would be "1" instead of 1
> >
> > I fixed the biz object to provide a method to return ints for now; but this
> > just got me wondering. The docs note creating an ArrayList, and how to use a
> > Hash from the context, but no mention of Hash creation.
> >
> > Can a Hash be created in #set?
> >
> > Cheers,
> > Timo
>
> If you really want to create more complex objects within VTL (a bit
> against MVC paradigm) you can use a context tool to create these.
>
> Please take a look at the http://jakarta.apache.org/commons sandbox.
> You will find a ContextTool within the CVS branch
> http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/rupert/src/java/org/apache/commons/rupert/christoph/ContextTool.java
> that allows you to create a Hashtable. Other tools that can be used
> within velocity can also be found there.
>
> Geir,
> an 'util' commons package was now created by jvz. It would be good to
> merge the 'ruppert' branch into this. The only contract there is that
> they should be of general use and shall not have any external
> dependencies (except java.*). I'm willing to do the required proposal
> and changes if I'm voted for as a comitter.
That's 'Rupert' :)
I guess util would be fine. Is this kind of stuff along the lines of
util? I was thinking also that we could drag it back here.
geir
>
> :) Christoph
--
Geir Magnusson Jr. geirm@optonline.net
System and Software Consulting
Developing for the web? See http://jakarta.apache.org/velocity/
Well done is better than well said - New England Proverb
Re: Can a Hash be created in #set?
Posted by Christoph Reck <Ch...@dlr.de>.
Tim Colson wrote:
>
> I just figured out that one of the $biz objects was returning a String
> rather than an int...which is why the following barfed:
>
> #set ( $monthname = ["Jan", "Feb", "Mar"] )
> $monthname.get($biz.month) ##$biz.month would be "1" instead of 1
>
> I fixed the biz object to provide a method to return ints for now; but this
> just got me wondering. The docs note creating an ArrayList, and how to use a
> Hash from the context, but no mention of Hash creation.
>
> Can a Hash be created in #set?
>
> Cheers,
> Timo
If you really want to create more complex objects within VTL (a bit
against MVC paradigm) you can use a context tool to create these.
Please take a look at the http://jakarta.apache.org/commons sandbox.
You will find a ContextTool within the CVS branch
http://cvs.apache.org/viewcvs/jakarta-commons-sandbox/rupert/src/java/org/apache/commons/rupert/christoph/ContextTool.java
that allows you to create a Hashtable. Other tools that can be used
within velocity can also be found there.
Geir,
an 'util' commons package was now created by jvz. It would be good to
merge the 'ruppert' branch into this. The only contract there is that
they should be of general use and shall not have any external
dependencies (except java.*). I'm willing to do the required proposal
and changes if I'm voted for as a comitter.
:) Christoph