Hi,

This is probably a very noob question but I have updated my project to
GWT 2.0 and I am trying to rewrite some of my Widgets to use
Declarative UI because it looks very promising and cool!

However, I am a little stumped on how to apply CssResource styles
dynamically in my code.  I found the trailing info on the site (http://
code.google.com/webtoolkit/doc/latest/DevGuideUiBinder.html) and
copied it here for convenience.  The part that stumps is me is the
following lines:

void setEnabled(boolean enabled) {
    getElement().addStyle(enabled ? : style.enabled() : style.disabled
());
    getElement().removeStyle(enabled ? : style.disabled() :
style.enabled());
  }

There do not appear to be addStyle(String) and removeStyle(String)
methods in the Element class??  Am I missing something obvious?  I
hope so!

thanks!



--------------------------
Programmatic access to inline Styles
Your code will need access to at least some of the styles your
template uses. For example, suppose your widget needs to change color
when it's enabled or disabled:
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'>

  <ui:style type='com.my.app.MyFoo.MyStyle'>
    .redBox { background-color:pink; border: 1px solid red; }
    .enabled { color:black; }
    .disabled { color:gray; }
  </ui:style>

  <div class='{style.redBox} {style.enabled}'>I'm a red box widget.</
div>

</ui:UiBinder>
public class MyFoo extends Widget {
  interface MyStyle extends CssResource {
    String enabled();
    String disabled();
  }

  @UiField MyStyle style;

  /* ... */

  void setEnabled(boolean enabled) {
    getElement().addStyle(enabled ? : style.enabled() : style.disabled
());
    getElement().removeStyle(enabled ? : style.disabled() :
style.enabled());
  }
}

-- 
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/google-web-toolkit?hl=en.

Reply via email to