Intro on Errai 4

Arnaud Tournier, le 11-11-2015

Speaker : Max XXX

Why errai ?

GWT is fantastic. But still the more code you have, more painful becomes the maintenance.

GWT projects can get really large and compile time gets too big.

  • Declarative good, boilerplate bad. – Dependency injection (consistent with CDI) – 2 way data binding – Dynamic runtime modules

Dependency injection

@Inject, @Alternative, @Specializes, @Produces, circular dependencies…

Declarative templating

View is a plain HTML file

Templated bean is a normal bean associated with a HTML view.

Can select a fragment from any html file and use it as a template :

@Templated("DesignerTemplateFile.html#contact")
public calss ContactView extends Composite{
	...
}

Data binding

Synchronizes view and beans.

Can be used in @Templated elements

@Bindable
class User {
	private String field;

	// getter and setter
}

@Templated
class MyForm {
	@Inject @AutoBound
	DataBinder<User> binder;

	@Inject
	@Bound
	@DataField
	TextBox userName;

	@Inject
	@Bound(property="dateOfBirth")
	@DataField
	DateBox dob;

	...

	void t(){
		User user = binder.getModel();
	}
}

Binding a list of values

@Inject
ListWidget<User, UserView> userList;

List<User> models = userList.getValue();
models.add(new User());
models.get(0).setUserName("John");
models.remove(0);

Dynamic Runtime modules

Hwo to breakup your big application into several compiled sub-modules and then re-assemble them at runtime

Uses JsInterop as the foundation for that.

Example

2 projects : consumer producer; bother are compiled withthe MySimpleService interface in (which is a JsType)

Summary


Arnaud Tournier, le 11-11-2015