我在幾個月前潛入gwt世界,現在正在嘗試使用gwt-query庫。 我跟着本教程:http://code.google.com/p/gwtquery/wiki/GettingStarted 因爲我在Modle-View-Presenter中工作,我嘗試在View中實現上面的教程(綁定到..View.ui.xml),但它似乎工作。Gwt-query對我的MVP不起作用。
我試圖創建一個拉布勒,然後運行該代碼:
列表allGwtLabels = $( 「GWT-標籤」。)窗口小部件();
但它沒有選擇任何東西!
我想我有我想要的qwtQuery搜索小部件(點我具體ui.xml文件)
什麼我做錯了以某種方式點?
在此先感謝。下面是我的我的演示+查看+ XML即dosent工作的代碼:
//================================Presenter=================================:
public class QueryPresenter extends
Presenter<QueryPresenter.MyView, QueryPresenter.MyProxy> {
public interface MyView extends View {
}
@ProxyCodeSplit
@NameToken(NameTokens.query)
public interface MyProxy extends ProxyPlace<QueryPresenter> {
}
@Inject
public QueryPresenter(final EventBus eventBus, final MyView view,
final MyProxy proxy) {
super(eventBus, view, proxy);
}
@Override
protected void revealInParent() {
RevealRootContentEvent.fire(this, this);
}
@Override
protected void onBind() {
super.onBind();
}
}
//====================================View============================================:
public class QueryView extends ViewImpl implements QueryPresenter.MyView {
private final Widget widget;
public interface Binder extends UiBinder<Widget, QueryView> {
}
@Inject
public QueryView(final Binder binder) {
widget = binder.createAndBindUi(this);
List<Widget> allGwtLabels = $(".gwt-Label").widgets(); //Doesn't Work!!
//Also doesn't work!!
Label label = new Label("Click on me and I will disappear");
$(label).click(new Function() {
@Override
public void f(Widget w) {
//fade out the label
$(w).fadeOut(1000);
}
});
_html.add(label);
//retrieve all attached gwt labels
}
@Override
public Widget asWidget() {
return widget;
}
@UiField Label _label;
@UiField HTMLPanel _html;
}
//==================xml file===============================
<!DOCTYPE ui:UiBinder SYSTEM "http://dl.google.com/gwt/DTD/xhtml.ent">
<ui:UiBinder xmlns:ui='urn:ui:com.google.gwt.uibinder'
xmlns:g='urn:import:com.google.gwt.user.client.ui'
ui:generateFormat='com.google.gwt.i18n.rebind.format.PropertiesFormat'
ui:generateKeys='com.google.gwt.i18n.rebind.keygen.MD5KeyGenerator'
ui:generateLocales='default'>
<g:HTMLPanel ui:field="_html">
<script type="text/javascript" language="javascript" src="gquerytest/gquerytest.nocache.js"></script>
<g:Label text="hey" ui:field="_label"/>
</g:HTMLPanel>
</ui:UiBinder>
謝謝。它適用於List allGwtLabels = $(「。gwt-Label」,widget).widgets();但我仍然無法使這項工作:$(標籤,_html)。單擊(新功能(){ \t \t \t @覆蓋 \t \t \t公共無效F(部件w){ \t \t \t \t //褪色out of the label $(w,_html).fadeOut(1000); \t \t \t} \t \t}); – Michael 2012-04-14 16:21:23