I have a list with ajax link in each line. this link controls the process of deleting rows. entire list wrapped in WebMarkupContainer. By clicking on the link called the following logic 1) the item is deleted from the database. 2) updated list model 3) target.add (wmc) - add WebMarkupContainer to ajax to update
since the list contains more than one element, each of which removes the action broken during the rendering stage. Therefore, after refreshing the page, I see that the action was completed, but after that there was a problem
IKickListener onKickListener = new IKickListener() { @Override public void onKickListener(ListItem<Consultant> item, AjaxRequestTarget target) { Cons modelObject = item.getModelObject(); mUserDAO.remove(modelObject.accountId, getId()); updateListModel(); target.add(mWmc); target.appendJavaScript("console.log("kicked")"); } }; mWmc = new WebMarkupContainer("wmc"); mWmc.setOutputMarkupId(true); add(mWmc); ListView listView = new ConsListView("consList", new PropertyModel<List<? extends Cons>>(this, "consultants"), onKickListener); mWmc.add(listView);
and the method of filling my list
@Override protected void populateItem(final ListItem<ConsPanel.Cons> item) { item.add(new IndicatingAjaxLink("actionKick") { private static final long serialVersionUID = 1L; @Override public void onClick(AjaxRequestTarget target) { mKickListener.onKickListener(item, target); } }); }
then I got the following stack trace
org.apache.wicket.core.request.handler.ComponentNotFoundException: Component 'consPanelPlace:cons:wmc:consList:2:actionKick' has been removed from page. at org.apache.wicket.core.request.handler.ListenerInterfaceRequestHandler.respond(ListenerInterfaceRequestHandler.java:177) at org.apache.wicket.request.cycle.RequestCycle$HandlerExecutor.respond(RequestCycle.java:865) at org.apache.wicket.request.RequestHandlerStack.execute(RequestHandlerStack.java:64) at org.apache.wicket.request.cycle.RequestCycle.execute(RequestCycle.java:265) at org.apache.wicket.request.cycle.RequestCycle.processRequest(RequestCycle.java:222) at org.apache.wicket.request.cycle.RequestCycle.processRequestAndDetach(RequestCycle.java:293) at org.apache.wicket.protocol.http.WicketFilter.processRequestCycle(WicketFilter.java:261) at org.apache.wicket.protocol.http.WicketFilter.processRequest(WicketFilter.java:203) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:284) 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.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:506) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:142) 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:1145) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615) at org.apache.tomcat.util.threads.TaskThread$WrappingRunnable.run(TaskThread.java:61) at java.lang.Thread.run(Thread.java:745)
I am using wicket 7.0.0-M5
UPDATE I found that when I have more than one item in the list, the ajax callback is only bound to the first. But when you click on an action, all elements are deleted, except for one. Also, the ajax link is called element count time.