|
From: Seth L. <se...@eh...> - 2004-03-17 18:23:44
|
Rim, Mark wrote:
> jozsa,
>
> well, for now, i think the short answer is yes. you do have to manually parse
> request parameters. otherwise, you could look through some source code and
> override methods at just the right points. but manual parsing might be easier.
>
> it looks like the issue is in the bean framework and not in the web stuff.
> although you can "get" map values by key using the BeanWrapper, you cannot set
> them. for example,
>
> MapBean tb = new MapBean();
> BeanWrapper bw = new BeanWrapperImpl(tb);
> tb.getMap().put("key1","value1");
> # the following works
> assertEquals("value1", bw.getPropertyValue("map[key1]"));
> # the next statement fails
> bw.setPropertyValue("map[key1]","value2");
>
> since mvc bindings (probably) depends on the bean framework, this is the
> likely cause of your pain. this may be by-design or a bug. i raised the issue
> on the developer mailing list during a bout with insomnia last night.
What is the current status on this issue for a 1.0 release? Do the
developers feel this is an issue to be fixed?
Judging from the amount of questions related to this issue found in the
forums and mailing lists (including my own) I feel this a feature worth
implementing.
It provides some symmetry with how getPropertyValue works. Also, many
of Spring's MVC users are Struts converts. The above functionality is
present in Struts, and having it in Spring would make porting those
applications to Spring easier and more straight forward.
If this functionality won't be added for 1.0, it would be very helpful
to have a workaround posted.
There are many patches for this, including my own, that are good
starting points. Most are labeled "hacks" so having the developer's
feedback would be very useful. :)
Thoughts or comments?
Thanks!
Seth
|
|
From: <jue...@we...> - 2004-03-18 14:54:50
|
FYI, I've just added support for directly setting bean property values =
in arrays, lists, and maps. So code like the following will now work, =
just like the getPropertyValue counterparts:
=20
MutablePropertyValues pvs =3D new MutablePropertyValues();
pvs.addPropertyValue("array[0]", tb5);
pvs.addPropertyValue("array[1]",tb4);
pvs.addPropertyValue("list[0]", tb3);
pvs.addPropertyValue("list[1]", tb2);
pvs.addPropertyValue("map[key1]", tb1);
pvs.addPropertyValue("map['key2']", tb0);
bw.setPropertyValues(pvs);
=20
Note that you can't set array elements outside of the size of the array, =
and can only set List elements within the List or added to the end of =
the List.
=20
Of course, this is straightforwardly available in =
ServletRequestDataBinder and consequently Spring's out-of-the-box =
command/form controller implementations.
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Seth Ladd
Gesendet: Mi 17.03.2004 19:23
An: spr...@li...
Betreff: [Springframework-developer] Re: [Springframework-user] =
java.util.Map binder in spring-mvc?
Rim, Mark wrote:
> jozsa,
>
> well, for now, i think the short answer is yes. you do have to =
manually parse
> request parameters. otherwise, you could look through some source code =
and
> override methods at just the right points. but manual parsing might be =
easier.
>
> it looks like the issue is in the bean framework and not in the web =
stuff.
> although you can "get" map values by key using the BeanWrapper, you =
cannot set
> them. for example,
>
> MapBean tb =3D new MapBean();
> BeanWrapper bw =3D new BeanWrapperImpl(tb);
> tb.getMap().put("key1","value1");
> # the following works
> assertEquals("value1", bw.getPropertyValue("map[key1]"));
> # the next statement fails
> bw.setPropertyValue("map[key1]","value2");
>
> since mvc bindings (probably) depends on the bean framework, this is =
the
> likely cause of your pain. this may be by-design or a bug. i raised =
the issue
> on the developer mailing list during a bout with insomnia last night.
What is the current status on this issue for a 1.0 release? Do the
developers feel this is an issue to be fixed?
Judging from the amount of questions related to this issue found in the
forums and mailing lists (including my own) I feel this a feature worth
implementing.
It provides some symmetry with how getPropertyValue works. Also, many
of Spring's MVC users are Struts converts. The above functionality is
present in Struts, and having it in Spring would make porting those
applications to Spring easier and more straight forward.
If this functionality won't be added for 1.0, it would be very helpful
to have a workaround posted.
There are many patches for this, including my own, that are good
starting points. Most are labeled "hacks" so having the developer's
feedback would be very useful. :)
Thoughts or comments?
Thanks!
Seth
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=3D1470&alloc_id=3D3638&op=3Dcli=
ck
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|
|
From: <jue...@we...> - 2004-03-18 14:57:26
|
FYI, I've just added support for directly setting bean property values =
in arrays, lists, and maps. So code like the following will now work, =
just like the getPropertyValue counterparts:
=20
MutablePropertyValues pvs =3D new MutablePropertyValues();
pvs.addPropertyValue("array[0]", tb5);
pvs.addPropertyValue("array[1]",tb4);
pvs.addPropertyValue("list[0]", tb3);
pvs.addPropertyValue("list[1]", tb2);
pvs.addPropertyValue("map[key1]", tb1);
pvs.addPropertyValue("map['key2']", tb0);
bw.setPropertyValues(pvs);
=20
Note that you can't set array elements outside of the size of the array, =
and can only set List elements within the List or added to the end of =
the List.
=20
Of course, this is straightforwardly available in =
ServletRequestDataBinder and consequently Spring's out-of-the-box =
command/form controller implementations.
=20
Juergen
=20
________________________________
Von: spr...@li... im Auftrag =
von Seth Ladd
Gesendet: Mi 17.03.2004 19:23
An: spr...@li...
Betreff: [Springframework-developer] Re: [Springframework-user] =
java.util.Map binder in spring-mvc?
Rim, Mark wrote:
> jozsa,
>
> well, for now, i think the short answer is yes. you do have to =
manually parse
> request parameters. otherwise, you could look through some source code =
and
> override methods at just the right points. but manual parsing might be =
easier.
>
> it looks like the issue is in the bean framework and not in the web =
stuff.
> although you can "get" map values by key using the BeanWrapper, you =
cannot set
> them. for example,
>
> MapBean tb =3D new MapBean();
> BeanWrapper bw =3D new BeanWrapperImpl(tb);
> tb.getMap().put("key1","value1");
> # the following works
> assertEquals("value1", bw.getPropertyValue("map[key1]"));
> # the next statement fails
> bw.setPropertyValue("map[key1]","value2");
>
> since mvc bindings (probably) depends on the bean framework, this is =
the
> likely cause of your pain. this may be by-design or a bug. i raised =
the issue
> on the developer mailing list during a bout with insomnia last night.
What is the current status on this issue for a 1.0 release? Do the
developers feel this is an issue to be fixed?
Judging from the amount of questions related to this issue found in the
forums and mailing lists (including my own) I feel this a feature worth
implementing.
It provides some symmetry with how getPropertyValue works. Also, many
of Spring's MVC users are Struts converts. The above functionality is
present in Struts, and having it in Spring would make porting those
applications to Spring easier and more straight forward.
If this functionality won't be added for 1.0, it would be very helpful
to have a workaround posted.
There are many patches for this, including my own, that are good
starting points. Most are labeled "hacks" so having the developer's
feedback would be very useful. :)
Thoughts or comments?
Thanks!
Seth
-------------------------------------------------------
This SF.Net email is sponsored by: IBM Linux Tutorials
Free Linux tutorial presented by Daniel Robbins, President and CEO of
GenToo technologies. Learn everything from fundamentals to system
administration.http://ads.osdn.com/?ad_id=3D1470&alloc_id=3D3638&op=3Dcli=
ck
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|