How disable widget?

2.1k views Asked by At

I use GWT Editors framework for data binding. I have next code:

AAAView.java

public interface AAAView extends Editor<AAA> {

public interface Presenter {
}

public interface Driver extends SimpleBeanEditorDriver<AAA, AAAViewImpl> {
}

void setPresenter(Presenter presenter);

Driver initializeDriver();

Widget asWidget();

}

AAAViewImpl.java

public class AAAViewImpl extends Composite implements AAAView {
interface AAAViewImplUiBinder extends UiBinder<Widget, AAAViewImpl> {
}

private static AAAViewImplUiBinder ourUiBinder = GWT.create(AAAViewImplUiBinder.class);

private Presenter presenter;

@UiField
ValueBoxEditorDecorator<String> firstName;
public AAAViewImpl() {
    Widget rootElement = ourUiBinder.createAndBindUi(this);
    initWidget(rootElement);
}

@Override
public void setPresenter(Presenter presenter) {
    this.presenter = presenter;
}


@Override
public Driver initializeDriver() {
    Driver driver = GWT.create(Driver.class);
    driver.initialize(this);
    return driver;
}

AAAViewImpl.ui.xml

<e:ValueBoxEditorDecorator ui:field="firstName">
<e:valuebox>
  <g:TextBox maxLength="16" width="100%"/>

  </e:valuebox>
</e:ValueBoxEditorDecorator>

How can I disable/enable firstName textbox in runtime? Or how get access to the inner textbox of ValueBoxEditorDecorator object? Anyone knows how to solve this problem? Thanks in advance.

1

There are 1 answers

0
Jon Newmuis On

Instead of setting the ui:field attribute on the ValueBoxEditorDecorator, set it on the inner TextBox. Then you can disable the TextBox by using:

firstName.setEnabled(false);