Back Forum Reply New

Map object FormModel

Hi,I've a dynamic domain object stored in a map, is there any way to use in a FormModel ???Thanks

What you could do is write a binder/binding which creates a panel in which all elements of the map are shown beneath eachother. For the individual element you can rely on the simple binders to create the controls (or provide a resolving system inside your binder which maps property types to binders)
How you'll handle the labels of those components is totally up to you. Since you don't know in advance which elements will be stored in the map, it's not so straightforward to put those labels in the standard i18n system of Spring RCP (unless you know in advance all possible items in the map, in that case you might be able to pull that off).

Just my .02

Greetz,

Lieven

You will have to provide your own PropertyAccessStrategy implementation and construct a FormModel instance using it.

Try lookup up BeanPropertyAccessStrategy code as an example on how to achieve this.

cheers,

Andrius

If you want to show specific items in the map based on the key, you'll need to do that. But then you will also have to handle the situation when that element isn't there at runtime (a map doesn't inforce a contract...).

Say you put the property myMap[someKey] on your form. What do you want to happen when someKey isn't in the map? By default, the behaviour should be the same as a normal property: fail fast. But with a map, you'll probably don't want to see that property. Hence the map binder.
¥
Back Forum Reply New