Как отключить виджет?

Я использую фреймворк GWT Editors для привязки данных. У меня есть следующий код:

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>

Как я могу отключить/включить текстовое поле firstName во время выполнения? Или как получить доступ к внутреннему текстовому полю объекта ValueBoxEditorDecorator? Кто-нибудь знает, как решить эту проблему? Заранее спасибо.


person VMN    schedule 08.04.2011    source источник


Ответы (1)


Вместо установки атрибута ui:field в ValueBoxEditorDecorator установите его во внутреннем текстовом поле. Затем вы можете отключить TextBox, используя:

firstName.setEnabled(false);
person Jon Newmuis    schedule 20.09.2011