2011-04-08 52 views
0

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

回答

2

而不是在ValueBoxEditorDecorator上设置ui:field属性,而是将其设置在内部TextBox上。然后你可以通过使用禁用TextBox:

firstName.setEnabled(false); 
相关问题