framework icon indicating copy to clipboard operation
framework copied to clipboard

Cannot update the Current Caption of ComboBox

Open pinonpierre opened this issue 9 years ago • 8 comments

There is no way to provoke the change of the caption of the Current ComboBox value

ListDataProvider<String> dataProvider = new ListDataProvider<>(Arrays.asList("one", "two", "three"));

ComboBox<String> comboBox = new ComboBox<>();
comboBox.setWidth(250, Unit.PIXELS);
comboBox.setDataProvider(dataProvider);
comboBox.setItemCaptionGenerator(item -> item + " - " + String.valueOf(System.currentTimeMillis()));

layout.addComponent(comboBox);
Button button = new Button("Refresh");
button.addClickListener(event -> dataProvider.refreshItem(comboBox.getValue()));
layout.addComponent(button);

The workaround is: comboBox.setItemCaptionGenerator(comboBox.getItemCaptionGenerator()); because that's call the private ComboBox.updateSelectedItemCaption() method

pinonpierre avatar Dec 01 '17 15:12 pinonpierre

I have the same problem, but the workaround doesn't work for me....the only difference is that I binded the combobox. The only way for refresh the caption of selected item is set value to null and then to the real value, with the conseguence to fire a change state event of the binder.

Cristian

cristian-aimi avatar Dec 06 '17 11:12 cristian-aimi

Up

pinonpierre avatar Mar 08 '18 14:03 pinonpierre

I can not reproduce the issue with latest master. Probably fixed together with something else. I am closing the ticket, let me us know if you have any other broken code example.

elmot avatar May 29 '18 14:05 elmot

I can not reproduce the issue with latest master. Probably fixed together with something else. I am closing the ticket, let me us know if you have any other broken code example.

Very strange because the bug is still present. When you select a ComboBox item and click on "Refresh button", the text shown in the combobox (the current value) is automatically updated?

@anasmi @elmot I think it's necessary to re-open this bug

pinonpierre avatar Nov 07 '18 13:11 pinonpierre

Hi Pierre,

I have checked the behaviour and it seems working to me:

  1. Select the value in CB
  2. Click Refresh
  3. Value is updated

I have used the code from your original message. What version are you using? This is master branch of the framework(8.7-SNAPHOT), but I recall testing at the same time as @elmot did and it worked back then also, so should be fixed at 8.6.0 as well.

combobox_video

anasmi avatar Nov 08 '18 05:11 anasmi

Hi,

I had to test that on the wrong version. Sorry for the inconvenience

Thanks,

pinonpierre avatar Nov 08 '18 09:11 pinonpierre

No problem! : )

It's always better to double check

anasmi avatar Nov 08 '18 09:11 anasmi

I have just found this issue because I had the same problem. It seems like the issue is fixed for refreshItem(T) but not for refreshAll().

Is it intendet that refreshItem(T) refreshes some more that refreshAll()?

For me it was not intuitive.

cornzy avatar May 20 '19 11:05 cornzy