What I have:
OptionGroup (radios) component on a page in which I can add elements though form.
What I want:
Make item caption contain remove link to have an ability to remove items.
As I understand I can’t simply override some AbstractField method to make all of this work.
I need to provide some changes in whole widget I suppose.
May be someone has an idea how to make this right?
That is really not a easy task to do. You would have to copy paste a lot of classes to just push the extra button into the caption.
Is it possible to fix the problem in some other way than modifying OptionGroup? Maybe fake it by having a VerticalLayout with a set of HorizontalLayouts in it. Every HorizontalLayout would represent a row in the OptionGroup and would contain a button for selecting, a caption label and a delete button. With a little theming it could look like an OptionGroup. A different workflow could also fix the issue, for example just a list of all options and a separate ComboBox where you choose one.
Those buttons could also be plain OptionGroups in immediate mode, each row containing only one item in its OptionGroup. That way you don’t really need to theme anything, you just add the delete button after the OptionGroup in each row (and you don’t need the additional Label, and you maintain good usability by having the item caption trigger the radio button as well, which you lose if you use a label).