Wicket page calibration

I am trying to add and extract with the key as String and the value as List<object> in Wicket PageParameters .

While I am retrieving the value using the key, I got a 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.

+4
source share
2 answers

You cannot store objects in PageParameters , because PageParameters is an abstraction of HTTP request parameters, and the protocol only supports String values. You should get a list of strings from the parameters and process it in Example objects.

 List<StringValue> values = parameters.getValues("examples"); for(StringValue value : values) { Example example = new Example(value.toString()); examples.add(example); } 
+9
source
 // Populate PageParameters final String dynamicValue = textFieldID.getModelObject(); PageParameters pageParameters = new PageParameters(); pageParameters.add("username", usernameValue); pageParameters.add("username", "fixedValue"); // Retrieving PageParameters String newValue = parameters.getValues("username").get(1).toString(); // here newValue will contain "fixedValue" (the second element) 
0
source

All Articles