Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wicket pageparameter

Tags:

java

wicket

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.

like image 336
jshree Avatar asked Jan 18 '23 15:01

jshree


1 Answers

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);
}
like image 79
Martijn Dashorst Avatar answered Jan 28 '23 18:01

Martijn Dashorst