setStyleName not working multiple times

I have a HorizontalLayout containing two Buttons I styled succesfully.
The layout is being used as a component itself, I used setStyleName(“searchBubble-active”) on it.
now, inside the class handling the component I have the method

public void setActiveStatus(boolean status) {
		if (status == isActive) {
			return;
		}
		if (status) {
			bubbleRappresentation.removeStyleName("searchBubble-inactive");
			bubbleRappresentation.setStyleName("searchBubble-active");
			System.out.println("Bubble activated! "
					+ bubbleRappresentation.getStyleName());
		} else {
			bubbleRappresentation.removeStyleName("searchBubble-active");
			bubbleRappresentation.setStyleName("searchBubble-inactive");
			System.out.println("Bubble deactivated "
					+ bubbleRappresentation.getStyleName());
		}
		bubbleRappresentation.requestRepaint();
		isActive = status;
	}

The method is called in the ClickListener of one of the buttons inside, switching the status.
Inside my css, “searchBubble-active” paints the layout background yellow, while “searchBubble-inactive” paints it blue.
When running, the first click succesfully changes the appearance of the layout (from active to inactive) but any other click doesn’t change nothing, while the setActiveStatus prints the expected output.
Using FireBug, I found that the

remains set to “searchBubble-inactive” even if I know it is changed by setActiveStatus!

Any suggestion or something I’m missing?

Setting component style back and forth works ok, as shown in
this example
.

I don’t see any particular problem with your code. The set-only-if-changed mechanism looks like a potential problem cause if the problem is that the style is changed just once - I hope you don’t reset the isActive variable somewhere else or give a wrong parameter value for the method.

Notice that you don’t need to use removeStyleName() if you use setStyleName(), as the set-method sets the style, not adds, as addStyleName() does. You also don’t need the requestRepaint().

Thank you, I found the problem in another class.The switching method was just being called two times, resulting in no changes.Now it works as a charm.
It’s so hard to work with others’ code!