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.
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;
+ 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;
+ ap.getFolder()
+ ".htm");
}
}
}
});
menu.addItem(mib);
}
}
}
}
}
RootPanel.get("navmenu").add(menu, 50, 50);