This assuming that the MenuItem item argument in the execute method's signature ought to contain the MenuItem currently being evaluated?
What I see is that item is always null (okay, it's probably more accurate to say that there seems to be a bug in whatever thing issues the callback (the menu?))
SmartGWT eval 2.5-NIGHTLY-2011-03-16
What I see is that item is always null (okay, it's probably more accurate to say that there seems to be a bug in whatever thing issues the callback (the menu?))
Code:
public void onModuleLoad() { Canvas main = new Canvas(); final Menu mCategory = new Menu(); mCategory.setTitle("Do something"); mCategory.setCanSelectParentItems(true); DataSource ds = SupplyCategoryXmlDS.getInstance(); ds.fetchData(new Criteria(), new DSCallback() { public void execute(DSResponse response, Object rawData, DSRequest request) { Record[] records = response.getData(); for (Record r : records ) { MenuItem mi = new MenuItem(r.getJsObj()); mi.setDynamicTitleFunction(new MenuItemStringFunction() { public String execute(Canvas target, Menu menu, MenuItem item) { return item == null ? "null" : "not null"; } }); mCategory.addItem(mi); } } }); mCategory.addItemClickHandler(new ItemClickHandler() { public void onItemClick(ItemClickEvent event) { MenuItem item = event.getItem(); SC.say(item.getAttributeAsString("someOtherColumn")); } }); IMenuButton bCategory = new IMenuButton("Go to category", mCategory); main.addChild(bCategory); main.draw(); }
Comment