Hi!

Is it possible to use BeanEditForm component for
editing complex beans?

I have the following classes (getters and some
irrelevant things are stripped, which might make
classes slightly odd, but they have to be this way in
my case).

public class Item {
        private String name;
        private Money price;
        private ItemDetails details;
}

public class Money {
        private double amount;
        private Currency currency;
}

public abstract class ItemDetails {
        private int weight;
}

public class SizedItemDetails extends ItemDetails {
        private int size;
}

public class ColoredItemDetails extends ItemDetails {
        private Color color
}

public class Color {
        private int red, green, blue;
}

I would like to use BeanEditForm for editing objects of
type Item.
For some items it should look like this:
Name: _____
Price: ____ ____\/
Weight: ___
Color: ____

And for some like this (depending on runtime type of
details field):
Name: _____
Price: ____ ____\/
Weight: ___
Red: ____
Green: __
Blue: ___


Seems that currently there are 2 limitations:
1) BeanModelSource does not parse details of the
complex types. It works for the name field, I can make
Money field work by contributing PropertyEditBlock for
Money, which displays a TextField and a ComboBox. But
for more complex types it does not work, since I can
not nest one BeanEditForm into another. I believe that
by changing BeanModelSource it would be possible to
make it look deeper in the hierarchy and display flat
list of all basic fields.

2) BeanModelSource creates bean model by parsing static
class hierarchy of object parameter type instead of the
actual runtime classes. This causes problem
with my details field, because BeanModelSource
always treats it as ItemDetails and thus sees only
weight field. And the problem is that it can not be
fixed by overriding BeanModelSource implementation,
because create method in BeanModelSource interface only
takes Class parameter. Since new BeanModel is created
for each request, it should not be a big overhead to
look at runtime class hierarchy.

Any thoughts on how to achieve the functionality I
need? Are there any plans to add something like that to
the existing BeanEditForm component?

Thanks in advance,
Imants

Advertisement:

WWW.GAMES.INBOX.LV – Looti daudz speeeles!!! Vairak par 100000 !!!

Reply via email to