You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@struts.apache.org by "Vladimir A. Balandin (JIRA)" <ji...@apache.org> on 2007/11/09 11:32:34 UTC

[jira] Created: (WW-2309) Don't set values to map with integer keys

Don't set values to map with integer keys
-----------------------------------------

                 Key: WW-2309
                 URL: https://issues.apache.org/struts/browse/WW-2309
             Project: Struts 2
          Issue Type: Bug
          Components: Core Actions, Expression Language, Value Stack
    Affects Versions: 2.0.9
            Reporter: Vladimir A. Balandin
            Priority: Critical


Parameters binding don't work properly when parameter 'map[key]' given from jsp, but if  'key' field will be an instance of String, it's work. 
In jsp it's don't work, too.
The tag <s:property value="map[key]" /> will display empty string.

class SomeAction {
     Integer key = 1;
     Map map = new HashMap();
     void setKey(Integer value) {
         this.key = key;
     }
     Integer getKey() {
        return key;
     }
     Map getMap() {
        return map;
     }
     void setMap(Map map) {
         this.map = map;
     }
     public String execute() {
         System.out.println("map[key]: " + map.get(key));
         return "success";
     }
 }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2309) Don't set values to map with integer keys

Posted by "Vladimir A. Balandin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42745 ] 

Vladimir A. Balandin commented on WW-2309:
------------------------------------------

I suggest to add this hint to the struts references.

> Don't set values to map with integer keys
> -----------------------------------------
>
>                 Key: WW-2309
>                 URL: https://issues.apache.org/struts/browse/WW-2309
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions, Expression Language, Value Stack
>    Affects Versions: 2.0.9
>            Reporter: Vladimir A. Balandin
>            Priority: Critical
>
> Parameters binding don't work properly when parameter 'map[key]' given from jsp, but if  'key' field will be an instance of String, it's work. 
> In jsp it's don't work, too.
> The tag <s:property value="map[key]" /> will display empty string.
> class SomeAction {
>      Integer key = 1;
>      Map map = new HashMap();
>      void setKey(Integer value) {
>          this.key = key;
>      }
>      Integer getKey() {
>         return key;
>      }
>      Map getMap() {
>         return map;
>      }
>      void setMap(Map map) {
>          this.map = map;
>      }
>      public String execute() {
>          System.out.println("map[key]: " + map.get(key));
>          return "success";
>      }
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2309) Don't set values to map with integer keys

Posted by "Marcin Wolak (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42740 ] 

Marcin Wolak commented on WW-2309:
----------------------------------

 The problem is that while using such sample the map is filled with "1" as a key but the type of it is String. That's why later on when one wants to get value for the key(but than the key type is Integer) one gets nothing.
 I'have invesigated the way xwork determines types of keys - by default if no type is speicified it becomes String.
 The way I used to indicate the type which should be used is using Key annotation(http://wiki.opensymphony.com/display/XW/Key+Annotation).
 Maybe there is also some other way to define it, didn't check. In our example,  the annotation should be added on key element getter and should look like:

	@Key( value = Integer.class )
	public Integer getKey() { 
		return key; 
	} 


> Don't set values to map with integer keys
> -----------------------------------------
>
>                 Key: WW-2309
>                 URL: https://issues.apache.org/struts/browse/WW-2309
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions, Expression Language, Value Stack
>    Affects Versions: 2.0.9
>            Reporter: Vladimir A. Balandin
>            Priority: Critical
>
> Parameters binding don't work properly when parameter 'map[key]' given from jsp, but if  'key' field will be an instance of String, it's work. 
> In jsp it's don't work, too.
> The tag <s:property value="map[key]" /> will display empty string.
> class SomeAction {
>      Integer key = 1;
>      Map map = new HashMap();
>      void setKey(Integer value) {
>          this.key = key;
>      }
>      Integer getKey() {
>         return key;
>      }
>      Map getMap() {
>         return map;
>      }
>      void setMap(Map map) {
>          this.map = map;
>      }
>      public String execute() {
>          System.out.println("map[key]: " + map.get(key));
>          return "success";
>      }
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.


[jira] Commented: (WW-2309) Don't set values to map with integer keys

Posted by "Vladimir A. Balandin (JIRA)" <ji...@apache.org>.
    [ https://issues.apache.org/struts/browse/WW-2309?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_42748 ] 

Vladimir A. Balandin commented on WW-2309:
------------------------------------------

Might the problem WW-2342 is similar to this.

> Don't set values to map with integer keys
> -----------------------------------------
>
>                 Key: WW-2309
>                 URL: https://issues.apache.org/struts/browse/WW-2309
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Core Actions, Expression Language, Value Stack
>    Affects Versions: 2.0.9
>            Reporter: Vladimir A. Balandin
>            Priority: Critical
>
> Parameters binding don't work properly when parameter 'map[key]' given from jsp, but if  'key' field will be an instance of String, it's work. 
> In jsp it's don't work, too.
> The tag <s:property value="map[key]" /> will display empty string.
> class SomeAction {
>      Integer key = 1;
>      Map map = new HashMap();
>      void setKey(Integer value) {
>          this.key = key;
>      }
>      Integer getKey() {
>         return key;
>      }
>      Map getMap() {
>         return map;
>      }
>      void setMap(Map map) {
>          this.map = map;
>      }
>      public String execute() {
>          System.out.println("map[key]: " + map.get(key));
>          return "success";
>      }
>  }

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.