Re: get value from map

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Re: get value from map

Marius Dumitru Florea
Hi,

My advice is to write the code in Java first and then adapt it for
Velocity. In Velocity you work with Java objects and you must know their
API.

Bubulina wrote:
> Hello,
> i Have this hashmap that i populate.
> no when i want to show in a table the key : value i get an error. this is
> the code:
> ....
> #foreach($pageName in $myMap.keySet())
> #foreach($dateDoc in $myMap.values())

I can't think of a reason to do this two nested loops. They are not
semantically connected.

> <tr>

>    <td> $pageName  $pageName </td>

not relevant

>    <td>$pageName.getValue() </td>

$pageName is the map key. What is its type? Does it have a getValue()
method?

>    <td>delete</td>

not relevant

> </tr>

> #set($count = $count +1)

not relevant

> #end
> #end
> ...
>

Also, when you post some code snippet and ask for help please post only
what's relevant. This is a good exercise for you: simply the code as
much as possible while preserving the error/misbehavior. By doing this,
in most of the cases you'll discover the problem yourself.

> if i comment the second foreach i don't get an error, but i have nothing to
> populate the date field with.
> do you know what i am doing wrong here?

What is the error? How can we help you if we don't know the error?..

Marius

> Thank you
_______________________________________________
users mailing list
[hidden email]
http://lists.xwiki.org/mailman/listinfo/users
Reply | Threaded
Open this post in threaded view
|

Re: get value from map


>    
not relevant

>    
$pageName is the map key. What is its type? Does it have a getValue()
method?

>    
not relevant

>
> #set($count = $count +1)

not relevant

> #end
> #end
> ...
>

Also, when you post some code snippet and ask for help please post only
what's relevant. This is a good exercise for you: simply the code as
much as possible while preserving the error/misbehavior. By doing this,
in most of the cases you'll discover the problem yourself.

> if i comment the second foreach i don't get an error, but i have nothing to
> populate the date field with.
> do you know what i am doing wrong here?

What is the error? How can we help you if we don't know the error?..

Marius

> Thank you
_______________________________________________
users mailing list
users@xwiki.org
http://lists.xwiki.org/mailman/listinfo/users
Bubulina
Hello
sorry for this. it was a simple thing.my bad was . i just had to use: $myMap.get($pageName)
Thx still :)

Marius Dumitru Florea wrote
Hi,

My advice is to write the code in Java first and then adapt it for
Velocity. In Velocity you work with Java objects and you must know their
API.

Bubulina wrote:
> Hello,
> i Have this hashmap that i populate.
> no when i want to show in a table the key : value i get an error. this is
> the code:
> ....
> #foreach($pageName in $myMap.keySet())
> #foreach($dateDoc in $myMap.values())

I can't think of a reason to do this two nested loops. They are not
semantically connected.

>
 $pageName  $pageName $pageName.getValue() delete