Re: Problems with CheckGroup
burnstone wrote: Removing the setType-Call doesn't help. Sorry, after some more debugging and then testing The Right Thing (tm) I have to say this statement is wrong. Removing the call to setType() fixes my problem. Well. Thanks for holding my hand, anyway :) -- chris - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Problems with CheckGroup
so the next step is to step into convertinput() and see why its returning a string instead of a collection. -igor On Tue, Aug 4, 2009 at 1:20 AM, burnstone wrote: > Debugging the code just tells me the same as the exception does: > > CheckGroup.updateModel: > > public void updateModel() > { > Collection collection = getModelObject(); > if (collection == null) > { > collection = getConvertedInput(); > setDefaultModelObject(collection); > } > else > { > modelChanging(); > collection.clear(); > collection.addAll(getConvertedInput()); <- > modelChanged(); > } > } > > > getConvertedInput() returns a String instead of a collection instance. This > just has to be wrong, because it returns T, the parameter of > FormComponent, and CheckGroup extends FormComponent>. > > Removing the setType-Call doesn't help. > > Martin Makundi wrote: >> >> Have you tried to debug the code where you get the exception? I >> suspect that you just have some data types mixed. >> >> Maybe it is just this: comp.setType(parameter.getType()); Is that >> necessary? >> >> ** >> Martin >> > > - > 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
Re: Problems with CheckGroup
Can you make a quickstart of it an send me? ** Martin 2009/8/4 burnstone : > Debugging the code just tells me the same as the exception does: > > CheckGroup.updateModel: > > public void updateModel() > { > Collection collection = getModelObject(); > if (collection == null) > { > collection = getConvertedInput(); > setDefaultModelObject(collection); > } > else > { > modelChanging(); > collection.clear(); > collection.addAll(getConvertedInput()); <- > modelChanged(); > } > } > > > getConvertedInput() returns a String instead of a collection instance. This > just has to be wrong, because it returns T, the parameter of > FormComponent, and CheckGroup extends FormComponent>. > > Removing the setType-Call doesn't help. > > Martin Makundi wrote: >> >> Have you tried to debug the code where you get the exception? I >> suspect that you just have some data types mixed. >> >> Maybe it is just this: comp.setType(parameter.getType()); Is that >> necessary? >> >> ** >> Martin >> > > - > 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
Re: Problems with CheckGroup
Debugging the code just tells me the same as the exception does: CheckGroup.updateModel: public void updateModel() { Collection collection = getModelObject(); if (collection == null) { collection = getConvertedInput(); setDefaultModelObject(collection); } else { modelChanging(); collection.clear(); collection.addAll(getConvertedInput()); <- modelChanged(); } } getConvertedInput() returns a String instead of a collection instance. This just has to be wrong, because it returns T, the parameter of FormComponent, and CheckGroup extends FormComponent>. Removing the setType-Call doesn't help. Martin Makundi wrote: Have you tried to debug the code where you get the exception? I suspect that you just have some data types mixed. Maybe it is just this: comp.setType(parameter.getType()); Is that necessary? ** Martin - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Problems with CheckGroup
Have you tried to debug the code where you get the exception? I suspect that you just have some data types mixed. Maybe it is just this: comp.setType(parameter.getType()); Is that necessary? ** Martin 2009/8/4 burnstone : > Martin Makundi wrote: >> >> What is U? In my understanding Check(box) operates on a Boolean value >> so the classcast exception might be there (btw. I always use >> CheckBox.. I never tried Check..). > > is just the parameter type, in this case a String, but could be an > Integer or Float as well. > > The example code in wicket-examples uses Integers, btw. > > - > 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
Re: Problems with CheckGroup
Martin Makundi wrote: What is U? In my understanding Check(box) operates on a Boolean value so the classcast exception might be there (btw. I always use CheckBox.. I never tried Check..). is just the parameter type, in this case a String, but could be an Integer or Float as well. The example code in wicket-examples uses Integers, btw. - To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org For additional commands, e-mail: users-h...@wicket.apache.org
Re: Problems with CheckGroup
What is U? In my understanding Check(box) operates on a Boolean value so the classcast exception might be there (btw. I always use CheckBox.. I never tried Check..). ** Martin 2009/8/4 burnst...@burnstone.ch : > Hi all > > I'm trying to use CheckGroup, but encounter some problems. First, my code: > > class NameValueListView> extends > ListView { > > void displayItem(ListItem listItem, ParameterValueProvider > parameter) { > ... > List enumItems = new ArrayList(parameter.getEnumCodes()); > addMultiSelectPanelListItem(listItem, enumItems, labelModel, new > PropertyModel>(parameter, > "valueList"), parameter); > } > > void addMultiSelectPanelListItem(ListItem listItem, > List enumItems, IModel labelModel, > IModel> model, > final ParameterValueProvider parameter) { > > CheckGroup comp = new CheckGroup("value"); > comp.setType(parameter.getType()); > comp.setRequired(!parameter.isOptional()); > comp.setLabel(labelModel); > > ListView enumListView = new ListView("values", enumItems) { > @Override > protected void populateItem(ListItem item) { > item.add(new Check("check", item.getModel())); > item.add(new Label("value", > item.getDefaultModelObjectAsString())); > } > }; > enumListView.setReuseItems(true); > comp.add(enumListView); > > // Add panel > MultiCheckBoxPanel panelMCB = new > MultiCheckBoxPanel(COMPONENT_ID, comp); > listItem.add(panelMCB); > } > } > > ParameterValueProvider has the mehtods {get,set}Value[List]. > > The html looks like this: > > > > > > > > > > > > > So far, so good. Values are getting displayed and the correct check boxes > are selected. However, when submitting the form, I get an exception: > > --- > WicketMessage: Method onFormSubmitted of interface > org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component > [MarkupContainer [Component id = cardDetailForm]] threw an exception > > Root cause: > > java.lang.ClassCastException: java.lang.String > at > org.apache.wicket.markup.html.form.CheckGroup.updateModel(CheckGroup.java:171) > at > org.apache.wicket.markup.html.form.Form$FormModelUpdateVisitor.component(Form.java:225) > at > org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:514) > at > org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) > at > org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) > at > org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) > at > org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) > at > org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrder(FormComponent.java:465) > at > org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:2051) > at > org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:2019) > at org.apache.wicket.markup.html.form.Form.process(Form.java:984) > at org.apache.wicket.markup.html.form.Form.process(Form.java:911) > at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:876) > at java.lang.reflect.Method.invoke(Unknown Source) > at > org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182) > at > org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73) > at > org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) > at > org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1241) > at org.apache.wicket.RequestCycle.step(RequestCycle.java:1320) > at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1419) > at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) > at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) > at > org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) > at > org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334) > at > org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:286) > at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567) > at org.mortbay.http.HttpContext.handle(HttpContext.java:1807) > at > org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525) > at org.mortbay.http.HttpContext.handle(HttpContext.java:1757) > at org.mortbay.http.HttpServer.service(HttpServer.java:879) > at org.mortbay.http.HttpConnection.service(HttpConnection.java:789) > at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:960) > at org.mortbay.http.HttpConnecti
Problems with CheckGroup
Hi all I'm trying to use CheckGroup, but encounter some problems. First, my code: class NameValueListView> extends ListView { void displayItem(ListItem listItem, ParameterValueProvider parameter) { ... List enumItems = new ArrayList(parameter.getEnumCodes()); addMultiSelectPanelListItem(listItem, enumItems, labelModel, new PropertyModel>(parameter, "valueList"), parameter); } void addMultiSelectPanelListItem(ListItem listItem, List enumItems, IModel labelModel, IModel> model, final ParameterValueProvider parameter) { CheckGroup comp = new CheckGroup("value"); comp.setType(parameter.getType()); comp.setRequired(!parameter.isOptional()); comp.setLabel(labelModel); ListView enumListView = new ListView("values", enumItems) { @Override protected void populateItem(ListItem item) { item.add(new Check("check", item.getModel())); item.add(new Label("value", item.getDefaultModelObjectAsString())); } }; enumListView.setReuseItems(true); comp.add(enumListView); // Add panel MultiCheckBoxPanel panelMCB = new MultiCheckBoxPanel(COMPONENT_ID, comp); listItem.add(panelMCB); } } ParameterValueProvider has the mehtods {get,set}Value[List]. The html looks like this: So far, so good. Values are getting displayed and the correct check boxes are selected. However, when submitting the form, I get an exception: --- WicketMessage: Method onFormSubmitted of interface org.apache.wicket.markup.html.form.IFormSubmitListener targeted at component [MarkupContainer [Component id = cardDetailForm]] threw an exception Root cause: java.lang.ClassCastException: java.lang.String at org.apache.wicket.markup.html.form.CheckGroup.updateModel(CheckGroup.java:171) at org.apache.wicket.markup.html.form.Form$FormModelUpdateVisitor.component(Form.java:225) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:514) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrderHelper(FormComponent.java:493) at org.apache.wicket.markup.html.form.FormComponent.visitComponentsPostOrder(FormComponent.java:465) at org.apache.wicket.markup.html.form.Form.internalUpdateFormComponentModels(Form.java:2051) at org.apache.wicket.markup.html.form.Form.updateFormComponentModels(Form.java:2019) at org.apache.wicket.markup.html.form.Form.process(Form.java:984) at org.apache.wicket.markup.html.form.Form.process(Form.java:911) at org.apache.wicket.markup.html.form.Form.onFormSubmitted(Form.java:876) at java.lang.reflect.Method.invoke(Unknown Source) at org.apache.wicket.RequestListenerInterface.invoke(RequestListenerInterface.java:182) at org.apache.wicket.request.target.component.listener.ListenerInterfaceRequestTarget.processEvents(ListenerInterfaceRequestTarget.java:73) at org.apache.wicket.request.AbstractRequestCycleProcessor.processEvents(AbstractRequestCycleProcessor.java:92) at org.apache.wicket.RequestCycle.processEventsAndRespond(RequestCycle.java:1241) at org.apache.wicket.RequestCycle.step(RequestCycle.java:1320) at org.apache.wicket.RequestCycle.steps(RequestCycle.java:1419) at org.apache.wicket.RequestCycle.request(RequestCycle.java:545) at org.apache.wicket.protocol.http.WicketFilter.doGet(WicketFilter.java:456) at org.apache.wicket.protocol.http.WicketFilter.doFilter(WicketFilter.java:289) at org.mortbay.jetty.servlet.WebApplicationHandler$Chain.doFilter(WebApplicationHandler.java:334) at org.mortbay.jetty.servlet.WebApplicationHandler.dispatch(WebApplicationHandler.java:286) at org.mortbay.jetty.servlet.ServletHandler.handle(ServletHandler.java:567) at org.mortbay.http.HttpContext.handle(HttpContext.java:1807) at org.mortbay.jetty.servlet.WebApplicationContext.handle(WebApplicationContext.java:525) at org.mortbay.http.HttpContext.handle(HttpContext.java:1757) at org.mortbay.http.HttpServer.service(HttpServer.java:879) at org.mortbay.http.HttpConnection.service(HttpConnection.java:789) at org.mortbay.http.HttpConnection.handleNext(HttpConnection.java:960) at org.mortbay.http.HttpConnection.handle(HttpConnection.java:806) at org.mortbay.http.SocketListener.handleConnection(SocketListener.java:218) at org.mortbay.util.ThreadedServer.handle(ThreadedServer.java:331) at org.mortbay.util.ThreadPool$PoolThread.run(ThreadPool.java:520) Complete stack: org.apache.wicket.WicketRuntimeException: Method onFormSubmitted of interface org.apache.wicket.markup.html.form