benefits of gwtQuery

后端 未结 2 2065
轮回少年
轮回少年 2021-01-28 08:34

Can somebody tell me what are the benefits of using gwt query .Is it just for css effects. and how we can use it to create ui elemnts like gwt.

What I understand is ju

2条回答
  •  半阙折子戏
    2021-01-28 09:06

    Think in gwtquery like an essential complement to GWT. It does not replace anything but makes your live a bit easier.

    Between others, these are the main features missing in GWT which gquery adds.

    1- CSS selectors and DOM traversal manipulation: allowing you to enhance any GWT widget. For instance, to add an image and a css class to all in a GWT table is as simpler as:

    $(".mygwttable td").append("").addClass("whatever");
    

    2- Get any widget instance present in the DOM as a way to decouple your code.

    TextBox emailBox = $("input[name='email']").widget()
    

    3- Manipulate easily elements: attributes, styling, etc:

    $(".gwt-Label")
      .css($$("background: red, color: white, width: 100%")
      .attr("whatever", true);
    

    4- Intuitive Ajax, much more simpler than RequestBuilder

    $(myLabel).load("file.html");
    

    5- Helpers to read javascript, change javascript objects and execute javascript functions without writing a single line of JSNI

    Properties history = JsUtils.prop(window, "history");
    JsUtils.runJavascriptFunction(history, "pushState", null, null, "whatever.html")
    

    6- Json and XML databinding: much more intuitive and simpler than autobeans.

    7- Promises, Animations, and much more ...

    So, although you could have a gwt project without using any gwt widget using just gwtquery, the normal way of using gquery is complementing GWT, so develop your app using the standard gwt way, and use gquery helpers to write less code.

    In your case use normal gwt widgets, and use gwtquery to enhance them (styling, changes in rendered dom, events, etc) without having to extend them to make changes.

提交回复
热议问题