Giter Site home page Giter Site logo

gwt-uibinder's Introduction

GWT UiBinder

This project is the APT conversion of the GWT 2 UiBinder module in preparation of GWT 3 and J2CL.

The goals for this project is to replace/migrate the code generation from the older GWT 2 generator API to Java APT. Future goals will include migration to new widget library, added features/functionality for UiBinder templates, etc.

Getting Started

Building

Currently, none of the GWT UiBinder jars have been uploaded to maven central. For the time being, this repository can be cloned or directly downloaded. Once that is done, perform a manual maven build like the following:

mvn clean install

Then, add the uibinder dependencies to your Maven module:

  <dependency>
    <groupId>org.gwtproject.uibinder</groupId>
    <artifactId>gwt-uibinder-client</artifactId>
    <version>1.0.0-SNAPSHOT</version>  
  </dependency>

  <dependency>
    <groupId>org.gwtproject.uibinder</groupId>
    <artifactId>gwt-uibinder-processor</artifactId>
    <version>1.0.0-SNAPSHOT</version>  
  </dependency>

Note: This is a snapshot version, so use at your own risk.

The new GWT UiBinder has been completely renamespaced to the org.gwtproject.uibinder package.
This means that both the old AND new UiBinder modules can be imported and used without interference between the two. This can be beneficial to slowly migrate your application from the old to the new.

Just import the module in your gwt.xml file and you're set

  <!-- new UiBinder -->
  <inherits name="org.gwtproject.uibinder.UiBinder"/>

See: Example project for further uses.

Changes in the new GWT UiBinder

Most of the functionality from UiBinder still exist, as it is a goal to become somewhat feature parity with the old module, but there are some minor differences.

@UiTemplate is now required.

With the former GWT 2 generators, code generation can be triggered for interface/class subtypes, but with APT, annotations are required. The setup is essentially identical to what is documented on gwtproject.org. Be sure to use classes from the new package!

The value attribute for @UiTemplate is now optional in which the annotation processor will infer the name of the .ui.xml file from the name of the class. This is the same behavior as before, just with the annotation present.

As this module is in transition between legacy GWT widgets and the new gwt-widgets module, the @UiTemplate interface also has a boolean attribute called legacyWidgets. By default, this is set to false; needed to generate classes for the new widgets. However, by setting legacyWidgets = true, the legacy widgets, SafeHtml, etc will be used. Be aware that widgets cannot be mixed.

GWT.create() no longer used

Previously, one would use GWT.create(MyUiBinder.class) to obtain the instance of the generated class, but with the change to using APT, that is no longer the case. The implementation is created at compile time and with the naming convention <owning_class>_<uibinderinterface>Impl. This is subject to change.
See example usage for a real-world example.

##Example Usage

package com.example.myapplication.view;

import org.gwtproject.uibinder.client.UiBinder;
import org.gwtproject.uibinder.client.UiFactory;
import org.gwtproject.uibinder.client.UiHandler;
import org.gwtproject.uibinder.client.UiTemplate;

import com.google.gwt.user.client.ui.IsWidget;

public class MyView implements IsWidget {
  
  @UiTemplate
  interface MyUiBinder extends UiBinder<VerticalPanel, MyView> {}

  private MyUiBinder binder = new MyView_MyUiBinderImpl();

  private Widget widget;

  @Override
  public Widget asWidget() {
    if (widget == null) {
      widget = binder.createAndBindUi(this);
    }
    return widget;
  }
}

gwt-uibinder's People

Contributors

jhickman avatar niloc132 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.