I need to get all children Text Field's of a container, wicket provide a method called visitChildren
then I do something like:
(FormComponent<?>[]) visitChildren(TextField.class).toList().toArray();
this example doesn't work, the exception I get is:
java.lang.ClassCastException: [Ljava.lang.Object; cannot be cast to [Lorg.apache.wicket.markup.html.form.FormComponent;
but if I do something like:
List<Component> list = visitChildren(TextField.class).toList();
FormComponent<?>[] array = new FormComponent[list.size()];
for (int x = 0; x < list.size(); x++) {
array[x] = (FormComponent<?>) list.get(x);
}
it work, why happen that? as far I can see both methods should work