|
From: <jue...@we...> - 2003-10-23 17:33:32
|
Everybody, Seems like we've got two people inquiring for indexed property support. = The second already dates back to mid-September :-( I've just rechecked the BeanWrapper implementation and discovered that = there is no proper support for indexed properties yet. The existing = getIndexedProperty method was not complete (e.g. no support for nesting) = and untested (no unit test covered it), so I've decided to remove it for = the time being (for 1.0 M2). It just confused both of those guys that = were looking for indexed property support. Jakarta Commons BeanUtils does support nested and mapped properties, = quoting from the javadocs of their PropertyUtils class: <quote> For the purposes of this class, five formats for referencing a = particular property value of a bean are defined, with the layout of an = identifying String in parentheses:=20 * Simple (name) - The specified name identifies an individual property = of a particular JavaBean. The name of the actual getter or setter method = to be used is determined using standard JavaBeans instrospection, so = that (unless overridden by a BeanInfo class, a property named "xyz" will = have a getter method named getXyz() or (for boolean properties only) = isXyz(), and a setter method named setXyz().=20 * Nested (name1.name2.name3) The first name element is used to select a = property getter, as for simple references above. The object returned for = this property is then consulted, using the same approach, for a property = getter for a property named name2, and so on. The property value that is = ultimately retrieved or modified is the one identified by the last name = element.=20 * Indexed (name[index]) - The underlying property value is assumed to be = an array, or this JavaBean is assumed to have indexed property getter = and setter methods. The appropriate (zero-relative) entry in the array = is selected. List objects are now also supported for read/write. You = simply need to define a getter that returns the List=20 * Mapped (name(key)) - The JavaBean is assumed to have an property = getter and setter methods with an additional attribute of type = java.lang.String.=20 * Combined (name1.name2[index].name3(key)) - Combining mapped, nested, = and indexed references is also supported </quote> The question is: When and how to we add support for indexed and mapped = properties? I guess that if we do, we should adopt the Commons BeanUtils = style of specifying property paths for index and map access. This means = that we wouldn't need additional methods in the BeanWrapper interface = but rather just support for respective property paths in the = BeanWrapperImpl implementation. Any thoughts on this? I've completely forgotten about these things in = face of all the enterprise stuff we've been addressing lately ;-) Juergen -----Original Message----- From: SourceForge.net [mailto:no...@so...] Sent: Thursday, October 23, 2003 3:54 PM To: no...@so... Subject: [[W3-SPAM]] - [springframework - Help] Index properties in forms - Found word(s) receiving this email email in the Text body. Read and respond to this message at:=20 https://sourceforge.net/forum/message.php?msg_id=3D2251775 By: breidenr I am using a SimpleFormController to help create an object using an HTTP = form. Obviously, if my form object is a Vendor, that object has a = setName(String) method, and my HTTP form has a field named "name", the Controller will = try call Vendor.setName(String) and pass in the value from the form. This also = goes for nested properties: address.setCity -> = vendor.getAddress().setCity(String). My question is, is there any support for *indexed* properties? By that, = I mean purchaseOrder[0].number -> ( (PurchaseOrder) vendor.getPurchaseOrders().get(0)).setNumber(). I know that some = expression languages support something like this. IIRC, Struts has something like = this, but it has a little kludgy. From what I can tell, nested porperies are supported by the Spring = BeanWrapperImpl, but that is it. If this is correct and I want to implement nested = properties, any suggestion as to the best route. Thanks. Ryan Read and respond to this message at:=20 https://sourceforge.net/forum/message.php?msg_id=3D2193984 By: hogie Hi, If I have a command object that stores a collection and I want the data = binder to populate that collection from the servlet request, how should I name = the parameters in my servlet request? In Struts I can do field[index], but I can't see if the same is possible = in Spring. I see BeanWrapper.getIndexedPropertyValue() , but no set() = equivalent. Many thanks, Mike. |