如何禁用小部件?

发布于 2024-10-31 13:19:52 字数 1457 浏览 0 评论 0原文

我使用 GWT 编辑器框架进行数据绑定。 我有下一个代码:

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 对象的内部文本框? 有人知道如何解决这个问题吗?提前致谢。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

萌梦深 2024-11-07 13:19:52

不要在 ValueBoxEditorDecorator 上设置 ui:field 属性,而是在内部 TextBox 上设置它。然后您可以使用以下方法禁用文本框:

firstName.setEnabled(false);

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文