Hi Chris, Yes, generally speaking, you have to cancel bubbling events to parent elements. For a [Ajax]Link (or any event-behavior related) you have to set the preventDefault property to true;
protected void updateAjaxAttributes(AjaxRequestAttributes attributes) { super.updateAjaxAttributes(attributes); attributes.setPreventDefault(true); // cancel bubbling } Hope this helps, Best regards, Sebastien On Fri, Feb 6, 2015 at 6:59 PM, Chris <chris...@gmx.at> wrote: > Hi Sebastian, > > I would have a follow-up question regarding the #Sortable: > > > Is it possible to add an AjaxLink to the item with its own behavior so > that if the user clicks on this link, then its on-click behavior should be > called instead of the #onselect method from the sortable. At the moment, > the #onselect method would be called for this link. > > Thanks a lot, > Chris > > @Override > protected void populateItem(ListItem<String> item) > { > item.add(new EmptyPanel("icon").add(AttributeModifier.append("class", > "ui-icon " + JQueryIcon.ARROW_2_N_S))); > item.add(new Label("item", item.getModelObject())); > item.add(AttributeModifier.append("class", "ui-state-default")); > } > > > > > > Am 05.02.2015 um 14:30 schrieb Sebastien <seb...@gmail.com>: > > > > I've opened the issue: > > https://github.com/sebfz1/wicket-jquery-ui/issues/153 > > > > > > On Thu, Feb 5, 2015 at 10:29 AM, Sebastien <seb...@gmail.com> wrote: > > > >> Hi Chris, > >> > >> Right, Sortable is processing events thought the Event Bus, that's > because > >> 2 sortables can be connected and then, these should be able to > communicate > >> > >> As you are sending the event from the Sortable, you enter the condition: > >> if (event.getSource() instanceof Sortable<?>) > >> > >> I will try to find out how I can add a check, but as Sortable is using a > >> generic model object (typeof T)... > >> I think the correct solution/workaround would be that you change the > >> broadcast type to EXACT, so Sortable#onEvent will not be triggered. > >> > >> Thanks & best regards, > >> Sebastien. > >> > >> > >> > >> On Wed, Feb 4, 2015 at 8:55 PM, Chris <chris...@gmx.at> wrote: > >> > >>> Hi Sven, thanks. > >>> > >>> The onRemove method is from the class > >>> com.googlecode.wicket.jquery.ui.interaction.sortable.Sortable: > >>> > >>> @Override > >>> public void onRemove(AjaxRequestTarget target, String item) { > >>> super.onRemove(target, item); > >>> } > >>> Why is the payload processed in this method, as it takes the target as > >>> parameter? Is there another way to render the other panel or rewrite > the > >>> payload? > >>> > >>> br, Chris > >>> > >>> > >>>> Am 04.02.2015 um 20:41 schrieb Sven Meier <s...@meiers.net>: > >>>> > >>>> Hi, > >>>> > >>>> you're using a DeleteItem as payload of the event: > >>>> > >>>> send(getPage(), Broadcast.BREADTH, new DeleteItem(target)); > >>>> > >>>> Yet in #onRemove() you're casting the payload to a String: > >>>> > >>>> java.lang.ClassCastException: tripplanner.mycompany.DeleteItem > >>> cannot be cast to java.lang.String > >>>> at > >>> mycompany.panels.SuitcasePanel$1.onRemove(SuitcasePanel.java:54) > >>>> > >>>> > >>>> Regards > >>>> Sven > >>>> > >>>> > >>>> On 04.02.2015 20:32, Chris wrote: > >>>>> Hi Tobias - sorry, here it is: > >>>>> > >>>>> Last cause: mycompany.DeleteItem cannot be cast to java.lang.String > >>>>> WicketMessage: Method onRequest of interface > >>> org.apache.wicket.behavior.IBehaviorListener targeted at > >>> > com.googlecode.wicket.jquery.ui.interaction.selectable.SelectableBehavior$1@127d9785 > >>> on component [Sortable [Component id = sortable]] threw an exception > >>>>> > >>>>> Root cause: > >>>>> > >>>>> java.lang.ClassCastException: tripplanner.mycompany.DeleteItem cannot > >>> be cast to java.lang.String > >>>>> at > >>> mycompany.panels.SuitcasePanel$1.onRemove(SuitcasePanel.java:54) > >>>>> at > >>> > com.googlecode.wicket.jquery.ui.interaction.sortable.Sortable.onEvent(Sortable.java:126) > >>>>> at > >>> > org.apache.wicket.settings.def.FrameworkSettings.dispatchEvent(FrameworkSettings.java:132) > >>>>> at > >>> > org.apache.wicket.ComponentEventSender.dispatchToComponent(ComponentEventSender.java:282) > >>>>> at > >>> > org.apache.wicket.ComponentEventSender.access$100(ComponentEventSender.java:36) > >>>>> at > >>> > org.apache.wicket.ComponentEventSender$ComponentEventVisitor.component(ComponentEventSender.java:329) > >>>>> at > >>> > org.apache.wicket.ComponentEventSender$ComponentEventVisitor.component(ComponentEventSender.java:306) > >>>>> at > >>> org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:144) > >>>>> at > >>> org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162) > >>>>> at > >>> org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:162) > >>>>> at > >>> org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:123) > >>>>> at > >>> org.apache.wicket.util.visit.Visits.visitChildren(Visits.java:192) > >>>>> at > >>> > org.apache.wicket.MarkupContainer.visitChildren(MarkupContainer.java:875) > >>>>> at > >>> > org.apache.wicket.ComponentEventSender.breadth(ComponentEventSender.java:160) > >>>>> at > >>> > org.apache.wicket.ComponentEventSender.send(ComponentEventSender.java:68) > >>>>> at org.apache.wicket.Component.send(Component.java:4429) > >>>>> at > >>> mycompany.panels.SuitcasePanel$1$1.onSelect(SuitcasePanel.java:92) > >>>>> at > >>> > com.googlecode.wicket.jquery.ui.interaction.selectable.SelectableBehavior.onAjax(SelectableBehavior.java:122) > >>>>> at > >>> > com.googlecode.wicket.jquery.core.ajax.JQueryAjaxBehavior.respond(JQueryAjaxBehavior.java:171) > >>>>> at > >>> > org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(AbstractDefaultAjaxBehavior.java:633) > >>>>> at java.lang.reflect.Method.invoke(Method.java:483) > >>>>> at > >>> > org.apache.wicket.RequestListenerInterface.internalInvoke(RequestListenerInterface.java:258) > >>>>> at > >>> > org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:241) > >>>>> at > >>> > org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.invokeListener(ListenerInterfaceRequestHandler.java:250) > >>>>> at > >>> > org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:236) > >>>>> at > >>> > org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:862) > >>>>> at > >>> > org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) > >>>>> at > >>> > org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:261) > >>>>> at > >>> > org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:218) > >>>>> at > >>> > org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:289) > >>>>> at > >>> > org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:259) > >>>>> at > >>> > org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:201) > >>>>> at > >>> > org.apache.wicket.protocol.http.WicketServlet.doGet(WicketServlet.java:137) > >>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:618) > >>>>> at javax.servlet.http.HttpServlet.service(HttpServlet.java:725) > >>>>> at > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:291) > >>>>> at > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>>> at > >>> org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52) > >>>>> at > >>> > org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:239) > >>>>> at > >>> > org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206) > >>>>> at > >>> > org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:219) > >>>>> at > >>> > org.apache.catalina.core.StandardContextValve.__invoke(StandardContextValve.java:106) > >>>>> at > >>> > org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java) > >>>>> at > >>> > org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) > >>>>> at > >>> > org.apache.catalina.core.StandardHostValve.__invoke(StandardHostValve.java:142) > >>>>> at > >>> > org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java) > >>>>> at > >>> > org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:79) > >>>>> at > >>> > org.apache.catalina.valves.AbstractAccessLogValve.invoke(AbstractAccessLogValve.java:610) > >>>>> at > >>> > org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:88) > >>>>> at > >>> > org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:537) > >>>>> at > >>> > org.apache.coyote.http11.AbstractHttp11Processor.process(AbstractHttp11Processor.java:1081) > >>>>> at > >>> > org.apache.coyote.AbstractProtocol$AbstractConnectionHandler.process(AbstractProtocol.java:658) > >>>>> at > >>> > org.apache.coyote.http11.Http11NioProtocol$Http11ConnectionHandler.process(Http11NioProtocol.java:222) > >>>>> at > >>> > org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.doRun(NioEndpoint.java:1566) > >>>>> at > >>> > org.apache.tomcat.util.net.NioEndpoint$SocketProcessor.run(NioEndpoint.java:1523) > >>>>> at > >>> > java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) > >>>>> at > >>> > java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) > >>>>> at > >>> > org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) > >>>>> at java.lang.Thread.run(Thread.java:745) > >>>>> > >>>>> > >>>>> br, Chris > >>>>> > >>>>> > >>>>>> Am 04.02.2015 um 20:09 schrieb Tobias Soloschenko < > >>> tobiassolosche...@googlemail.com>: > >>>>>> > >>>>>> Hi, > >>>>>> > >>>>>> would you be so kind and apply some more information like StackTrace > >>> of the interal server error. > >>>>>> > >>>>>> Thanks a lot. > >>>>>> > >>>>>> kind regards > >>>>>> > >>>>>> Tobias. > >>>>>> > >>>>>> Am 04.02.15 um 20:05 schrieb Chris: > >>>>>>> Sven, I have an additional situation where I am getting an internal > >>> error. Could you help me in figuring out the problem? > >>>>>>> > >>>>>>> Panel A senses the selection of an item from a user and adds the > >>> „sortable“ as container to the ajax target. > >>>>>>> In addition, Panel B should be added to the ajax target, using > >>> Wicket events. > >>>>>>> > >>>>>>> The internal error is thrown when using Wicket events to add the > >>> additional panel. Without the event, just calling > #target.add(sortable) it > >>> works. > >>>>>>> > >>>>>>> Panel A > >>>>>>> ************* > >>>>>>> @Override > >>>>>>> public void onSelect(AjaxRequestTarget target, List<String> items) > { > >>>>>>> sortable.onRemove(target, items.get(0)); > >>>>>>> target.add(sortable); > >>>>>>> send(getPage(), Broadcast.BREADTH, new > >>> DeleteItem(target)); > >>>>>>> } > >>>>>>> Panel B > >>>>>>> ************* > >>>>>>> public class PoiListPanel extends Panel { > >>>>>>> @Override > >>>>>>> public void onEvent(IEvent<?> event) { > >>>>>>> super.onEvent(event); > >>>>>>> > >>>>>>> if (event.getPayload() instanceof DeleteItem) { > >>>>>>> DeleteItem update = (DeleteItem) > >>> event.getPayload(); > >>>>>>> update.getTarget().add(this); > >>>>>>> > >>>>>>> } > >>>>>>> > >>>>>>> } > >>>>>>> Chris > >>>>>>> > >>>>>>> > >>>>>>>> Am 04.02.2015 um 14:32 schrieb Grün Christoph < > >>> christ...@ec.tuwien.ac.at>: > >>>>>>>> > >>>>>>>> Sven - thank you. That solved it! > >>>>>>>> > >>>>>>>> > >>>>>>>>> Am 04.02.2015 um 14:14 schrieb Sven Meier <s...@meiers.net>: > >>>>>>>>> > >>>>>>>>> Your container has to output its markup id: > >>>>>>>>> > >>>>>>>>> container.setOutputMarkupId() > >>>>>>>>> > >>>>>>>>> Regards > >>>>>>>>> Sven > >>>>>>>>> > >>>>>>>>> > >>>>>>>>> On 04.02.2015 14:11, Chris wrote: > >>>>>>>>>> Hi, > >>>>>>>>>> > >>>>>>>>>> When the user clicks on a certain icon, a specific part of the > >>> page should be reloaded through ajax. The icon is part of a panel, the > >>> specific part is a webmarkupcontainer added directly to the page. I am > >>> using Wicket Events to push the click event. However, when adding the > web > >>> markup container as target, I am getting an internal error. > >>>>>>>>>> > >>>>>>>>>> -> update.getTarget().add(container); > >>>>>>>>>> > >>>>>>>>>> Can someone help me to fix this? > >>>>>>>>>> > >>>>>>>>>> ********************* > >>>>>>>>>> ***** PANEL ***** > >>>>>>>>>> final WebMarkupContainer suitcaseIcon = new > >>> WebMarkupContainer("icon"); > >>>>>>>>>> icon.setOutputMarkupId(true); > >>>>>>>>>> icon.add(new AjaxEventBehavior("onclick") { > >>>>>>>>>> protected void onEvent(AjaxRequestTarget target) { > >>>>>>>>>> send(getPage(), Broadcast.BREADTH, new > >>> AddItem(target)); > >>>>>>>>>> } > >>>>>>>>>> }); > >>>>>>>>>> > >>>>>>>>>> ********************* > >>>>>>>>>> ***** PAGE ***** > >>>>>>>>>> ... > >>>>>>>>>> WebMarkupContainer container; > >>>>>>>>>> public HomePage() { > >>>>>>>>>> container = new WebMarkupContainer("container"); > >>>>>>>>>> add(container); > >>>>>>>>>> } > >>>>>>>>>> > >>>>>>>>>> @Override > >>>>>>>>>> public void onEvent(IEvent<?> event) { > >>>>>>>>>> super.onEvent(event); > >>>>>>>>>> if (event.getPayload() instanceof AddItem) { > >>>>>>>>>> AddItem update = (AddItem) event.getPayload(); > >>>>>>>>>> update.getTarget().add(container); > >>>>>>>>>> } > >>>>>>>>>> } > >>>>>>>>>> > >>>>>>>>>> ********************* > >>>>>>>>>> ***** AddItem ***** > >>>>>>>>>> public class AddItem { > >>>>>>>>>> private final AjaxRequestTarget target; > >>>>>>>>>> > >>>>>>>>>> public AddItem(AjaxRequestTarget target) { > >>>>>>>>>> this.target = target; > >>>>>>>>>> } > >>>>>>>>>> > >>>>>>>>>> public AjaxRequestTarget getTarget() { > >>>>>>>>>> return target; > >>>>>>>>>> } > >>>>>>>>>> } > >>>>>>>>>> > >>>>>>>>>> Thanks. > >>>>>>>>>> Chris > >>>>>>>>> > >>> --------------------------------------------------------------------- > >>>>>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >>>>>>>>> For additional commands, e-mail: users-h...@wicket.apache.org > >>>>>>>>> > >>>>>>>> > >>> --------------------------------------------------------------------- > >>>>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >>>>>>>> For additional commands, e-mail: users-h...@wicket.apache.org > >>>>>>>> > >>>>>> > >>>>>> > --------------------------------------------------------------------- > >>>>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >>>>>> For additional commands, e-mail: users-h...@wicket.apache.org > >>>>>> > >>>>> > >>>> > >>>> > >>>> --------------------------------------------------------------------- > >>>> To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org > >>>> For additional commands, e-mail: users-h...@wicket.apache.org > >>>> > >>> > >>> > >> > >