开发者

gwt uiBinder ui:field access problem

开发者 https://www.devze.com 2023-03-15 14:45 出处:网络
I have this in my ui.xml file: <g:Button ui:field="saveButton"/> This is in my view class:

I have this in my ui.xml file:

<g:Button ui:field="saveButton"/>

This is in my view class:

@UiField
Button saveButton;

@Inject
public MyView() {

    saveButton.setText("Save");

    initWidget(binder.createAndBindUi(this));
}

If I run it as is, I get blank screen. But if I remove the saveButton.setText("Save"); the button will come up but without any text in it. BTW I'm using mvp4g

开发者_高级运维Any idea why this is happening?


@UiField without provided have to go under the initWidget call and @UiField(provided = true) has to go above the initWidget call.

@Inject
public MyView() {    
    // here go all UiFields with provided=true 
    initWidget(binder.createAndBindUi(this));
    // here go all UiFields without provided
    saveButton.setText("Save");
}
0

精彩评论

暂无评论...
验证码 换一张
取 消