Re: Problems with CheckGroup

2009-08-04 Thread Martin Makundi
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 burnst...@burnstone.ch:
 Hi all

 I'm trying to use CheckGroup, but encounter some problems. First, my code:

 class NameValueListViewT extends ParameterValueProvider? extends
 ListViewT {

 U void displayItem(ListItemT listItem, ParameterValueProviderU
 parameter) {
 ...
 ListU enumItems = new ArrayListU(parameter.getEnumCodes());
 addMultiSelectPanelListItem(listItem, enumItems, labelModel, new
 PropertyModelCollectionU(parameter,
                     valueList), parameter);
 }

 U void addMultiSelectPanelListItem(ListItemT listItem,
   ListU enumItems, IModelString labelModel,
   IModelCollectionU model,
   final ParameterValueProviderU parameter) {

      CheckGroupU comp = new CheckGroupU(value);
      comp.setType(parameter.getType());
      comp.setRequired(!parameter.isOptional());
      comp.setLabel(labelModel);

      ListViewU enumListView = new ListViewU(values, enumItems) {
         @Override
         protected void populateItem(ListItemU item) {
            item.add(new CheckU(check, item.getModel()));
            item.add(new Label(value,
               item.getDefaultModelObjectAsString()));
         }
      };
      enumListView.setReuseItems(true);
      comp.add(enumListView);

      // Add panel
      MultiCheckBoxPanelU panelMCB = new
           MultiCheckBoxPanelU(COMPONENT_ID, comp);
      listItem.add(panelMCB);
 }
 }

 ParameterValueProvider has the mehtods {get,set}Value[List].

 The html looks like this:
 html xmlns:wicket
 wicket:panel
   span wicket:id=value
      span wicket:id=values
         input type=checkbox wicket:id=check /
         span wicket:id=value/span
         br/
      /span
   /span
 /wicket:panel
 /html

 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 

Re: Problems with CheckGroup

2009-08-04 Thread 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..).


U 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

2009-08-04 Thread Martin Makundi
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 burnst...@burnstone.ch:
 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..).

 U 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

2009-08-04 Thread burnstone

Debugging the code just tells me the same as the exception does:

CheckGroup.updateModel:

public void updateModel()
{
CollectionT 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 
FormComponentT, and CheckGroup extends FormComponentCollectionT.


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

2009-08-04 Thread Martin Makundi
Can you make a quickstart of it an send me?

**
Martin

2009/8/4 burnstone burnst...@burnstone.ch:
 Debugging the code just tells me the same as the exception does:

 CheckGroup.updateModel:

 public void updateModel()
 {
        CollectionT 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
 FormComponentT, and CheckGroup extends FormComponentCollectionT.

 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

2009-08-04 Thread Igor Vaynberg
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, burnstoneburnst...@burnstone.ch wrote:
 Debugging the code just tells me the same as the exception does:

 CheckGroup.updateModel:

 public void updateModel()
 {
        CollectionT 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
 FormComponentT, and CheckGroup extends FormComponentCollectionT.

 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

2009-08-04 Thread burnstone

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