This forum is now a read-only archive. All commenting, posting, registration services have been turned off. Those needing community support and/or wanting to ask questions should refer to the Tag/Forum map, and to http://spring.io/questions for a curated list of stackoverflow tags that Pivotal engineers, and the community, monitor.

AnnouncementAnnouncement Module

Collapse

No announcement yet.

ComboBoxBinder: changes in one combobox changes anotherPage Title Module

If I remember correctly, changing the list behind a combobox will indeed not show the changes. You need to change the internal model instead of the backing list. Also, you need to make sure you make those changes on the EDT.

Comment

If I remember correctly, changing the list behind a combobox will indeed not show the changes. You need to change the internal model instead of the backing list. Also, you need to make sure you make those changes on the EDT.

Thanks for the fast response. :-)

What do you mean by internal model? The Valuemodel? (I'm sorry if I ask stupid questions, but I'm new to Spring RCP).

It seems the valuemodel is changed when I change the backing bean. The listener set up in forms constructor:

Comment

No, the internal model of the combobox, the combobox model. In your backing bean, you're changing the backing list of the combobox. But Swing doesn't show changes in a backing list, only changes to the comboboxmodel are propagated iirc. I'll see if I can create a test case to mimic your case.
What you could do is add a changelistener to the valuemodel of one of the comboboxes and change the selectable items list in there (I'm freewheeling here), perhaps that'll work, but I can't say for sure.

Comment

No, the internal model of the combobox, the combobox model. In your backing bean, you're changing the backing list of the combobox. But Swing doesn't show changes in a backing list, only changes to the comboboxmodel are propagated iirc. I'll see if I can create a test case to mimic your case.
What you could do is add a changelistener to the valuemodel of one of the comboboxes and change the selectable items list in there (I'm freewheeling here), perhaps that'll work, but I can't say for sure.

Oki. I thought the point of using the form was that the backing bean was bound to the gui components so that changes to the gui are propagated to the backing bean and vice versa.

I have figured out one way of doing it that actually works, but I find it's a lot of code for something that should be really easy. I replace the combobox model, listen to changes in the backing bean's property and update the combobox model accordingly.

The changes to the selected value seems to work as I would expect - changes to the backing bean are propagated to the gui, without the need to explicitly change them. It is only the list of selectable items that are not propagated back to the gui. Seems a bit strange to me.