Dynamically generating menus [message #1128050] |
Mon, 07 October 2013 09:27 |
|
I would like to create a dynamic number of menus based on the result of a lookup call.
In the example below, getTable().setMenus doesn't exist.
The alternative which I had thought possible was to use getMenus and and setMenus on the page instead of its table (and there, setMenus does exist) but it doesn't seem to have an effect. Any idea why this is not straight forward?
@Override
protected void execInitPage() throws ProcessingException {
ArrayList<IMenu> menus = new ArrayList<>();
menus.addAll(Arrays.asList(getTable().getMenus()));
SomeLookupCall call = new SomeLookupCall();
call.setText("A7* - ");
LookupRow[] rows = null;
try {
rows = call.getDataByText();
}
catch (ProcessingException e) {
// do nothing
}
if (rows != null) {
for (LookupRow row : rows) {
final String s = row.getText();
IMenu menu = new AbstractMenu() {
@Override
public String getText() {
return s;
}
@Override
protected void execAction() throws ProcessingException {
doSomethingAwesomeWith(s);
}
};
menus.add(menu);
}
getTable().setMenus(menus.toArray(new IMenu[0]));
}
}
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.03063 seconds