in wicket you use anonymous classes often. an alternative would be to make that anonymous class into a private static class, or if it is reusable make it a public static class.
unlike many other web frameworks out there wicket requires you to use the full facilities of OO in java, so if you want to use wicket you might as well learn those.
the loadable model is a good pracice anyways, because it does not store your list in session which it would've been given your original code. storing that list in session is a waste of space.
i think the problem is that the list that is returned is not serializable and so it cannot be stored in session. that is a hibernate specific detail. what you can do is copy that list into an array list, but that is not a good solution imho, the loadable detachable model is.
-Igor
On 2/10/06, VGJ <[EMAIL PROTECTED]> wrote:
Phew, that could get ugly. Could I fix this by making my domain classes serializable? Bare with me, I'm still pretty new to Java as well as Wicket :)On 2/10/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:and if it is, looks like whatever list is returned is not serializable so wicket cannot wrap it with a model for you.
here is how to fix that and make the model detacahable, which is good anyways:
IModel listModel=new LoadableDetachableModel() {
Object load() {
//get default directory
Directory ed = DirectoryProxy.getDefaultWithEmployees();
//get employees from directory
return ed.getEmployees();
}
}
add(new ListView("emoloyees", listModel)...
-Igor
On 2/10/06, Igor Vaynberg <[EMAIL PROTECTED]> wrote:is that the root cause of the exception?
-IgorOn 2/10/06, VGJ < [EMAIL PROTECTED]> 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!
