Tuesday, April 29, 2014

Re: menus with UIBinder

Personally I would live with it until GWT understands Java8 lambda's and method references which would eliminate most anonymous classes in GWT sooner or later. To make the init() method look nicer I would think about writing it as:

void init() {

private ScheduledCommand executeLoginCmd() {
  return new ScheduledCommand() {
    public void execute() {
      // code here

This still looks terrible to me! :-)

If there is no better solution, I will consider doing it with constants and switch-statements (back to the 90's):

public enum Command

void init ()
 setCommand (itm_Login,CMD_LOGIN);
 setCommand (itm_Logout,CMD_LOGOUT);
 setCommand (itm_Cheers,CMD_CHEERS);

private void setCommand (MenuItem itm,final Command cmd)
   new ScheduledCommand ()
    public void execute ()
     processCommand (cmd);

private void processCommand (Command cmd)
 // mega switch

Well ok personally I would never use MenuBar + MenuItem because I like to have real hyperlinks so I can open things in tabs. I would have used something like FlowPanel + PopupPanel to build the menu and Hyperlink + GWT Places to build the menu items.

Sounds interesting. Can you give an example? 


You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment