I'm using the Wicket Quickstart (latest as of yesterday) as a base and I'm
trying to do a very simple loop through data I've grabbed from a database
(Hibernate, MySQL, no Spring). I'm following the various DataView, ListView,
etc examples to the letter and every time I restart the server and reload
the page, I get:

     /Last cause: [Ljava.lang.Object; cannot be cast to com.cfm.Contact/

This is referring to this line:

     /final Contact thisContact = (Contact)item.getModelObject();/

I have WicketApplication.java, HomePage.html, HomePage.java,
HibernateUtil.java, and Contact.java all under /src/main/java/com.cfm

Contact is declared as 

     /public class Contact implements java.io.Serializable {/

and just has some basic string fields with getters and setters.

The relevant part of HomePage.java is:

/        List<Contact> contactList = session.createSQLQuery("select * from
wicket.contacts").list();
        final DataView dv = new DataView("AllContacts", new
ListDataProvider(contactList)){
            public void populateItem(final Item item){
                final Contact thisContact = (Contact)item.getModelObject();
                item.add(new Label("Id", thisContact.getId()));
            }
        };

        add(dv);
/
and it dies at the final Contact thisContact.... line. I have no idea what's
going on. All of the examples I've found through Google all show it
happening in this exact way. I've tried about three different methods of
looping through the data (it's really hard to find how to loop through
database data in wicket...) and it all comes to the same result (even if I
leave the /(Contact)/ part off). 

--
View this message in context: 
http://apache-wicket.1842946.n4.nabble.com/item-getModelObject-result-cannot-be-cast-to-tp4666598.html
Sent from the Users forum mailing list archive at Nabble.com.

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to