Greetings, Wicket Wizards,
I am updating a sample Wicket program from 1.3.6 to 1.4.3 and running into
a few generics-related issues. I am hoping you folks can quickly set me
straight. My code appears to run successfully and passes its JUnit tests,
despite the warnings I would like to remove. The purpose of the code is
to demonstrate simple use of Forms, Lists, and Tables and associated
testing of these constructs using WicketTester.
First off, although you hopefully will not need to, you can download the
sample code from here:
http://ics-wicket-examples.googlecode.com/files/wicket-example02-1.0.1106.zip
Unzip, cd into the directory, and type ant, It should download Ivy, then
download Wicket, Jetty, SLF4J, and JUnit, and finally compile the system,
generating the following generic-related warnings. Let me now show you
what they are:
Problem 1: please take a look at line 39 of TablePage.java:
http://code.google.com/p/ics-wicket-examples/source/browse/trunk/example02/src/edu/hawaii/wicket/TablePage.java
The problematic line is:
new ListDataProvider(contacts)
and obviously requires a generic argument, but neither of the following
work:
new ListDataProviderContact(contacts) // my preferred guess
new ListDataProviderListContact(contacts)
The compiler warning is:
[javac] TablePage.java:39: warning: [unchecked] unchecked call to
ListDataProvider(java.util.ListT) as a member of the raw type
org.apache.wicket.markup.repeater.data.ListDataProvider
[javac] new ListDataProvider(contacts)) {
[javac] ^
[javac] TablePage.java:39: warning: [unchecked] unchecked conversion
[javac] found :
org.apache.wicket.markup.repeater.data.ListDataProvider
[javac] required:
org.apache.wicket.markup.repeater.data.IDataProviderjava.util.Listedu.hawaii.wicket.TablePage.Contact
[javac] new ListDataProvider(contacts)) {
[javac] ^
Problem 2: on line 49 of the same file, TablePage.java:
http://code.google.com/p/ics-wicket-examples/source/browse/trunk/example02/src/edu/hawaii/wicket/TablePage.java
The line is:
Contact contact = (Contact) item.getModelObject();
Since the preceding line provides a parameterized declaration of item
(ItemListContact item), I don't understand why I need to cast here.
But the code does not compile if I don't. Then, I get the following
warning:
[javac] TablePage.java:49: warning: [unchecked] unchecked cast
[javac] found : java.util.Listedu.hawaii.wicket.TablePage.Contact
[javac] required: edu.hawaii.wicket.TablePage.Contact
[javac] Contact contact = (Contact) item.getModelObject();
[javac]
^
Problem 3: WicketTester and generics.
I clearly don't understand how to test with WicketTester. Take a look at
lines 37-39 of TestListPage:
http://code.google.com/p/ics-wicket-examples/source/browse/trunk/example02/src/edu/hawaii/wicket/TestListPage.java
This is a mess, and generates the following warning:
[javac] TestListPage.java:39: warning: [unchecked] unchecked cast
[javac] found : capture#294 of ?
[javac] required: java.util.Listjava.lang.String
[javac] ListString metaVars = (ListString)
varsModel.getObject();
I have a feeling that my whole approach to getting values out of the table
for testing is wrong, but I don't know what the correct approach is.
If any of you can give me a hand, the first Mai Tai is on me the next time
you are in Hawaii.
Thanks!
Philip
-
To unsubscribe, e-mail: users-unsubscr...@wicket.apache.org
For additional commands, e-mail: users-h...@wicket.apache.org