You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@wicket.apache.org by pieter claassen <pi...@claassen.co.uk> on 2008/10/23 10:46:42 UTC

ListView broken?

I am getting a classcast exception in ListView that is stumping me.

This is the error message (top few lines)

WicketMessage: Error attaching this container for rendering:  
[MarkupContainer [Component id = questioneditform]]

Root cause:

java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
at  
org 
.apache 
.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
at org.apache.wicket.Component.getModelObject(Component.java:1558)
at com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm 
$1.populateItem(TemplateEditPage.java:93)


This is the code that generates my ListItems:

			ListView questions = new ListView("questions", template
					.getQuestions()) {


				@Override
				protected void populateItem(ListItem item) {
					final QuestionAndAnswer qanda = (QuestionAndAnswer) item
							.getModelObject();
					setModel(new CompoundPropertyModel(qanda));



I know for a fact that template.getQuestions() produces an ArrayList.

The arraylist works when there is only 1 item in it but when I have  
more than 1 item, it fails with the ClassCastException. Is this a  
wicket problem or am I doing something wrong?

Regards,
Pieter
pieter claassen
pieter@claassen.co.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by James Carman <ja...@carmanconsulting.com>.
How about just use PropertyListView?

On Thu, Oct 23, 2008 at 9:39 AM, pieter claassen <pi...@claassen.co.uk> wrote:
> Guys, thanks for all your feedback. You were right.
>
> Cheers,
> Pieter
>
> On Oct 23, 2008, at 2:44 PM, Jeremy Thomerson wrote:
>
>> Johan nailed it... here are your bad lines:
>>
>>  System.out.println("+++++++"+
>> item.getModelObject().getClass().getName());
>>  final QuestionAndAnswer qanda = (QuestionAndAnswer)
>> item.getModelObject();
>>  setModel(new CompoundPropertyModel(qanda));
>>
>> That should just be changed to:
>>
>>  item.setModel(new CompoundPropertyModel(item.getModel());
>>
>> if that's what you want.
>>
>> -- Jeremy Thomerson
>> http://www.wickettraining.com
>>
>> On Thu, Oct 23, 2008 at 6:13 AM, Johan Compagner
>> <jc...@gmail.com>wrote:
>>
>>> What are you doing there?
>>> You get a model object from the listitem
>>> And then you are calling setmodel(compound) on the listview itself?
>>> Why is that then you are changing the model of the listview inside the
>>> loop that it goes over them creating listitems!
>>>
>>> On 10/23/08, pieter claassen <pi...@claassen.co.uk> wrote:
>>>>
>>>> I am getting a classcast exception in ListView that is stumping me.
>>>>
>>>> This is the error message (top few lines)
>>>>
>>>> WicketMessage: Error attaching this container for rendering:
>>>> [MarkupContainer [Component id = questioneditform]]
>>>>
>>>> Root cause:
>>>>
>>>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>>>> at
>>>> org
>>>> .apache
>>>> .wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>>>> at com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm
>>>> $1.populateItem(TemplateEditPage.java:93)
>>>>
>>>>
>>>> This is the code that generates my ListItems:
>>>>
>>>>                     ListView questions = new ListView("questions",
>>>
>>> template
>>>>
>>>>                                     .getQuestions()) {
>>>>
>>>>
>>>>                             @Override
>>>>                             protected void populateItem(ListItem item)
>>>
>>> {
>>>>
>>>>                                     final QuestionAndAnswer qanda =
>>>
>>> (QuestionAndAnswer) item
>>>>
>>>>                                                     .getModelObject();
>>>>                                     setModel(new
>>>
>>> CompoundPropertyModel(qanda));
>>>>
>>>>
>>>>
>>>> I know for a fact that template.getQuestions() produces an ArrayList.
>>>>
>>>> The arraylist works when there is only 1 item in it but when I have
>>>> more than 1 item, it fails with the ClassCastException. Is this a
>>>> wicket problem or am I doing something wrong?
>>>>
>>>> Regards,
>>>> Pieter
>>>> pieter claassen
>>>> pieter@claassen.co.uk
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>
> pieter claassen
> pieter@claassen.co.uk
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by pieter claassen <pi...@claassen.co.uk>.
Guys, thanks for all your feedback. You were right.

Cheers,
Pieter

On Oct 23, 2008, at 2:44 PM, Jeremy Thomerson wrote:

> Johan nailed it... here are your bad lines:
>
>   System.out.println("+++++++"+
> item.getModelObject().getClass().getName());
>   final QuestionAndAnswer qanda = (QuestionAndAnswer)
> item.getModelObject();
>   setModel(new CompoundPropertyModel(qanda));
>
> That should just be changed to:
>
>   item.setModel(new CompoundPropertyModel(item.getModel());
>
> if that's what you want.
>
> --  
> Jeremy Thomerson
> http://www.wickettraining.com
>
> On Thu, Oct 23, 2008 at 6:13 AM, Johan Compagner  
> <jc...@gmail.com>wrote:
>
>> What are you doing there?
>> You get a model object from the listitem
>> And then you are calling setmodel(compound) on the listview itself?
>> Why is that then you are changing the model of the listview inside  
>> the
>> loop that it goes over them creating listitems!
>>
>> On 10/23/08, pieter claassen <pi...@claassen.co.uk> wrote:
>>> I am getting a classcast exception in ListView that is stumping me.
>>>
>>> This is the error message (top few lines)
>>>
>>> WicketMessage: Error attaching this container for rendering:
>>> [MarkupContainer [Component id = questioneditform]]
>>>
>>> Root cause:
>>>
>>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>>> at
>>> org
>>> .apache
>>> .wicket 
>>> .markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>>> at com.musmato.wicket.pages.templates.TemplateEditPage 
>>> $QuestionEditForm
>>> $1.populateItem(TemplateEditPage.java:93)
>>>
>>>
>>> This is the code that generates my ListItems:
>>>
>>>                      ListView questions = new ListView("questions",
>> template
>>>                                      .getQuestions()) {
>>>
>>>
>>>                              @Override
>>>                              protected void populateItem(ListItem  
>>> item)
>> {
>>>                                      final QuestionAndAnswer qanda =
>> (QuestionAndAnswer) item
>>>                                                      .getModelObject 
>>> ();
>>>                                      setModel(new
>> CompoundPropertyModel(qanda));
>>>
>>>
>>>
>>> I know for a fact that template.getQuestions() produces an  
>>> ArrayList.
>>>
>>> The arraylist works when there is only 1 item in it but when I have
>>> more than 1 item, it fails with the ClassCastException. Is this a
>>> wicket problem or am I doing something wrong?
>>>
>>> Regards,
>>> Pieter
>>> pieter claassen
>>> pieter@claassen.co.uk
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>

pieter claassen
pieter@claassen.co.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by Jeremy Thomerson <je...@wickettraining.com>.
Johan nailed it... here are your bad lines:

   System.out.println("+++++++"+
item.getModelObject().getClass().getName());
   final QuestionAndAnswer qanda = (QuestionAndAnswer)
item.getModelObject();
   setModel(new CompoundPropertyModel(qanda));

That should just be changed to:

   item.setModel(new CompoundPropertyModel(item.getModel());

if that's what you want.

-- 
Jeremy Thomerson
http://www.wickettraining.com

On Thu, Oct 23, 2008 at 6:13 AM, Johan Compagner <jc...@gmail.com>wrote:

> What are you doing there?
> You get a model object from the listitem
> And then you are calling setmodel(compound) on the listview itself?
> Why is that then you are changing the model of the listview inside the
> loop that it goes over them creating listitems!
>
> On 10/23/08, pieter claassen <pi...@claassen.co.uk> wrote:
> > I am getting a classcast exception in ListView that is stumping me.
> >
> > This is the error message (top few lines)
> >
> > WicketMessage: Error attaching this container for rendering:
> > [MarkupContainer [Component id = questioneditform]]
> >
> > Root cause:
> >
> > java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
> > at
> > org
> > .apache
> > .wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
> > at org.apache.wicket.Component.getModelObject(Component.java:1558)
> > at com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm
> > $1.populateItem(TemplateEditPage.java:93)
> >
> >
> > This is the code that generates my ListItems:
> >
> >                       ListView questions = new ListView("questions",
> template
> >                                       .getQuestions()) {
> >
> >
> >                               @Override
> >                               protected void populateItem(ListItem item)
> {
> >                                       final QuestionAndAnswer qanda =
> (QuestionAndAnswer) item
> >                                                       .getModelObject();
> >                                       setModel(new
> CompoundPropertyModel(qanda));
> >
> >
> >
> > I know for a fact that template.getQuestions() produces an ArrayList.
> >
> > The arraylist works when there is only 1 item in it but when I have
> > more than 1 item, it fails with the ClassCastException. Is this a
> > wicket problem or am I doing something wrong?
> >
> > Regards,
> > Pieter
> > pieter claassen
> > pieter@claassen.co.uk
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> > For additional commands, e-mail: users-help@wicket.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: ListView broken?

Posted by Johan Compagner <jc...@gmail.com>.
What are you doing there?
You get a model object from the listitem
And then you are calling setmodel(compound) on the listview itself?
Why is that then you are changing the model of the listview inside the
loop that it goes over them creating listitems!

On 10/23/08, pieter claassen <pi...@claassen.co.uk> wrote:
> I am getting a classcast exception in ListView that is stumping me.
>
> This is the error message (top few lines)
>
> WicketMessage: Error attaching this container for rendering:
> [MarkupContainer [Component id = questioneditform]]
>
> Root cause:
>
> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
> at
> org
> .apache
> .wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
> at org.apache.wicket.Component.getModelObject(Component.java:1558)
> at com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm
> $1.populateItem(TemplateEditPage.java:93)
>
>
> This is the code that generates my ListItems:
>
> 			ListView questions = new ListView("questions", template
> 					.getQuestions()) {
>
>
> 				@Override
> 				protected void populateItem(ListItem item) {
> 					final QuestionAndAnswer qanda = (QuestionAndAnswer) item
> 							.getModelObject();
> 					setModel(new CompoundPropertyModel(qanda));
>
>
>
> I know for a fact that template.getQuestions() produces an ArrayList.
>
> The arraylist works when there is only 1 item in it but when I have
> more than 1 item, it fails with the ClassCastException. Is this a
> wicket problem or am I doing something wrong?
>
> Regards,
> Pieter
> pieter claassen
> pieter@claassen.co.uk
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by pieter claassen <pi...@claassen.co.uk>.
Comments inline:

On Oct 23, 2008, at 10:59 AM, Serkan Camurcuoglu wrote:

>
> it seems like template.getQuestions() returns a model which has a
> QuestionAndAnswer instance instead of a list as its model object..


This is the code in template that returns an arraylist.

	public ArrayList<QuestionAndAnswer> getQuestions() {
		return questions;
	}

Is this correct?

P


> The code
> on the line where the exception is thrown is:
>
> return ((List)listView.getModelObject()).get(index);
>
> which indicates that your problem is trying to cast a  
> QuestionAndAnswer
> instance to a List. Everyone is using ListView and it cannot be  
> broken this
> way :)
>
>
>
>
> Pieter Claassen wrote:
>>
>> I am getting a classcast exception in ListView that is stumping me.
>>
>> This is the error message (top few lines)
>>
>> WicketMessage: Error attaching this container for rendering:
>> [MarkupContainer [Component id = questioneditform]]
>>
>> Root cause:
>>
>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>> at
>> org
>> .apache
>> .wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java: 
>> 55)
>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>> at com.musmato.wicket.pages.templates.TemplateEditPage 
>> $QuestionEditForm
>> $1.populateItem(TemplateEditPage.java:93)
>>
>>
>> This is the code that generates my ListItems:
>>
>> 			ListView questions = new ListView("questions", template
>> 					.getQuestions()) {
>>
>>
>> 				@Override
>> 				protected void populateItem(ListItem item) {
>> 					final QuestionAndAnswer qanda = (QuestionAndAnswer) item
>> 							.getModelObject();
>> 					setModel(new CompoundPropertyModel(qanda));
>>
>>
>>
>> I know for a fact that template.getQuestions() produces an ArrayList.
>>
>> The arraylist works when there is only 1 item in it but when I have
>> more than 1 item, it fails with the ClassCastException. Is this a
>> wicket problem or am I doing something wrong?
>>
>> Regards,
>> Pieter
>> pieter claassen
>> pieter@claassen.co.uk
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>>
>
> -- 
> View this message in context: http://www.nabble.com/ListView-broken--tp20126952p20127126.html
> Sent from the Wicket - User mailing list archive at Nabble.com.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

pieter claassen
pieter@claassen.co.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by Serkan Camurcuoglu <se...@telenity.com>.
it seems like template.getQuestions() returns a model which has a
QuestionAndAnswer instance instead of a list as its model object.. The code
on the line where the exception is thrown is:

return ((List)listView.getModelObject()).get(index);

which indicates that your problem is trying to cast a QuestionAndAnswer
instance to a List. Everyone is using ListView and it cannot be broken this
way :)




Pieter Claassen wrote:
> 
> I am getting a classcast exception in ListView that is stumping me.
> 
> This is the error message (top few lines)
> 
> WicketMessage: Error attaching this container for rendering:  
> [MarkupContainer [Component id = questioneditform]]
> 
> Root cause:
> 
> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
> at  
> org 
> .apache 
> .wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
> at org.apache.wicket.Component.getModelObject(Component.java:1558)
> at com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm 
> $1.populateItem(TemplateEditPage.java:93)
> 
> 
> This is the code that generates my ListItems:
> 
> 			ListView questions = new ListView("questions", template
> 					.getQuestions()) {
> 
> 
> 				@Override
> 				protected void populateItem(ListItem item) {
> 					final QuestionAndAnswer qanda = (QuestionAndAnswer) item
> 							.getModelObject();
> 					setModel(new CompoundPropertyModel(qanda));
> 
> 
> 
> I know for a fact that template.getQuestions() produces an ArrayList.
> 
> The arraylist works when there is only 1 item in it but when I have  
> more than 1 item, it fails with the ClassCastException. Is this a  
> wicket problem or am I doing something wrong?
> 
> Regards,
> Pieter
> pieter claassen
> pieter@claassen.co.uk
> 
> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
> 
> 
> 

-- 
View this message in context: http://www.nabble.com/ListView-broken--tp20126952p20127126.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by Serkan Camurcuoglu <se...@telenity.com>.
I suspect there may be a strange interaction with compound property models,
since the name of your listview is questions and you also have a
getQuestions() method in your upper level model object.. I'm just guessing
but can you try to change the name of your listview to "questionList"
instead of "questions" and try again..

by the way are you sure that you've rebuilt and redeployed your
application..
-- 
View this message in context: http://www.nabble.com/ListView-broken--tp20126952p20128604.html
Sent from the Wicket - User mailing list archive at Nabble.com.


---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: Applet Wicket communication

Posted by Francis De Brabandere <fr...@gmail.com>.
Just use an plain servlet, and talk to it using http + add the
WicketSessionFilter in front of it so you can interact with the wicket
session

http://www.wicket-framework.org/apidocs/wicket/protocol/http/servlet/WicketSessionFilter.html

On Thu, Oct 23, 2008 at 1:21 PM, Iqbal Akhtar <iq...@hotmail.com> wrote:
> Hi everyone,
>
> I need help regarding applet to wicket communication. Any help, code, pointer will be appreciated.
>
> Thanks and Regards,
> Iqbal
>
> _________________________________________________________________
> Explore the seven wonders of the world
> http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE



-- 
http://www.somatik.be
Microsoft gives you windows, Linux gives you the whole house.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Applet Wicket communication

Posted by Iqbal Akhtar <iq...@hotmail.com>.
Hi everyone, 

I need help regarding applet to wicket communication. Any help, code, pointer will be appreciated.

Thanks and Regards,
Iqbal

_________________________________________________________________
Explore the seven wonders of the world
http://search.msn.com/results.aspx?q=7+wonders+world&mkt=en-US&form=QBRE

Re: ListView broken?

Posted by James Carman <ja...@carmanconsulting.com>.
So, what does it print when you print out the class name?

On Thu, Oct 23, 2008 at 6:24 AM, pieter claassen <pi...@claassen.co.uk> wrote:
> Ok, I might be doing something thats not ok but ..... there are not two
> ListViews on this page (there are 3 forms? Is this a problem?)
> ClassCastException is throw at System.out.println("++++")
>
>
> package com.musmato.wicket.pages.templates;
>
> import java.util.Arrays;
>
> import org.apache.wicket.markup.html.form.DropDownChoice;
> import org.apache.wicket.markup.html.form.Form;
> import org.apache.wicket.markup.html.form.RequiredTextField;
> import org.apache.wicket.markup.html.form.TextArea;
> import org.apache.wicket.markup.html.link.Link;
> import org.apache.wicket.markup.html.list.ListItem;
> import org.apache.wicket.markup.html.list.ListView;
> import org.apache.wicket.model.CompoundPropertyModel;
>
> import com.musmato.model.QuestionAndAnswer;
> import com.musmato.model.Role;
> import com.musmato.model.Template;
> import com.musmato.model.WebControlType;
> import com.musmato.wicket.model.QuestionAndAnswerWebModel;
> import com.musmato.wicket.model.TemplateWebModel;
> import com.musmato.wicket.pages.AuthPage;
> import com.musmato.wicket.util.WicketApplication;
>
> public class TemplateEditPage extends AuthPage {
>
>        public TemplateEditPage(TemplateWebModel templatemodel) {
>
>                add(new TemplateEditForm("templateeditform", templatemodel));
>                add(new QuestionAddForm("questionaddform", templatemodel));
>                add(new QuestionEditForm("questioneditform", templatemodel));
>        }
>
>        @Override
>        public Role[] getAllowedRoles() {
>                // TODO Auto-generated method stub
>                return null;
>        }
>
>        private class TemplateEditForm extends Form {
>                private final Template template;
>
>                public TemplateEditForm(String id, TemplateWebModel
> templatemodel) {
>                        super(id);
>                        template = (Template) templatemodel.getObject();
>                        setModel(new CompoundPropertyModel(templatemodel));
>                        add(new RequiredTextField("name"));
>                        add(new RequiredTextField("version"));
>                        add(new TextArea("description"));
>                }
>
>                @Override
>                public void onSubmit() {
>
>  WicketApplication.get().getTemplateFactory().store(template);
>                        setResponsePage(new TemplateEditPage(new
> TemplateWebModel(template)));
>                }
>        }
>
>        private class QuestionAddForm extends Form {
>                private final Template template;
>
>                public QuestionAddForm(String id, TemplateWebModel
> templatemodel) {
>                        super(id);
>                        template = (Template) templatemodel.getObject();
>                        setModel(new CompoundPropertyModel(new
> QuestionAndAnswerWebModel(
>                                        (Long) null)));
>                        add(new RequiredTextField("question"));
>                        add(new DropDownChoice("type",
> Arrays.asList(WebControlType
>                                        .values())));
>                }
>
>                @Override
>                public void onSubmit() {
>                        QuestionAndAnswer qanda = (QuestionAndAnswer)
> getModel()
>                                        .getObject();
>
>                        template.addQuestion(qanda);
>
>  WicketApplication.get().getTemplateFactory().store(template);
>                        setResponsePage(new TemplateEditPage(new
> TemplateWebModel(template)));
>                }
>        }
>
>        private class QuestionEditForm extends Form {
>                private Template template;
>
>                public QuestionEditForm(String id, TemplateWebModel
> templatemodel) {
>                        super(id);
>                        template = (Template) templatemodel.getObject();
>                        ListView questionlist = new ListView("questions",
> template
>                                        .getQuestions()) {
>                                @Override
>                                protected void populateItem(ListItem item) {
>                                        System.out.println("+++++++"
>                                                        +
> item.getModelObject().getClass().getName());
>                                        final QuestionAndAnswer qanda =
> (QuestionAndAnswer) item
>                                                        .getModelObject();
>                                        setModel(new
> CompoundPropertyModel(qanda));
>                                        item.add(new
> RequiredTextField("question"));
>                                        item.add(new DropDownChoice("type",
> Arrays
>
>  .asList(WebControlType.values())));
>                                        item.add(new Link("delete") {
>                                                @Override
>                                                public void onClick() {
>
>  template.delQuestion(qanda);
>                                                        setResponsePage(new
> TemplateEditPage(
>                                                                        new
> TemplateWebModel(template)));
>                                                }
>                                        });
>                                }
>                        };
>                        add(questionlist);
>                }
>
>                @Override
>                public void onSubmit() {
>
>  WicketApplication.get().getTemplateFactory().store(template);
>                        setResponsePage(new TemplateEditPage(new
> TemplateWebModel(template)));
>                }
>        }
> }
>
> On Oct 23, 2008, at 12:04 PM, Martijn Dashorst wrote:
>
>> The classcastexception happens on retrieving the N-th item from the
>> list. The class cast tries to cast the model object of the listview to
>> a List. Apparently the argument to the listview is not a List, but
>> somethign that returns a QuestionAndAnswer.
>>
>> Are you looking at the correct ListView (i.e. are there more ListView
>> s on your page)?
>>
>> Martijn
>>
>> On Thu, Oct 23, 2008 at 11:55 AM, Dipu <di...@googlemail.com> wrote:
>>>
>>> pass , sorry i have no clue
>>>
>>> On Thu, Oct 23, 2008 at 10:37 AM, pieter claassen
>>> <pi...@claassen.co.uk>wrote:
>>>
>>>> Ok, I added;
>>>>
>>>> public class Debug {
>>>>      public static void debug(List list) {
>>>>              for (Object item : list) {
>>>>                      System.out.println("++DEBUG++: " +
>>>> item.getClass().toString());
>>>>              }
>>>>      }
>>>>
>>>>
>>>> and called debug just before I returned my ArrayList of question:
>>>>
>>>>      public ArrayList<QuestionAndAnswer> getQuestions() {
>>>>              Debug.debug(questions);
>>>>              return questions;
>>>>      }
>>>>
>>>> This is what I saw in my console. There are two objects in the list and
>>>> they are both QuestionAndAnswer objects
>>>>
>>>>
>>>> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
>>>> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
>>>>
>>>> Regards,
>>>> Pieter
>>>>
>>>>
>>>> On Oct 23, 2008, at 11:18 AM, Dipu wrote:
>>>>
>>>> can't you check what exactly is being returned by
>>>> template.getQuestions()
>>>>>
>>>>> and if its a list what are the items in it
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen
>>>>> <pieter@claassen.co.uk
>>>>>>
>>>>>> wrote:
>>>>>
>>>>> Hi Dipu,
>>>>>>
>>>>>> I tried that but when I do the following:
>>>>>>
>>>>>>            protected void populateItem(ListItem item) {
>>>>>>                    System.out.println("+++++++" +
>>>>>> item.getModelObject().getClass().getName());
>>>>>>                    final QuestionAndAnswer qanda = (QuestionAndAnswer)
>>>>>> item.getModelObject();
>>>>>>
>>>>>> I find that I now get the ClassCastException in the System.out.println
>>>>>> line. It is clear as mud that the problem is that I am trying to force
>>>>>> something into a list which is not a list?
>>>>>>
>>>>>> Regards,
>>>>>> Pieter
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Oct 23, 2008, at 10:59 AM, Dipu wrote:
>>>>>>
>>>>>> looks like template.getQuestions() is returning a list  with items in
>>>>>> it
>>>>>>
>>>>>>> which is not of the type QuestionAndAnswer
>>>>>>>
>>>>>>> try iterating through the list and logging the class name of each
>>>>>>> item
>>>>>>> in
>>>>>>> it
>>>>>>>
>>>>>>> Dipu
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen
>>>>>>> <pieter@claassen.co.uk
>>>>>>>
>>>>>>>> wrote:
>>>>>>>>
>>>>>>>
>>>>>>> I am getting a classcast exception in ListView that is stumping me.
>>>>>>>
>>>>>>>>
>>>>>>>> This is the error message (top few lines)
>>>>>>>>
>>>>>>>> WicketMessage: Error attaching this container for rendering:
>>>>>>>> [MarkupContainer [Component id = questioneditform]]
>>>>>>>>
>>>>>>>> Root cause:
>>>>>>>>
>>>>>>>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> org.apache.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>>>>>>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>>>>>>>> at
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm$1.populateItem(TemplateEditPage.java:93)
>>>>>>>>
>>>>>>>>
>>>>>>>> This is the code that generates my ListItems:
>>>>>>>>
>>>>>>>>                  ListView questions = new ListView("questions",
>>>>>>>> template
>>>>>>>>                                  .getQuestions()) {
>>>>>>>>
>>>>>>>>
>>>>>>>>                          @Override
>>>>>>>>                          protected void populateItem(ListItem item)
>>>>>>>> {
>>>>>>>>                                  final QuestionAndAnswer qanda =
>>>>>>>> (QuestionAndAnswer) item
>>>>>>>>                                                  .getModelObject();
>>>>>>>>                                  setModel(new
>>>>>>>> CompoundPropertyModel(qanda));
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> I know for a fact that template.getQuestions() produces an
>>>>>>>> ArrayList.
>>>>>>>>
>>>>>>>> The arraylist works when there is only 1 item in it but when I have
>>>>>>>> more
>>>>>>>> than 1 item, it fails with the ClassCastException. Is this a wicket
>>>>>>>> problem
>>>>>>>> or am I doing something wrong?
>>>>>>>>
>>>>>>>> Regards,
>>>>>>>> Pieter
>>>>>>>> pieter claassen
>>>>>>>> pieter@claassen.co.uk
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> ---------------------------------------------------------------------
>>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>>
>>>>>>>>
>>>>>>>>
>>>>>>>> pieter claassen
>>>>>>
>>>>>> pieter@claassen.co.uk
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>> pieter claassen
>>>> pieter@claassen.co.uk
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>
>>
>>
>>
>> --
>> Become a Wicket expert, learn from the best: http://wicketinaction.com
>> Apache Wicket 1.3.4 is released
>> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>
> pieter claassen
> pieter@claassen.co.uk
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by pieter claassen <pi...@claassen.co.uk>.
Ok, I might be doing something thats not ok but ..... there are not  
two ListViews on this page (there are 3 forms? Is this a problem?)  
ClassCastException is throw at System.out.println("++++")


package com.musmato.wicket.pages.templates;

import java.util.Arrays;

import org.apache.wicket.markup.html.form.DropDownChoice;
import org.apache.wicket.markup.html.form.Form;
import org.apache.wicket.markup.html.form.RequiredTextField;
import org.apache.wicket.markup.html.form.TextArea;
import org.apache.wicket.markup.html.link.Link;
import org.apache.wicket.markup.html.list.ListItem;
import org.apache.wicket.markup.html.list.ListView;
import org.apache.wicket.model.CompoundPropertyModel;

import com.musmato.model.QuestionAndAnswer;
import com.musmato.model.Role;
import com.musmato.model.Template;
import com.musmato.model.WebControlType;
import com.musmato.wicket.model.QuestionAndAnswerWebModel;
import com.musmato.wicket.model.TemplateWebModel;
import com.musmato.wicket.pages.AuthPage;
import com.musmato.wicket.util.WicketApplication;

public class TemplateEditPage extends AuthPage {

	public TemplateEditPage(TemplateWebModel templatemodel) {

		add(new TemplateEditForm("templateeditform", templatemodel));
		add(new QuestionAddForm("questionaddform", templatemodel));
		add(new QuestionEditForm("questioneditform", templatemodel));
	}

	@Override
	public Role[] getAllowedRoles() {
		// TODO Auto-generated method stub
		return null;
	}

	private class TemplateEditForm extends Form {
		private final Template template;

		public TemplateEditForm(String id, TemplateWebModel templatemodel) {
			super(id);
			template = (Template) templatemodel.getObject();
			setModel(new CompoundPropertyModel(templatemodel));
			add(new RequiredTextField("name"));
			add(new RequiredTextField("version"));
			add(new TextArea("description"));
		}

		@Override
		public void onSubmit() {
			WicketApplication.get().getTemplateFactory().store(template);
			setResponsePage(new TemplateEditPage(new  
TemplateWebModel(template)));
		}
	}

	private class QuestionAddForm extends Form {
		private final Template template;

		public QuestionAddForm(String id, TemplateWebModel templatemodel) {
			super(id);
			template = (Template) templatemodel.getObject();
			setModel(new CompoundPropertyModel(new QuestionAndAnswerWebModel(
					(Long) null)));
			add(new RequiredTextField("question"));
			add(new DropDownChoice("type", Arrays.asList(WebControlType
					.values())));
		}

		@Override
		public void onSubmit() {
			QuestionAndAnswer qanda = (QuestionAndAnswer) getModel()
					.getObject();

			template.addQuestion(qanda);
			WicketApplication.get().getTemplateFactory().store(template);
			setResponsePage(new TemplateEditPage(new  
TemplateWebModel(template)));
		}
	}

	private class QuestionEditForm extends Form {
		private Template template;

		public QuestionEditForm(String id, TemplateWebModel templatemodel) {
			super(id);
			template = (Template) templatemodel.getObject();
			ListView questionlist = new ListView("questions", template
					.getQuestions()) {
				@Override
				protected void populateItem(ListItem item) {
					System.out.println("+++++++"
							+ item.getModelObject().getClass().getName());
					final QuestionAndAnswer qanda = (QuestionAndAnswer) item
							.getModelObject();
					setModel(new CompoundPropertyModel(qanda));
					item.add(new RequiredTextField("question"));
					item.add(new DropDownChoice("type", Arrays
							.asList(WebControlType.values())));
					item.add(new Link("delete") {
						@Override
						public void onClick() {
							template.delQuestion(qanda);
							setResponsePage(new TemplateEditPage(
									new TemplateWebModel(template)));
						}
					});
				}
			};
			add(questionlist);
		}

		@Override
		public void onSubmit() {
			WicketApplication.get().getTemplateFactory().store(template);
			setResponsePage(new TemplateEditPage(new  
TemplateWebModel(template)));
		}
	}
}

On Oct 23, 2008, at 12:04 PM, Martijn Dashorst wrote:

> The classcastexception happens on retrieving the N-th item from the
> list. The class cast tries to cast the model object of the listview to
> a List. Apparently the argument to the listview is not a List, but
> somethign that returns a QuestionAndAnswer.
>
> Are you looking at the correct ListView (i.e. are there more ListView
> s on your page)?
>
> Martijn
>
> On Thu, Oct 23, 2008 at 11:55 AM, Dipu <di...@googlemail.com>  
> wrote:
>> pass , sorry i have no clue
>>
>> On Thu, Oct 23, 2008 at 10:37 AM, pieter claassen <pieter@claassen.co.uk 
>> >wrote:
>>
>>> Ok, I added;
>>>
>>> public class Debug {
>>>       public static void debug(List list) {
>>>               for (Object item : list) {
>>>                       System.out.println("++DEBUG++: " +
>>> item.getClass().toString());
>>>               }
>>>       }
>>>
>>>
>>> and called debug just before I returned my ArrayList of question:
>>>
>>>       public ArrayList<QuestionAndAnswer> getQuestions() {
>>>               Debug.debug(questions);
>>>               return questions;
>>>       }
>>>
>>> This is what I saw in my console. There are two objects in the  
>>> list and
>>> they are both QuestionAndAnswer objects
>>>
>>>
>>> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
>>> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
>>>
>>> Regards,
>>> Pieter
>>>
>>>
>>> On Oct 23, 2008, at 11:18 AM, Dipu wrote:
>>>
>>> can't you check what exactly is being returned by  
>>> template.getQuestions()
>>>> and if its a list what are the items in it
>>>>
>>>>
>>>>
>>>>
>>>> On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen <pieter@claassen.co.uk
>>>>> wrote:
>>>>
>>>> Hi Dipu,
>>>>>
>>>>> I tried that but when I do the following:
>>>>>
>>>>>             protected void populateItem(ListItem item) {
>>>>>                     System.out.println("+++++++" +
>>>>> item.getModelObject().getClass().getName());
>>>>>                     final QuestionAndAnswer qanda =  
>>>>> (QuestionAndAnswer)
>>>>> item.getModelObject();
>>>>>
>>>>> I find that I now get the ClassCastException in the  
>>>>> System.out.println
>>>>> line. It is clear as mud that the problem is that I am trying to  
>>>>> force
>>>>> something into a list which is not a list?
>>>>>
>>>>> Regards,
>>>>> Pieter
>>>>>
>>>>>
>>>>>
>>>>> On Oct 23, 2008, at 10:59 AM, Dipu wrote:
>>>>>
>>>>> looks like template.getQuestions() is returning a list  with  
>>>>> items in it
>>>>>
>>>>>> which is not of the type QuestionAndAnswer
>>>>>>
>>>>>> try iterating through the list and logging the class name of  
>>>>>> each item
>>>>>> in
>>>>>> it
>>>>>>
>>>>>> Dipu
>>>>>>
>>>>>>
>>>>>>
>>>>>> On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen <pieter@claassen.co.uk
>>>>>>
>>>>>>> wrote:
>>>>>>>
>>>>>>
>>>>>> I am getting a classcast exception in ListView that is stumping  
>>>>>> me.
>>>>>>
>>>>>>>
>>>>>>> This is the error message (top few lines)
>>>>>>>
>>>>>>> WicketMessage: Error attaching this container for rendering:
>>>>>>> [MarkupContainer [Component id = questioneditform]]
>>>>>>>
>>>>>>> Root cause:
>>>>>>>
>>>>>>> java.lang.ClassCastException:  
>>>>>>> com.musmato.model.QuestionAndAnswer
>>>>>>> at
>>>>>>>
>>>>>>>
>>>>>>> org 
>>>>>>> .apache 
>>>>>>> .wicket 
>>>>>>> .markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>>>>>> at org.apache.wicket.Component.getModelObject(Component.java: 
>>>>>>> 1558)
>>>>>>> at
>>>>>>>
>>>>>>>
>>>>>>> com.musmato.wicket.pages.templates.TemplateEditPage 
>>>>>>> $QuestionEditForm$1.populateItem(TemplateEditPage.java:93)
>>>>>>>
>>>>>>>
>>>>>>> This is the code that generates my ListItems:
>>>>>>>
>>>>>>>                   ListView questions = new ListView("questions",
>>>>>>> template
>>>>>>>                                   .getQuestions()) {
>>>>>>>
>>>>>>>
>>>>>>>                           @Override
>>>>>>>                           protected void populateItem(ListItem  
>>>>>>> item) {
>>>>>>>                                   final QuestionAndAnswer  
>>>>>>> qanda =
>>>>>>> (QuestionAndAnswer) item
>>>>>>>                                                   .getModelObject 
>>>>>>> ();
>>>>>>>                                   setModel(new
>>>>>>> CompoundPropertyModel(qanda));
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> I know for a fact that template.getQuestions() produces an  
>>>>>>> ArrayList.
>>>>>>>
>>>>>>> The arraylist works when there is only 1 item in it but when I  
>>>>>>> have
>>>>>>> more
>>>>>>> than 1 item, it fails with the ClassCastException. Is this a  
>>>>>>> wicket
>>>>>>> problem
>>>>>>> or am I doing something wrong?
>>>>>>>
>>>>>>> Regards,
>>>>>>> Pieter
>>>>>>> pieter claassen
>>>>>>> pieter@claassen.co.uk
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> ---------------------------------------------------------------------
>>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>> pieter claassen
>>>>> pieter@claassen.co.uk
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>> pieter claassen
>>> pieter@claassen.co.uk
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>
>
>
>
> -- 
> Become a Wicket expert, learn from the best: http://wicketinaction.com
> Apache Wicket 1.3.4 is released
> Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>

pieter claassen
pieter@claassen.co.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by Martijn Dashorst <ma...@gmail.com>.
The classcastexception happens on retrieving the N-th item from the
list. The class cast tries to cast the model object of the listview to
a List. Apparently the argument to the listview is not a List, but
somethign that returns a QuestionAndAnswer.

Are you looking at the correct ListView (i.e. are there more ListView
s on your page)?

Martijn

On Thu, Oct 23, 2008 at 11:55 AM, Dipu <di...@googlemail.com> wrote:
> pass , sorry i have no clue
>
> On Thu, Oct 23, 2008 at 10:37 AM, pieter claassen <pi...@claassen.co.uk>wrote:
>
>> Ok, I added;
>>
>> public class Debug {
>>        public static void debug(List list) {
>>                for (Object item : list) {
>>                        System.out.println("++DEBUG++: " +
>> item.getClass().toString());
>>                }
>>        }
>>
>>
>> and called debug just before I returned my ArrayList of question:
>>
>>        public ArrayList<QuestionAndAnswer> getQuestions() {
>>                Debug.debug(questions);
>>                return questions;
>>        }
>>
>> This is what I saw in my console. There are two objects in the list and
>> they are both QuestionAndAnswer objects
>>
>>
>> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
>> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
>>
>> Regards,
>> Pieter
>>
>>
>> On Oct 23, 2008, at 11:18 AM, Dipu wrote:
>>
>>  can't you check what exactly is being returned by template.getQuestions()
>>> and if its a list what are the items in it
>>>
>>>
>>>
>>>
>>> On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen <pieter@claassen.co.uk
>>> >wrote:
>>>
>>>  Hi Dipu,
>>>>
>>>> I tried that but when I do the following:
>>>>
>>>>              protected void populateItem(ListItem item) {
>>>>                      System.out.println("+++++++" +
>>>> item.getModelObject().getClass().getName());
>>>>                      final QuestionAndAnswer qanda = (QuestionAndAnswer)
>>>> item.getModelObject();
>>>>
>>>> I find that I now get the ClassCastException in the System.out.println
>>>> line. It is clear as mud that the problem is that I am trying to force
>>>> something into a list which is not a list?
>>>>
>>>> Regards,
>>>> Pieter
>>>>
>>>>
>>>>
>>>> On Oct 23, 2008, at 10:59 AM, Dipu wrote:
>>>>
>>>> looks like template.getQuestions() is returning a list  with items in it
>>>>
>>>>> which is not of the type QuestionAndAnswer
>>>>>
>>>>> try iterating through the list and logging the class name of each item
>>>>> in
>>>>> it
>>>>>
>>>>> Dipu
>>>>>
>>>>>
>>>>>
>>>>> On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen <pieter@claassen.co.uk
>>>>>
>>>>>> wrote:
>>>>>>
>>>>>
>>>>> I am getting a classcast exception in ListView that is stumping me.
>>>>>
>>>>>>
>>>>>> This is the error message (top few lines)
>>>>>>
>>>>>> WicketMessage: Error attaching this container for rendering:
>>>>>> [MarkupContainer [Component id = questioneditform]]
>>>>>>
>>>>>> Root cause:
>>>>>>
>>>>>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>>>>>> at
>>>>>>
>>>>>>
>>>>>> org.apache.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>>>>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>>>>>> at
>>>>>>
>>>>>>
>>>>>> com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm$1.populateItem(TemplateEditPage.java:93)
>>>>>>
>>>>>>
>>>>>> This is the code that generates my ListItems:
>>>>>>
>>>>>>                    ListView questions = new ListView("questions",
>>>>>> template
>>>>>>                                    .getQuestions()) {
>>>>>>
>>>>>>
>>>>>>                            @Override
>>>>>>                            protected void populateItem(ListItem item) {
>>>>>>                                    final QuestionAndAnswer qanda =
>>>>>> (QuestionAndAnswer) item
>>>>>>                                                    .getModelObject();
>>>>>>                                    setModel(new
>>>>>> CompoundPropertyModel(qanda));
>>>>>>
>>>>>>
>>>>>>
>>>>>> I know for a fact that template.getQuestions() produces an ArrayList.
>>>>>>
>>>>>> The arraylist works when there is only 1 item in it but when I have
>>>>>> more
>>>>>> than 1 item, it fails with the ClassCastException. Is this a wicket
>>>>>> problem
>>>>>> or am I doing something wrong?
>>>>>>
>>>>>> Regards,
>>>>>> Pieter
>>>>>> pieter claassen
>>>>>> pieter@claassen.co.uk
>>>>>>
>>>>>>
>>>>>>
>>>>>>
>>>>>> ---------------------------------------------------------------------
>>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>>
>>>>>>
>>>>>>
>>>>>>  pieter claassen
>>>> pieter@claassen.co.uk
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> pieter claassen
>> pieter@claassen.co.uk
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>
>



-- 
Become a Wicket expert, learn from the best: http://wicketinaction.com
Apache Wicket 1.3.4 is released
Get it now: http://www.apache.org/dyn/closer.cgi/wicket/1.3.

---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by Dipu <di...@googlemail.com>.
pass , sorry i have no clue

On Thu, Oct 23, 2008 at 10:37 AM, pieter claassen <pi...@claassen.co.uk>wrote:

> Ok, I added;
>
> public class Debug {
>        public static void debug(List list) {
>                for (Object item : list) {
>                        System.out.println("++DEBUG++: " +
> item.getClass().toString());
>                }
>        }
>
>
> and called debug just before I returned my ArrayList of question:
>
>        public ArrayList<QuestionAndAnswer> getQuestions() {
>                Debug.debug(questions);
>                return questions;
>        }
>
> This is what I saw in my console. There are two objects in the list and
> they are both QuestionAndAnswer objects
>
>
> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
> ++DEBUG++: class com.musmato.model.QuestionAndAnswer
>
> Regards,
> Pieter
>
>
> On Oct 23, 2008, at 11:18 AM, Dipu wrote:
>
>  can't you check what exactly is being returned by template.getQuestions()
>> and if its a list what are the items in it
>>
>>
>>
>>
>> On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen <pieter@claassen.co.uk
>> >wrote:
>>
>>  Hi Dipu,
>>>
>>> I tried that but when I do the following:
>>>
>>>              protected void populateItem(ListItem item) {
>>>                      System.out.println("+++++++" +
>>> item.getModelObject().getClass().getName());
>>>                      final QuestionAndAnswer qanda = (QuestionAndAnswer)
>>> item.getModelObject();
>>>
>>> I find that I now get the ClassCastException in the System.out.println
>>> line. It is clear as mud that the problem is that I am trying to force
>>> something into a list which is not a list?
>>>
>>> Regards,
>>> Pieter
>>>
>>>
>>>
>>> On Oct 23, 2008, at 10:59 AM, Dipu wrote:
>>>
>>> looks like template.getQuestions() is returning a list  with items in it
>>>
>>>> which is not of the type QuestionAndAnswer
>>>>
>>>> try iterating through the list and logging the class name of each item
>>>> in
>>>> it
>>>>
>>>> Dipu
>>>>
>>>>
>>>>
>>>> On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen <pieter@claassen.co.uk
>>>>
>>>>> wrote:
>>>>>
>>>>
>>>> I am getting a classcast exception in ListView that is stumping me.
>>>>
>>>>>
>>>>> This is the error message (top few lines)
>>>>>
>>>>> WicketMessage: Error attaching this container for rendering:
>>>>> [MarkupContainer [Component id = questioneditform]]
>>>>>
>>>>> Root cause:
>>>>>
>>>>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>>>>> at
>>>>>
>>>>>
>>>>> org.apache.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>>>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>>>>> at
>>>>>
>>>>>
>>>>> com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm$1.populateItem(TemplateEditPage.java:93)
>>>>>
>>>>>
>>>>> This is the code that generates my ListItems:
>>>>>
>>>>>                    ListView questions = new ListView("questions",
>>>>> template
>>>>>                                    .getQuestions()) {
>>>>>
>>>>>
>>>>>                            @Override
>>>>>                            protected void populateItem(ListItem item) {
>>>>>                                    final QuestionAndAnswer qanda =
>>>>> (QuestionAndAnswer) item
>>>>>                                                    .getModelObject();
>>>>>                                    setModel(new
>>>>> CompoundPropertyModel(qanda));
>>>>>
>>>>>
>>>>>
>>>>> I know for a fact that template.getQuestions() produces an ArrayList.
>>>>>
>>>>> The arraylist works when there is only 1 item in it but when I have
>>>>> more
>>>>> than 1 item, it fails with the ClassCastException. Is this a wicket
>>>>> problem
>>>>> or am I doing something wrong?
>>>>>
>>>>> Regards,
>>>>> Pieter
>>>>> pieter claassen
>>>>> pieter@claassen.co.uk
>>>>>
>>>>>
>>>>>
>>>>>
>>>>> ---------------------------------------------------------------------
>>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>>
>>>>>
>>>>>
>>>>>  pieter claassen
>>> pieter@claassen.co.uk
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
> pieter claassen
> pieter@claassen.co.uk
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: ListView broken?

Posted by pieter claassen <pi...@claassen.co.uk>.
Ok, I added;

public class Debug {
	public static void debug(List list) {
		for (Object item : list) {
			System.out.println("++DEBUG++: " + item.getClass().toString());
		}
	}


and called debug just before I returned my ArrayList of question:

	public ArrayList<QuestionAndAnswer> getQuestions() {
		Debug.debug(questions);
		return questions;
	}

This is what I saw in my console. There are two objects in the list  
and they are both QuestionAndAnswer objects


++DEBUG++: class com.musmato.model.QuestionAndAnswer
++DEBUG++: class com.musmato.model.QuestionAndAnswer

Regards,
Pieter

On Oct 23, 2008, at 11:18 AM, Dipu wrote:

> can't you check what exactly is being returned by  
> template.getQuestions()
> and if its a list what are the items in it
>
>
>
>
> On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen <pieter@claassen.co.uk 
> >wrote:
>
>> Hi Dipu,
>>
>> I tried that but when I do the following:
>>
>>               protected void populateItem(ListItem item) {
>>                       System.out.println("+++++++" +
>> item.getModelObject().getClass().getName());
>>                       final QuestionAndAnswer qanda =  
>> (QuestionAndAnswer)
>> item.getModelObject();
>>
>> I find that I now get the ClassCastException in the  
>> System.out.println
>> line. It is clear as mud that the problem is that I am trying to  
>> force
>> something into a list which is not a list?
>>
>> Regards,
>> Pieter
>>
>>
>>
>> On Oct 23, 2008, at 10:59 AM, Dipu wrote:
>>
>> looks like template.getQuestions() is returning a list  with items  
>> in it
>>> which is not of the type QuestionAndAnswer
>>>
>>> try iterating through the list and logging the class name of each  
>>> item in
>>> it
>>>
>>> Dipu
>>>
>>>
>>>
>>> On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen <pieter@claassen.co.uk
>>>> wrote:
>>>
>>> I am getting a classcast exception in ListView that is stumping me.
>>>>
>>>> This is the error message (top few lines)
>>>>
>>>> WicketMessage: Error attaching this container for rendering:
>>>> [MarkupContainer [Component id = questioneditform]]
>>>>
>>>> Root cause:
>>>>
>>>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>>>> at
>>>>
>>>> org 
>>>> .apache 
>>>> .wicket 
>>>> .markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>>>> at
>>>>
>>>> com.musmato.wicket.pages.templates.TemplateEditPage 
>>>> $QuestionEditForm$1.populateItem(TemplateEditPage.java:93)
>>>>
>>>>
>>>> This is the code that generates my ListItems:
>>>>
>>>>                     ListView questions = new ListView("questions",
>>>> template
>>>>                                     .getQuestions()) {
>>>>
>>>>
>>>>                             @Override
>>>>                             protected void populateItem(ListItem  
>>>> item) {
>>>>                                     final QuestionAndAnswer qanda =
>>>> (QuestionAndAnswer) item
>>>>                                                     .getModelObject 
>>>> ();
>>>>                                     setModel(new
>>>> CompoundPropertyModel(qanda));
>>>>
>>>>
>>>>
>>>> I know for a fact that template.getQuestions() produces an  
>>>> ArrayList.
>>>>
>>>> The arraylist works when there is only 1 item in it but when I  
>>>> have more
>>>> than 1 item, it fails with the ClassCastException. Is this a wicket
>>>> problem
>>>> or am I doing something wrong?
>>>>
>>>> Regards,
>>>> Pieter
>>>> pieter claassen
>>>> pieter@claassen.co.uk
>>>>
>>>>
>>>>
>>>>
>>>> ---------------------------------------------------------------------
>>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>>
>>>>
>>>>
>> pieter claassen
>> pieter@claassen.co.uk
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>

pieter claassen
pieter@claassen.co.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by Dipu <di...@googlemail.com>.
can't you check what exactly is being returned by template.getQuestions()
 and if its a list what are the items in it




On Thu, Oct 23, 2008 at 10:10 AM, pieter claassen <pi...@claassen.co.uk>wrote:

> Hi Dipu,
>
> I tried that but when I do the following:
>
>                protected void populateItem(ListItem item) {
>                        System.out.println("+++++++" +
> item.getModelObject().getClass().getName());
>                        final QuestionAndAnswer qanda = (QuestionAndAnswer)
> item.getModelObject();
>
> I find that I now get the ClassCastException in the System.out.println
> line. It is clear as mud that the problem is that I am trying to force
> something into a list which is not a list?
>
> Regards,
> Pieter
>
>
>
> On Oct 23, 2008, at 10:59 AM, Dipu wrote:
>
>  looks like template.getQuestions() is returning a list  with items in it
>> which is not of the type QuestionAndAnswer
>>
>> try iterating through the list and logging the class name of each item in
>> it
>>
>> Dipu
>>
>>
>>
>> On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen <pieter@claassen.co.uk
>> >wrote:
>>
>>  I am getting a classcast exception in ListView that is stumping me.
>>>
>>> This is the error message (top few lines)
>>>
>>> WicketMessage: Error attaching this container for rendering:
>>> [MarkupContainer [Component id = questioneditform]]
>>>
>>> Root cause:
>>>
>>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>>> at
>>>
>>> org.apache.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
>>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>>> at
>>>
>>> com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm$1.populateItem(TemplateEditPage.java:93)
>>>
>>>
>>> This is the code that generates my ListItems:
>>>
>>>                      ListView questions = new ListView("questions",
>>> template
>>>                                      .getQuestions()) {
>>>
>>>
>>>                              @Override
>>>                              protected void populateItem(ListItem item) {
>>>                                      final QuestionAndAnswer qanda =
>>> (QuestionAndAnswer) item
>>>                                                      .getModelObject();
>>>                                      setModel(new
>>> CompoundPropertyModel(qanda));
>>>
>>>
>>>
>>> I know for a fact that template.getQuestions() produces an ArrayList.
>>>
>>> The arraylist works when there is only 1 item in it but when I have more
>>> than 1 item, it fails with the ClassCastException. Is this a wicket
>>> problem
>>> or am I doing something wrong?
>>>
>>> Regards,
>>> Pieter
>>> pieter claassen
>>> pieter@claassen.co.uk
>>>
>>>
>>>
>>>
>>> ---------------------------------------------------------------------
>>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>>> For additional commands, e-mail: users-help@wicket.apache.org
>>>
>>>
>>>
> pieter claassen
> pieter@claassen.co.uk
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>

Re: ListView broken?

Posted by pieter claassen <pi...@claassen.co.uk>.
Hi Dipu,

I tried that but when I do the following:

		protected void populateItem(ListItem item) {
			System.out.println("+++++++" +  
item.getModelObject().getClass().getName());
			final QuestionAndAnswer qanda = (QuestionAndAnswer)  
item.getModelObject();

I find that I now get the ClassCastException in the System.out.println  
line. It is clear as mud that the problem is that I am trying to force  
something into a list which is not a list?

Regards,
Pieter


On Oct 23, 2008, at 10:59 AM, Dipu wrote:

> looks like template.getQuestions() is returning a list  with items  
> in it
> which is not of the type QuestionAndAnswer
>
> try iterating through the list and logging the class name of each  
> item in it
>
> Dipu
>
>
>
> On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen <pieter@claassen.co.uk 
> >wrote:
>
>> I am getting a classcast exception in ListView that is stumping me.
>>
>> This is the error message (top few lines)
>>
>> WicketMessage: Error attaching this container for rendering:
>> [MarkupContainer [Component id = questioneditform]]
>>
>> Root cause:
>>
>> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
>> at
>> org 
>> .apache 
>> .wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java: 
>> 55)
>> at org.apache.wicket.Component.getModelObject(Component.java:1558)
>> at
>> com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm 
>> $1.populateItem(TemplateEditPage.java:93)
>>
>>
>> This is the code that generates my ListItems:
>>
>>                       ListView questions = new ListView("questions",
>> template
>>                                       .getQuestions()) {
>>
>>
>>                               @Override
>>                               protected void populateItem(ListItem  
>> item) {
>>                                       final QuestionAndAnswer qanda =
>> (QuestionAndAnswer) item
>>                                                       .getModelObject 
>> ();
>>                                       setModel(new
>> CompoundPropertyModel(qanda));
>>
>>
>>
>> I know for a fact that template.getQuestions() produces an ArrayList.
>>
>> The arraylist works when there is only 1 item in it but when I have  
>> more
>> than 1 item, it fails with the ClassCastException. Is this a wicket  
>> problem
>> or am I doing something wrong?
>>
>> Regards,
>> Pieter
>> pieter claassen
>> pieter@claassen.co.uk
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
>> For additional commands, e-mail: users-help@wicket.apache.org
>>
>>

pieter claassen
pieter@claassen.co.uk




---------------------------------------------------------------------
To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
For additional commands, e-mail: users-help@wicket.apache.org


Re: ListView broken?

Posted by Dipu <di...@googlemail.com>.
 looks like template.getQuestions() is returning a list  with items in it
which is not of the type QuestionAndAnswer

try iterating through the list and logging the class name of each item in it

Dipu



On Thu, Oct 23, 2008 at 9:46 AM, pieter claassen <pi...@claassen.co.uk>wrote:

> I am getting a classcast exception in ListView that is stumping me.
>
> This is the error message (top few lines)
>
> WicketMessage: Error attaching this container for rendering:
> [MarkupContainer [Component id = questioneditform]]
>
> Root cause:
>
> java.lang.ClassCastException: com.musmato.model.QuestionAndAnswer
> at
> org.apache.wicket.markup.html.list.ListItemModel.getObject(ListItemModel.java:55)
> at org.apache.wicket.Component.getModelObject(Component.java:1558)
> at
> com.musmato.wicket.pages.templates.TemplateEditPage$QuestionEditForm$1.populateItem(TemplateEditPage.java:93)
>
>
> This is the code that generates my ListItems:
>
>                        ListView questions = new ListView("questions",
> template
>                                        .getQuestions()) {
>
>
>                                @Override
>                                protected void populateItem(ListItem item) {
>                                        final QuestionAndAnswer qanda =
> (QuestionAndAnswer) item
>                                                        .getModelObject();
>                                        setModel(new
> CompoundPropertyModel(qanda));
>
>
>
> I know for a fact that template.getQuestions() produces an ArrayList.
>
> The arraylist works when there is only 1 item in it but when I have more
> than 1 item, it fails with the ClassCastException. Is this a wicket problem
> or am I doing something wrong?
>
> Regards,
> Pieter
> pieter claassen
> pieter@claassen.co.uk
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@wicket.apache.org
> For additional commands, e-mail: users-help@wicket.apache.org
>
>