Wicket - Top level menu freezes on click of Context Menu

135 views Asked by At

My application has top-level menu and context menu for a page which displays certain report details. On clicking this context menu icon, i will get a context menu with certain actions as shown below enter image description here

Now, the problem is whenever i click this context menu and do nothing (not chosen any actions of from that context menu), the top level menu is frozen. I need to refresh the page to get it working. I am using below wicket code to deal with actions on context menu -

on click of context menu, action will be null and on click of Delete, Edit or Copy, action will go to else loop. If it goes in else loop, I am good as page will be navigated to another and top level menu works. In case of action null, where scheduleRequestHandlerAfterCurrent is being called, I am facing issue with frozen top-level menu.

@Override
    public void onRequest()
    {
        final Component component = getComponent();
        final IRequestCycle cycle = component.getRequestCycle();
        final IRequestParameters parameters = cycle.getRequest().getRequestParameters();
        final String action = parameters.getParameterValue("action").toString(null);
        if (null == action)
        {
            cycle.scheduleRequestHandlerAfterCurrent(new TextRequestHandler("application/json", "UTF-8",
                    buildResponse()));
        } else
        {
            final String target = parameters.getParameterValue("targetId").toString(null);
            if (null == target)
            {
                throw new RuntimeException(
                        String.format("Did not receive a target object identifier for action [%s].", action));
            }
            menu.getAdapter().performActionOnTarget(component, action, target);
        }
    }
2

There are 2 answers

0
ChilBud On BEST ANSWER

There was an $(document).unbind('click'); line in custom JS before showing up the context menu. This context menu was earlier designed to show on mouse right click. IN the new implementation, it was changed to show in the event of mouse click. Removing that unbind statement fixed this issue in my case..

1
martin-g On

Check for JavaScript errors in the DevTools of your browser. In the if clause you return plain JSON to the browser. This JSON is not processed by Wicket but by custom JavaScript. If there is an error then most probably some other JavaScript event is not registered and any clicks do not trigger it.