struts-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eric Lentz <Eric.Le...@sherwin.com>
Subject "/" character an invalid key?
Date Thu, 07 Jul 2011 12:50:33 GMT
I'm using Struts 2.2.1.

I have a use case whereby form fields are generated dynamically and some 
of them are select lists. Since it is a database driven list of fields, 
the labels presented for the user are also used as keys for the map that 
the form posts back to. Using alternate keys is not desirable.

That's brief background to attempt at justification for what I'm doing. To 
provide a simple example, this is the equivalent to one of the select 
lists that gets created:
        <s:select list="#{'Interior':'Interior','Exterior':'Exterior'}" 
                          name='foo["Interior/Exterior"]' 
                          headerKey="-1" 
                          headerValue="Select One" />

Interior/Exterior, as a key, seems to be an issue. Using that on a test 
form and a test action that has the following:

                if(foo == null) {
                        bar = "Foo is null";
                }
                else if(foo.containsKey("Interior/Exterior")) {
                        bar = foo.get("Interior/Exterior");
                }
                else {
                        bar = "Not Found";
                }

bar always gets assigned "Foo is null".

Any ideas why the "/" character contained in a key would make it invalid? 
I tested using that exact key in a map and Java is fine with it. Since foo 
is null, it appears to not be passed at all. I tried various escaping 
(e.g., "\/"), but it still comes back null when "/" is in the key.

The page, action and configuration I used to test this is here: 
http://www.chopapp.com/#32ycxelq

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message