How Wicket models works with generic?
wicket
Solution
The source code of Wicket is very well documented and self-explanatory. `Label` is using `getDefaultModelObjectAsString()` from `Component` that look like this:
// Get converter
final Class<?> objectClass = modelObject.getClass();
final IConverter converter = getConverter(objectClass);
// Model string from property
final String modelString = converter.convertToString(modelObject, getLocale());
So here you can see that Wicket uses a `IConverter` to convert the model object to a `String`. Looking at the implementation of the default `ConverterLocator` you'll see that if you haven't registered any `IConverter` for this type of object, Wicket will use the `DefaultConverter` that uses `org.apache.wicket.util.lang.Objects` static methods to convert the object to a `String`.
The `TextField` also uses a `IConverter` to convert the object to a `String` and from the `String` to an object again. The difference is that Wicket is able to always convert an unknown class to a `String` using the `toString` method, but not the other way. So if you want to use a `IModel<Person>` with a `TextField` you'll need to register your own `IConverter<Person>` implementation.
Problem
I'd like to know something about wicket supporting models with generic. I understood the models, prop model, and prop compound model. But what about the Model class? What happen if I do this: ``` Label<Person> label = new Label<Person> ( "someID", new Model<Person>() ) ``` What will be show in that label? toString output? Lets say I have the same in a TextField. What value it will set up in that object?