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
<[EMAIL PROTECTED]>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 <[EMAIL PROTECTED]> 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
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
pieter claassen
[EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]