• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Struts 2 parameter mapping issue

 
Ranch Hand
Posts: 61
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a problem populating a parameter to a Map<String, String>. I have the following parameter that does not get placed in the newValue within my model which has a getter and setter for newValue:

newValue['1234-5'] = ABCDE

But if I have the following it works:

newValue['12345'] = ABCDE

I am wondering why it does not populate the map when I have a dash?
 
Ranch Hand
Posts: 485
Eclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Let us know what you are doing? What you are type of field being populated?
 
Don Blodgett
Ranch Hand
Posts: 61
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the following classes, MyModel is set into MyAction through the use of Spring:





When I pass as a parameter the following, the newValues Map in MyModel is null:



If I pass the parameter as the following, the newValues Map in MyModel has the key/value pair of 12345=ABCDE:



The only difference is that in the non-working parameter I have a dash in the key and the working parameter I do not have the dash in the key.

The dash is important to have as it is part of the unique Id for this process.

I have found another way of doing this by creating a list of custom model classes that has a key and value field, but I am still wondering why a Map will not work for this case.
 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have the exactly same problem! (map with dashes in the key)

Do you have any workaround or solution?


EDIT: I solved myself, replacing the dashes ("-") to underscores ("_") in JSP, than, replaced back in the controller.
 
Don't get me started about those stupid light bulbs.
reply
    Bookmark Topic Watch Topic
  • New Topic