Hi Sebastien,

Thats great news, I prefer to use library version as it has a lot of
advantages over rolling my own solution. I tried yours and it works fine for
me. I think example of how to recognize which link was clicked in demo would
be helpful for others, as context menu will certainly need this for real
world scenario. Here how I did it (let me know if thats how its intended to
use):
final ContextMenu menu = new ContextMenu("menu", Arrays.asList(menuItem1,
menuItem2, menuItem3, menuItem4)) {

            private static final long serialVersionUID = 1L;
            
            private AjaxFallbackLink<User> selectedLink = null;

            @SuppressWarnings("unchecked")
            @Override
            protected void onContextMenu(AjaxRequestTarget target, Component
component)
            {
                selectedLink = ((AjaxFallbackLink<User>)component);
            }

            @Override
            public void onClick(AjaxRequestTarget target, IMenuItem item)
            {
                switch (item.getTitle().getObject()) {
                case "Context menu 1":
                    if (selectedLink != null) {
                        selectedLink.onClick(target);
                    }
                    break;
                case "Context menu 2":
                    System.out.println("Clicked " +
item.getTitle().getObject() + " on " +
selectedLink.getModelObject().getNickname());
                    break;
                case "Context menu 3":
                    System.out.println("Clicked " +
item.getTitle().getObject() + " on " +
selectedLink.getModelObject().getNickname());
                    break;
                case "Context menu 4":
                    System.out.println("Clicked " +
item.getTitle().getObject() + " on " +
selectedLink.getModelObject().getNickname());
                    break;
                }
            }
        };

Big thanks and best regards! :)

bronius



--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/Wicket-context-menu-component-tp4659306p4659541.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org

Reply via email to