Hi, I think what is missing you is the AjaxBehavior / Event / jQuery event binding.
Basically, your ContextMenuBehavior (CMB) should embed an ajax behavior (JQueryAjaxBehavior, let's say AB). A common Event object (E) should be shared between CMB & AB. Note that CMB should implement IJQueryAjaxAware the its instance (this) should be passed to AB's contructor. Once bound to the CMB (see #bind() ), you can get the AB#getCallbackFunction() (if using wicket-jquery-ui-6.x) that you will transmit to the jQuery function 'callback' like this: "{ selector: '.the selector', callback: " + ab.getCallbackFunction() + " }". At this stage, AB should be invoked when the jQuery event is fired, and you can do things in CMD#onAjax(AjaxRequestTarget target, JQueryEvent event). (note the JQueryEvent here) The question is now how you transmit an additional information to AB (means wicket side). First, you need to know what parameter context-menu will give you when the callback is triggered. If I see that the callback have 2 parameters (key and options), I will suppose that the key is the menu-id I am interested to get back, so in AB: protected CallbackParameter[] getCallbackParameters() { return new CallbackParameter[] { CallbackParameter.explicit("key") //considering key is the menu-item key, see CallbackParameter javadoc CallbackParameter.context("option"), }; } Once invoked AB will create a new E. What you need is a custom event that have a key property (ie: getKey()) which have the value coming the jquery callback: protected static class MyCallbackEvent extends JQueryEvent { private final String key; public MyCallbackEvent() { this.key = RequestCycleUtils.getQueryParameterValue("key").toString(); //the menu key! } public String getKey() { return this.key; } } Here we are, in the onAjax above, get the key, eventually the menu-item associated to the key, and fire a custom event (for instance onClick, onMenuClicked, onWhatYouWant) if (event instanceof MyCallbackEvent ) { String key = ((MyCallbackEvent)event).getKey(); MenuItem item = null; // FIXME: get the menu item using the key from the List<MenuItem> this.onClick(target, item); //the custom event } If you encounter other problem(s), you can post a quickstart on the wicket-jquery-ui googlegroup. (but my home PC is currently under re-installation so feel free to investigate a little bit on your own before... ;)) Best regards, Sebastien. On Mon, Jun 10, 2013 at 12:14 PM, bronius <keptavi...@gmail.com> wrote: > Hi, > > Yes I checked it. I also was reading this: > http://code.google.com/p/wicket-jquery-ui/wiki/HowToCreatePlugin2. However > context menu plug in was not standard here is jquery example: > $(function(){ > $.contextMenu({ > selector: '.context-menu-one', > callback: function(key, options) { > var m = "clicked: " + key; > window.console && console.log(m) || alert(m); > }, > items: { > "edit": {name: "Edit", icon: "edit"}, > "cut": {name: "Cut", icon: "cut"}, > "copy": {name: "Copy", icon: "copy"}, > "paste": {name: "Paste", icon: "paste"}, > "delete": {name: "Delete", icon: "delete"}, > "sep1": "---------", > "quit": {name: "Quit", icon: "quit"} > } > }); > > $('.context-menu-one').on('click', function(e){ > console.log('clicked', this); > }) > }); > Now the problem is I don't have knowledge about jquery, but from what I > understand it creates context menu instance with parameters: selector, > callback and items. Differently from menu it does not have any markup > (items are passed as parameters and thats it) and also jquery syntax is > different. Menu jquery example is just like this: > $(function() { > $( "#menu" ).menu(); > }); > Thats why I extended JQueryAbstractBehavior, as jquery initialization is > quite different. What I implemented shows context menu, and callback > function is invoked(from jquery parameter), but I lack knowledge on how to > convert that callback function to wicket one. Menu example is ok, but its > different and also it seems I understand what separate methods do, but > because of my inexperience I lack bigger picture understanding how > everything works together. Any help is really appreciated :) > > > > -- > View this message in context: > http://apache-wicket.1842946.n4.nabble.com/Wicket-context-menu-component-tp4659306p4659334.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 > >