|
From: <jue...@we...> - 2003-11-12 19:14:46
|
I've just introduced preliminary support for indexed and mapped = properties to BeanWrapperImpl, including test cases on the bean wrapper = and form controller level. The current implementation is XP-style, i.e. = "the simplest thing that might possibly work": It does not aim to offer = a generic object graph navigation language like OGNL bur rather just the = ability to traverse arrays, lists, and maps. Consider a bean with the following properties, each containing 2 = NestedBean instances: - NestedBean[] myArray (of size 2) - List myList (containing 2 NestedBean instances) - Map myMap (containing 2 NestedBean values with String keys "key" and = "key2) NestedBean has a "name" property of type String that can then be set in = the various instances as follows, for example as HTTP request = parameters: - myArray[0].name - myArray[1].name - myList[0].name - myList[1].name - myMap[key1].name - myMap[key2].name The map handling also supports the following alternative notations, so = that JSP EL and OGNL syntax can be applied too: - myMap['key1'].name - myMap["key2"].name Altogether, this should allow for populating a wide range of nested bean = instances: simple nestings, arrays, lists, String-keyed maps. Note that = it is *not* supported to *set* array/list/map elements yet: In a typical = web app, new elements are created via special commands, not directly = from a request parameter - but the bean properties of indexed elements = need to populated directly from request parameters. The beauty of it is that there are just a few lines of code in = BeanWrapperImpl involved now, and that custom editors are nicely = inherited. Of course we can try to add full-blown languages like OGNL = later: I just don't see an easy way to combine this with our = BeanWrapper's own capabilities. Finally, a special feature for custom editor registration: You can not = only register an editor for a property of a specific bean with an = expression like "myArray[0].name" but also for a property of all beans = in an array/list/map with "myArray.name". This is particularly = convenient as it is the normal case: If a custom editor for an array = element has to be registered, it should typically apply to all elements. Juergen DI J=FCrgen H=F6ller Senior System Architect ______________________________________ werk3ATS - division systementwicklung werk3AT informations- und mediensysteme europaplatz 4 A - 4020 linz t. +43 (0) 732 71 65 29 502 f. +43 (0) 732 71 65 29 3 mailto:jue...@we... http://www.werk3at.com ______________________________________ werk3ATS - WIR ENTWICKELN ERFOLG |