tags:

views:

170

answers:

1

i have a panel (A), which contains 3 other panels (AA, AB, AC). Each of the subpanels contains Label and Button. The label has a style. How can i remove all styles from all labels over A. My idea was to make something like A.getChilds().removeStyleName();...

edit: the number of the subpanels is variable...from 2 to 1000. Each subpanel has the same css-class.

+2  A: 

You should only need to add the style to A.

.someStyle { background-color: blue; }
.someStyle .gwt-Label { font-weight: bold; }

(Note that GWT Labels automatically have the styleName "gwt-Label" specified)

Then when you want to remove this style from everything beneath panel A, it's as easy as panelA.removeStyleName("someStyle"); which will make the above rules no longer apply.

Removing someStyle from panel A will remove it from all nodes beneath it. This is why they're called Cascading Style Sheets.

Jason Hall
this solution will work, if the number of the subpanels is constant (see my edited post, I've tried to explain it better now).
cupakob
Updated my answer. It doesn't matter how many subpanels/labels you have beneath panel A, and you don't really have to enumerate them all in the CSS.
Jason Hall
I've combined you idea with an array list and it works :) thanks a lot...
cupakob
Could you edit your question to include the solution you went with? It might be helpful to others with similar questions, and there might still be ways to make it better.
Jason Hall