Add properties to BeanItem?

Can I add more properties to a BeanItem than are defined in the bean itself?

I’d like to duplicate a “name” property in my bean to be “originalName” so that when I go to edit the bean in my Form with CustomLayout I can put the “originalName” in the Form along with its id while still letting the user modify the name like normal.

Thanks for any tips.

I’ve tried:

in my container that subclasses BeanItemContainer:
super(MyBean.class);
super.addContainerProperty(“originalName”,String.class,null);

Then when I add my MyBean objects I did:
BeanItem item = addItem(mybean);
item.addItemProperty(“originalName”, new ObjectProperty(item.getBean().getName());

But this clearly not right since it blows up.

I also tried something similar in my Form, but adding the property seemed to never trigger a request to call the DefaultFieldFactory.createField with my property name “originalName” despite specifying that when I set the bean with its ordered properties in my Forms.setItemDataSource() method.

Hi David:

Could you finally solve this?

I don’t think I ever resolved it.

In the end, I just made another field in my bean to hold the original name, with a get method so the bean get retrieve the original, but there’s no set method. Then when I instantiate my bean, I copy the original name value into the new field.

ok…thanks for your answer David…

regards,

Hugo