You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@velocity.apache.org by Magne Skjeret <ma...@broadpark.no> on 2004/08/05 10:38:24 UTC

hashtable dot in key

Hi

I have a problem with looking up in a hashtable from the template when 
the key has a dot in it.

E.G
$!i18n.tab.type

I understand why this example wont work, but is there a way I can do 
this? Escaping the dot somehow.

Magne




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


Re: hashtable dot in key

Posted by Nathan Bubna <na...@esha.com>.
Magne Skjeret said:
> Magne Skjeret wrote:
...
> > I have a problem with looking up in a hashtable from the template when
> > the key has a dot in it.
> >
> > E.G
> > $!i18n.tab.type
> >
> > I understand why this example wont work, but is there a way I can do
> > this? Escaping the dot somehow.
>
> Of course using the get method direclty will work, but a cleaner
> solution is appreciated.

$!i18n.get('tab.type')

is a pretty clean solution IMHO.  anyway, there's no way to escape the dot.
so that's as clean as you'll get without changing the key or using some magic
key-appending object.  not that a magic key-appending object is really
"cleaner" in my opinion, but if you want an example of something like that,
then check out:

http://cvs.apache.org/viewcvs.cgi/jakarta-velocity-tools/src/java/org/apache/velocity/tools/struts/MessageTool.java?rev=1.14&view=auto

Nathan Bubna
nathan@esha.com


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


Re: hashtable dot in key

Posted by Magne Skjeret <ma...@broadpark.no>.
Magne Skjeret wrote:

> Hi
>
> I have a problem with looking up in a hashtable from the template when 
> the key has a dot in it.
>
> E.G
> $!i18n.tab.type
>
> I understand why this example wont work, but is there a way I can do 
> this? Escaping the dot somehow.

Of course using the get method direclty will work, but a cleaner 
solution is appreciated.

Magne

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


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