[xwiki-users] get value from map
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()) <tr> <td> $pageName $pageName </td> <td>$pageName.getValue() </td> <td>delete</td> </tr> #set($count = $count +1) #end #end ... 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? Thank you -- View this message in context: http://n2.nabble.com/get-value-from-map-tp4138399p4138399.html Sent from the XWiki- Users mailing list archive at Nabble.com.
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
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.
<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 [email protected] http://lists.xwiki.org/mailman/listinfo/users
-- View this message in context: http://n2.nabble.com/Re-get-value-from-map-tp4138709p4138718.html Sent from the XWiki- Users mailing list archive at Nabble.com.
participants (2)
-
Bubulina -
Marius Dumitru Florea