javaNoober
javaNoober

Reputation: 1338

SmartGWT: apply style dynamically

I would like to obtain a CSS-like string from code and add it to the current widget style.

SmartGWT have a setStyleName attribute, which work with CSS present on the stylesheet only, but no set Style or anything similar I can think of. How can I achieve this?

Upvotes: 2

Views: 1814

Answers (1)

bogdanb
bogdanb

Reputation: 458

If I understand your question correctly, you should be able to use {widget}.getElement().getStyle() to obtain a com.google.gwt.dom.client.Style object that you can manipulate. But you need to give it individual “parsed” CSS properties.

If you just have a chunk of CSS as a string you can add it to your document with com.google.gwt.dom.user.StyleInjector, then add the needed classes to the widgets that need them.

Upvotes: 1

Related Questions