2 GWT Bibliotheken für REST- und MVP-Anwendungen

1. http://code.google.com/p/restful-gwt/

Die History korrekt zu Implementieren ist das O und A einer GWT-Anwendung. Hier greift http://code.google.com/p/restful-gwt/ unter die Arme, in dem es wie bei REST Pfade einzelne GWT-Seiten mappt. Das Projekt steht am Anfang, die Idee ist aber nett für kleinere GWT-Anwendungen.

Simple Example
@GET@Produces("text/html")public String textHtmlDemo() {        return "welcome <b>home<b> !";}

A new gwt Label with : „welcome home !“ will be appended to the RootPanel.

Example 2
@GET@Path("hello/{name}")public void helloWithIntegerParam(@PathParam("name") Integer myName) {   Window.alert("Hello "+(myName+1));}

If you try to access http://…/MyPage.html#hello/1 the helloWithIntegerParam will be invoked on client side with the parameter „1“. Since the return type is void, nothing will be added automatically to the Rootpanel. You will just see a popup displaying „Hello 2“.

Example 3
@GETpublic Widget demo3() {        return new Button("Click me");}

Yes, returning widgets works too !

Example 4
@Path("search/{name}")public class Test {

@PathParam("name")String name;

@GETpublic void search() {   myTextBox.setValue(name);}}

Field initialisation is working the same way.

Example 5
@Path("search/{name}")public class Test {

@UiField@PathParam("name")TextBox tbName;

@GETpublic void search() {   // nothing here}}

In this special case, when a field extends „HasValue“ class, the field have to be initialized by yourself, the framework will call „setValue“ with the

2. http://code.google.com/p/mvp4g/

Noch eine Nummer größer als der bescheidene erste REST-Ansatz ist http://code.google.com/p/mvp4g/ aufgestellt. Es implementiert in komplettes MVP-Framework mit Event-Bus, DI, Modulen, Code-Spitting und allen Schnick und Schnack. Die Dokumentation ist mit UML-Diagrammen schon fast unwirklich. Die Einarbeitung dauert, zahlt sich jedoch aus. Eine Umstellung existierender GWT-Anwendungen ist jedoch aufwändig, da mvp4g größere Änderungen nach sich zieht.

Ähnliche Beiträge

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert