|
From: JP P. <jp....@ti...> - 2003-07-07 20:41:10
|
In my case, there is no add or delete, only selection in well known
number of elements (used for instantiation of the array). I didn't try
with a list but the conversion is perhaps made internally. At least with
arrays, the two minor changes I proposed work as I use them. If lists
work also it will no care about the number of elements.
Jean-Pierre
-----Message d'origine-----
De=A0: spr...@li...
[mailto:spr...@li...] De la
part de JP Pawlak
Envoy=E9=A0: lundi 7 juillet 2003 21:55
=C0=A0: 'j=FCrgen h=F6ller [werk3AT]'; 'Rhandy Lado'
Cc=A0: spr...@li...
Objet=A0: RE : [Springframework-developer] RE: [Springframework] Request
Binding
Hi Juergen,
I'm not sure that my answer is related to this, maybe.
I had to handle with multiselect listboxes. The issue is the same with
checkboxes. The form returns many values for the same identifier. I just
take a look at the code. It is already the same as in the original
framework and don't handle this situation.
I had modified in my own i21 version the
com.interface21.web.util.WebUtils class the method
getParametersStartingWith(ServletRequest as follows:
----------------------
public static Properties getParametersStartingWith(ServletRequest
request, String base) {
Enumeration enum =3D request.getParameterNames();
Properties props =3D new Properties();
=09
if (base =3D=3D null)
base =3D "";
while (enum !=3D null && enum.hasMoreElements()) {
String paramName =3D (String) enum.nextElement();
if (base =3D=3D null || "".equals(base) ||
paramName.startsWith(base)) {
String val =3D request.getParameter(paramName);
// JPP My add
if (request.getParameterValues(paramName).length > 1) {
val =3D
StringUtils.arrayToDelimitedString(request.getParameterValues(paramName)
, ","); =09
}
// JPP End My add
String unprefixed =3D
paramName.substring(base.length());
props.setProperty(unprefixed, val);
}
}
return props;
} // getParameterValuesStartingWith
--------------
By the way, I checked what others change I made and discover also I
added in com.interface21.beans.propertyeditors.
StringArrayPropertyEditor the getAsText method:
public String getAsText() {
String[] array =3D (String[])this.getValue();
return StringUtils.arrayToDelimitedString(array,",");
}
Even if it's not related with Rhandy's question, can I or you integrate
these changes?
Regards,
Jean-Pierre=20
-----Message d'origine-----
De=A0: spr...@li...
[mailto:spr...@li...] De la
part de j=FCrgen h=F6ller [werk3AT]
Envoy=E9=A0: lundi 7 juillet 2003 19:26
=C0=A0: Rhandy Lado
Cc=A0: spr...@li...
Objet=A0: [Springframework-developer] RE: [Springframework] Request
Binding
Hi Rhandy,
For multiple form objects, you could use custom objects that you bind
parameters onto via BindUtils and put in the session as some custom
attribute. I consider it preferable to use a different strategy though:
Not a map, but a custom root object that contains the form objects as
bean properties, like a MyRootObject class with getMyFirstObject and
getMySecondFormObject methods. It's easy to bind to the contained
objects via nested properties, e.g. "myFirstFormObject.myProperty" and
"mySecondFormObject.myOtherProperty".
Regarding a list of objects, it's probably indeed the best way to parse
respective request parameters manually, in a custom onBindAndValidate
implementation. Especially if you want to add and remove elements, I
can't think of a different way. We could try to bind to an existing list
of objects, but it's not too obvious how to go about this (via an index?
what if it's a Set, Collection, or Map), so we don't support this yet.
If you have an idea how to achieve this, please let me know :-)
Regards,
Juergen
-----Original Message-----
From: Rhandy Lado [mailto:rh...@do...]
Sent: Monday, July 07, 2003 10:49 AM
To: j=FCrgen h=F6ller [werk3AT]
Subject: [Springframework] Request Binding
Hi Jurgen,
I've been using the FormController classes in a few webpages now and
found that I sometimes need to work with more than one form object. How
do I return more than two objects and bind each of them in the webpage?
Should I put each object in a Map and then return the map? If so, how do
you access the map using the <i21:bind> tags?
Also, I have a list defined in my form object. Do the <i21:bind> tags
support binding data to a list? If not, do you have any suggestions on
how I may go about this? (I was initially thinking of passing back a
series of request parameters and manually adding these values to the
form object list but I have a feeling there is a more elegant way of
doing this.)
Thanks in advance,
Rhandy
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
-------------------------------------------------------
This SF.Net email sponsored by: Free pre-built ASP.NET sites including
Data Reports, E-commerce, Portals, and Forums are available now.
Download today and enter to win an XBOX or Visual Studio .NET.
http://aspnet.click-url.com/go/psa00100006ave/direct;at.asp_061203_01/01
_______________________________________________
Springframework-developer mailing list
Spr...@li...
https://lists.sourceforge.net/lists/listinfo/springframework-developer
|