Results 1 to 4 of 4

Thread: Map object FormModel

  1. #1
    Join Date
    Jun 2006
    Posts
    27

    Default Map object FormModel

    Hi,


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


    Thanks

  2. #2
    Join Date
    Mar 2007
    Location
    Oudenaarde
    Posts
    294

    Default

    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

  3. #3
    Join Date
    Jan 2006
    Location
    Vilnius, Lithuania
    Posts
    68

    Default

    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

  4. #4
    Join Date
    Mar 2007
    Location
    Oudenaarde
    Posts
    294

    Default

    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •