Your exception most likely stems from this issue:
The list view constructor that throws the exception looks like this:
public ListView(final String id, final List list) { this(id, new Model((Serializable)list)); }
Since empList (java.util.RandomAccessSubList) does not implement Serializable you get the exception.
A quick fix (but potentially expensive) would be to change your code to
//list 1 add(new ListView("employees", new ArrayList(empList)) { ...
Hope that helps, - Jens
PS. From my experience Wicket (in my case version 1.1) works very well with JDK 5.0 and generics.
On Feb 10, 2006, at 1:50 PM, VGJ wrote: I'm trying to convert a single page of an existing application using Wicket...just to see how it works. The entire app was built on JDK 5.0. It uses hibernate and retrieves lists of data with generics...and it may be what is causing my problems since I've spotted a comment here and there that Wicket doesn't support Java 5?
It's a simple test...I've got my 3 files:
CheckIn.html CheckIn.java CheckInApp.java
Here's where I'm pulling a List from a proxy class in the middle-layer of the application and trying to display it:
public class CheckIn extends WebPage { public CheckIn() { //get default directory Directory ed = DirectoryProxy.getDefaultWithEmployees(); //get employees from directory List<Employee> employees = ed.getEmployees(); //list 1 add(new ListView("employees", empList) { // This method is called for each 'entry' in the list. protected void populateItem(ListItem item) { //get employee object Employee employee = (Employee)item.getModelObject(); //other employee labels item.add(new Label("firstName", employee.getFirstName())); item.add(new Label("lastName", employee.getLastName())); } }); } }
Here's part of the exception I'm getting:
... 14:25:09,613 ERROR RequestCycle:785 - Unexpected runtime exception [page = null] java.lang.ClassCastException: java.util.RandomAccessSubList at wicket.markup.html.list.ListView.<init>(ListView.java:135) at com.portlets.ui.CheckIn$1.<init>(CheckIn.java:58) at com.portlets.ui.CheckIn.<init>(CheckIn.java:55) Any ideas? Thanks!
|
- Re: [Wicket-user] Exception when displaying List from hiberna... Jens Schmidt
-