I would like to implement menus (MenuBar, MenuItem) using the declarative approach via UiBinder in GWT 2.0.
I have run into two problems:
-
Is there a way to add MenuItemSeparators in the .ui.xml file? So
far, I have only managed to put MenuBar- and MenuItem-tags into the
file. -
Using
@UiHandler, GWT writes the boilerplate code for event
handlers for me. For menus, I need to write commands. How am I
supposed to do this using the UiBinder approach? Is there a command
tag to put in the.ui.xmlfile? Do I have to write the boilerplate
code for the command handlers myself?
Thanks for thinking about these questions!
I agree, if you try to put a
MenuItemSeparatorin, it will complain stating only aMenuItemcan be a child when GWT tries to create the widget . Since this is not currently supported, I suggest that you request this as a future enhancement to the GWT team.In the meantime, you can add a separator programmatically and add a command in the following manner:
The XML file:
The Java file(s):
Elsewhere in my code, I implemented a
HistoryListenerto catch any changes, i.e.