I am creating a custom widget to implement visual controls, AControlWidget by extending CustomComponent similar to section 5.20 in the Vaadin book and I can render my layout OK.
My widget will have icons, images, textFields, Buttons. Some will be editable or have button actions requiring server actions.
For data/interaction, my Vaadin Application will access a separate REST server to get/set physical controls each of which has a set of properties according to control type.
I have a populateControlsContainer() method which pulls in data from the RESTserver and local classes I have made such as FooControl and BarControl each of which has its properties.
At the moment I create instances of FooControl & BarControl, initialise them and use addBean(.) to put them in a sub-class of BeanItemContainer.
Now I am struggling to see how to bind the Buttons (say) in my CustomComponent (AControlWidget) to a specific property of a particular control instance in the data container. Normally, I would have made a key out of Control “name” and Control “type” which I know is unique and put them in a map. I could then access a particular property.
Since the BeanItemContainer behaves more as a set or an array, I can not do that. Doing a search for each use seems inefficient.
I wondering which classes I should be using to do this so as not to duplicate functionality which is already there in Vaadin classes. I suppose I was looking for a method
addBean( item, (String id) )
, but there is not one.
Section 5.20 stops short of discussing binding (because that is dealt with later in chapter 9, which I read, but I didn’t quite see how to finish off 5.20.
Finally, my REST server data changes autonomously with time, so periodically I need to refresh my display. When binding is in place, can I just refresh the data model which in turn would refresh the display? Who has to initiate refresh?
Can anyone suggest directly, or give pointers to how to deal with this kind of thing?