Information Technology Reference
In-Depth Information
private PlaceManager placeManager;
@Inject
private MessageListView view;
@WorkbenchMenu
public Menus getMenus() {
return MenuFactory
.newTopLevelMenu(constants.NewMessage())
.respondsWith(new Command() {
@Override
public void execute() {
placeManager.goTo(
new DefaultPlaceRequest(
"uberFireDemo.NewMessagePopup" )
);
}
}).endMenu().build();
}
}
}
There are a few components in this code fragment that we still haven't seen and are very
useful when working with UberFire components:
UberView interface : This is an extension of the IsWidget interface, which
adds a method to initialize a view based on a presenter object. You can see that
we extend it to add methods that will be useful for our specific case.
Injection of MessageListView instance : This is because the view object is also
generated and injected through Errai and CDI. As you can see in the code, the
view implementation is template-based and we're working with an HTML file
( MessageListViewImpl.html ). The templating is handled by mappings
between both the files marked by data-field attributes in the HTML file, and
@DataField annotated attributes in the Java class.
WorkbenchMenu generation : This is to show how we can create menus that
have any commands we wish. In the preceding code, we show how to use a very
useful utility called PlaceManager (which is also injected through Errai and
CDI), which is a utility manager to tell the workbench to go to another particular
view or to get parameters from the current URL. In our case, we're using it to go
to the popup for creating a new message.
Search WWH ::




Custom Search