I have list with ajax link in each row. this link manage own row removeing process. whole list wrapped with WebMarkupContainer. By pressing the link, called next logic 1) item removed from DB. 2) updated list model 3) target.add(wmc) - add WebMarkupContainer to ajax for updating
since list has more then one element each remove action crashed on render stage. So after refresh page i see that action was done, but problem happened after that
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 populate method of 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 recived next 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 use wicket 7.0.0-M5
UPDATE I have found, that when i have more then 1 item in list, ajax callback attached only for first one. But on click action removed all items except one. Also ajax link called items count times.
I fount the problem. I have had same id not wicket:id, but general id, at each item. so listener had attached to first one, because wicket ajax listen for it. then it had called few times. Problem was in markup.
<span class="btn" wicket:id="actionKick" id="kick">Kick</span>
^^^^^^^^^---problem was here
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With