This week's book giveaway is in the Programmer Certification forum.
We're giving away four copies of OCP Oracle Certified Professional Java SE 21 Developer Study Guide: Exam 1Z0-830 and have Jeanne Boyarsky & Scott Selikoff on-line!
See this thread for details.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

Accessing a HashMap using Struts 2

 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi everyone,

I have two concerns that have been annoying me since quite some time now.

I have hashmap that was created on a page using the struts2 <s:set> tag. It looks something like this


At some point in the page, i need to get a value from the hashmap based upon a key, and i want to do it using OGNL. I dont want to iterate the map. I simply need to get a single value from the map. How am i supposed to do that without iterating?

The second problem is the following
The key is generated based upon some logic, which i store using another <s:set> tag. Something like this


I need to get a value from the hashmap using this key. And i need to display it.

How do i simply call the get function on the hashmap?

I tried this

and this

and this


The third one obviously does not work because of the nesting problem. But the same nesting logic is applicable to the second case as well, due to the manner the value attribute is handled. However none seem to work for me.


I suppose the issues are very simple. I almost feel that i get it, but somehow the solution eludes me.
Could someone please tell me what i am missing here?

Regards,
Ryan Sukale
 
ryan sukale
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Ok guys, i got it

I suppose i was using a different version of struts wherein using the %{} was required for the expression to be evaluated. I changed the jar files now. This is what did the job for me

<s:property value="#mymap.[#mykey2]"/>

My problem was coming because i was trying to use it in a href for a s:a tag. And without the %{} operator, the expression was not being evaluated.

So, i guess, i was right in the beginning itself. Rest of the time, it was just me making silly mistakes. :>

Regards,
Ryan Sukale
 
I child proofed my house but they still get in. Distract them with this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic