Accordion tab caption is not refreshing on ValueChangeEvent


I have an accordion with some tabs, and I want to change the caption of the open tab on selecting an option from the optiongroup inside the tab.

Here some code ilustrate that:

public class MyApplication extends Application {
	public void init() {
		setMainWindow(new Window("Acc-Test"));
		getMainWindow().setContent(new VerticalLayout() {

			public void attach() {

				List<String> cities = Arrays.asList(new String[] {"Berlin", "Brussels"});
				OptionGroup optionGroup = new OptionGroup("Select", cities);
				Button changeCaptionButton = new Button("changeCaption2");

				Accordion acc = new Accordion();
				final Tab tab1 = acc.addTab(optionGroup, "OptionGroup Tab - 1");
				final Tab tab2 = acc.addTab(changeCaptionButton, "Button Tab - 2");

				optionGroup.addListener(new ValueChangeListener() {
					public void valueChange(ValueChangeEvent event) {
						tab1.setCaption("new Caption Tab1");			
				changeCaptionButton.addListener(new ClickListener() {
					public void buttonClick(ClickEvent event) {
						tab2.setCaption("new Caption Tab2");



When I click on an option the ValueChangeListener-Code is executed, but the caption of the tab is not refreshed. But on changing the tab, the new caption is shown.
BTW: Then same code in the Button.ClickListener works as expacted!

Is there anything wrong in my code, or may there be better ways to do things like this?

Thanks for Help! :slight_smile:


the OptionGroup does not send the changes to the server immediately (like the Button does). Try adding the following to your code, after you create the optionGroup:



Hi Tepi,

yes, that’s it!!!
Thanks a lot for your verry fast replay!