Problem with wiquery Slider in a ListView

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Problem with wiquery Slider in a ListView

I'm planning to do the following:

I get Infos from a JSONserver which tells me how much sliders I need, saves the values, etc. Works fine, not more is needed here. Every Slider is an Element in a ListView. (Works)

Now I want to add a ListView and in it create a slider and save the value. So at the end I i.e. have 4 Sliders generated from my ListView. (Works)

Later, I want to read the Values after clicking a Submit button.

Now my Problem: I see the Sliders, but when I touch one, I get the following Error:

Root cause:

java.lang.IllegalArgumentException: component cannot be null
at org.apache.wicket.ajax.AjaxRequestTarget.addComponent(
at org.apache.wicket.ajax.AbstractDefaultAjaxBehavior.onRequest(
at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(
at org.apache.wicket.RequestCycle.processEventsAndRespond(
at org.apache.wicket.RequestCycle.step(
at org.apache.wicket.RequestCycle.steps(
at org.apache.wicket.RequestCycle.request(
at org.apache.wicket.protocol.http.WicketFilter.doGet(
at org.apache.wicket.protocol.http.WicketFilter.doFilter(
at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(
at org.apache.catalina.core.ApplicationFilterChain.doFilter(
at org.apache.catalina.core.StandardWrapperValve.invoke(
at org.apache.catalina.core.StandardContextValve.invoke(
at org.apache.catalina.authenticator.AuthenticatorBase.invoke(
at org.apache.catalina.core.StandardHostValve.invoke(
at org.apache.catalina.valves.ErrorReportValve.invoke(
at org.apache.catalina.valves.AccessLogValve.invoke(
at org.apache.catalina.core.StandardEngineValve.invoke(
at org.apache.catalina.connector.CoyoteAdapter.service(
at org.apache.coyote.http11.Http11Processor.process(
at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$ Source)
at Source)

Here is my Code - It's mostly the official example, just packed into a Listview...

                add(new ListView<VirtualAttributes>("sliderlist", sliderlist) {
                        private static final long serialVersionUID = 1L;
                        private AbstractDefaultAjaxBehavior sliderBehavior;
                        private int sliderValue;
                        private Label sliderLabel;
                        private Slider slider;
            protected void populateItem(ListItem<VirtualAttributes> item) {
                                final VirtualAttributes s = item.getModelObject();
                                sliderValue = 0;
                                sliderBehavior = new AbstractDefaultAjaxBehavior() {
                                        private static final long serialVersionUID = 1L;
                                        protected void respond(AjaxRequestTarget target) {
                                                sliderValue = Integer.parseInt(this.getComponent().getRequest().getParameter("sliderValue"));
                                slider = new Slider("slider", 0, 100);
                                                new DefaultJsScopeUiEvent(
                                                                "wicketAjaxGet('" + sliderBehavior.getCallbackUrl(true)
                                                                + "&sliderValue='+" + Slider.UI_VALUE
                                                                + ", null,null, function() {return true;})"));

                                Label sliderLabel = new Label("sliderLabel", new PropertyModel(this, "sliderValue"));