I am trying to add and fetch with a key as String
and value as List<object>
in Wicket PageParameters
.
While am fetching the value with key, I got classcastException:String cant be converted into list.
I am using something like this:
List<Example> list = (List<Example>)params.get("ExampleList");
Any help is appreciated.
You can't store objects in PageParameters
because PageParameters
are an abstraction of HTTP request parameters and the protocol only supports String
values. You have to get the list of Strings from the parameters and process it into Example
objects.
List<StringValue> values = parameters.getValues("examples");
for(StringValue value : values) {
Example example = new Example(value.toString());
examples.add(example);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With