http://www.java2s.com/Code/Java/GWT/Menuwithstyle.htm
I tried this example and it happens the same =( Is it a bug of gwt or something its missing on my project? the first item of each menu cant be selected :( whyyyyyyyyyy? 2011/8/16 Marko Borges <[email protected]> > what i do is create my menu and in items and menu without items I add > Command to go to a certain page. > > this happens ok with the hosted page. but in another page the first item of > each menu doesnt let execute Command and neither let select that item when > mouse is over. > > Here is the code: > > <code> > for (int i = 0; i < result.size(); i++) { > final PageDTO page = result.get(i); > if (page.getParentid() == 1) { > mb.add(page); > } > } > boolean[] bools = new boolean[mb.size()]; > > MenuBar menu = new MenuBar(); > menu.setAutoOpen(true); > menu.setHeight("25px"); > menu.setAnimationEnabled(true); > > for (int i = 0; i < result.size(); i++) { > final PageDTO page = result.get(i); > if (page.getParentid() != 1) { > for (int j = 0; j < mb.size(); j++) { > PageDTO parent = mb.get(j); > if (page.getParentid() == parent.getPageid()) { > bools[j] = true; > if (last == parent.getPageid()) { > lastName = parent.getPagename(); > items.add(page.getPagename()); > } > if (last == 0) { > items.add(page.getPagename()); > last = parent.getPageid(); > lastName = parent.getPagename(); > } > if (i == result.size() - 1 > || last != parent.getPageid()) { > MenuBar menuButton = new MenuBar(true); > menuButton.addStyleName("demo-MenuItem"); > menu.addSeparator(); > MenuItem mi = new MenuItem(lastName, > menuButton); > mi.setHeight("20px"); > menu.addItem(mi); > for (int x = 0; x < items.size(); x++) { > MenuItem mi2 = new MenuItem(items > .get(x), new Command() { > > @Override > public void execute() { > ActivityDTO act = page > .getActivity(); > boolean found = false; > if (act != null) { > Iterator itr = act > .getActivityPaths() > .iterator(); > while (!found) { > ActivityPathDTO ap = (ActivityPathDTO) itr > .next(); > found = true; > redirect("http://127.0.0.1:8888/" > + ap.getFolder() > + ".htm"); > } > } > } > > }); > menuButton.addItem(mi2); > } > > items = new ArrayList<String>(); > last = parent.getPageid(); > lastName = parent.getPagename(); > items.add(page.getPagename()); > > // break; > } > } else { > if (page.getParentid() > mb.get(j).getPageid() > && !bools[j]) { > final PageDTO actual = mb.get(j); > bools[j] = true; > MenuItem mib = new MenuItem(mb.get(j) > .getPagename(), new Command() { > > @Override > public void execute() { > ActivityDTO act = actual > .getActivity(); > boolean found = false; > if (act != null) { > Iterator itr = act > .getActivityPaths() > .iterator(); > while (!found) { > ActivityPathDTO ap = (ActivityPathDTO) itr > .next(); > found = true; > redirect("http://127.0.0.1:8888/" > + ap.getFolder() > + ".htm"); > } > } > } > > }); > menu.addItem(mib); > } > } > } > } > } > RootPanel.get("navmenu").add(menu, 50, 50); > </code> > > > 2011/8/16 BST <[email protected]> > >> Could you elaborate, maybe provide code snippet ? >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Google Web Toolkit" group. >> To view this discussion on the web visit >> https://groups.google.com/d/msg/google-web-toolkit/-/Y_bxITPaS0cJ. >> >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/google-web-toolkit?hl=en. >> > > -- You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
