Information Technology Reference
In-Depth Information
The code in the view implementation is then only an initialization and exposure of GWT
components (in our case, those components are just a table with strings in it).
The other component, the pop up, has a very similar structure. Let's analyze this code
fragment of the NewMessagePresenter class:
@Dependent
@WorkbenchPopup(identifier = "uberFireDemo.NewMessagePopup")
public class NewMessagePresenter {
...
@Inject
private Caller<DemoServiceEntryPoint> demoService;
@Inject
private Event<NewMessageEvent> newMsgEvent;
public void sendMessage(String message) {
this.demoService.call( new RemoteCallback<Void>() {
@Override
public void callback( Void response ) {
//send event
newMsgEvent.fire(
new NewMessageEvent( view.getMessage()
) );
}
} ).sendMessage( message );
}
}
For brevity's sake, we removed the most similar parts to the previous component. Let's
discuss what's new in this class:
Caller : This interface is a wrapper from Errai to handle server-side service in-
vocations as an asynchronous communication. As we have mentioned, GWT code
will be translated by a compiler into JavaScript code. This means that service
calls will eventually be made through JavaScript using Ajax, and their behavior
should be asynchronous. Later on, in the sendMessage method, we will learn
how we use that wrapper with a RemoteCallback parameter to handle the re-
sponse.
Search WWH ::




Custom Search