| | | | Browse by category |
Question
How to select an activity and display popup menu with right click in thin client?
Answer
In order to generate a dynamic popup menu on right click event, you will need ilog.views.util.servlet.IlvMenuFactory
to create the menu on the server. You can also select the target activity on the server side within the createMenu
method.
public class SimpleMenuFactory implements IlvMenuFactory {
public SimpleMenuFactory() {
}
public IlvMenu createMenu(Object graphicComponent, Object
selectedObject, String menuModelId) {
if((selectedObject !=null) && (selectedObject instanceof
IlvActivity))
{
IlvGanttChart chart = (IlvGanttChart) graphicComponent;
chart.deSelectAllRows();
chart.select( (IlvActivity) selectedObject, true);
IlvMenu menu = new IlvMenu("menu");
String label = ((IlvActivity)selectedObject).getID();
IlvMenuItem item = new IlvMenuItem(label);
menu.addChild(item);
return menu;
}
return null;
}
}
On the client side, there is no update request when popup menu is triggered. Hence the selected activity will not be displayed. You can overcome this by override the IlvGanttComponentView.prototype.mouseUp
to do an updateAll
on the Gantt view after the popup menu is processed.
Something like the following:
IlvGanttComponentView.prototype.mouseUp_base =
IlvGanttComponentView.prototype.mouseUp;
IlvGanttComponentView.prototype.mouseUp = function(e) {
var popupMenu = this.popupMenu;
if (popupMenu!=null && popupMenu.isPopupTrigger(e)) {
this.mouseUp_base(e); // generate and display the popup menu
this.getGanttView().updateAll(); // request an update to see
the selected activity
}
};
Attached is the modified servlet
sample that contains the above suggestion. Changes were made in the webpages/index.html
and src/GanttChartServlet.java
file.