Question

I'm trying to migrate an application using OpenId4Java to Wicket 1.5. Using the migration notes I've gotten everything to work.

Except one thing: Before Wicket 1.5 PageParameters was a map which was perfect since OpenId4Java's ParameterList took an map as an argument.

However in Wicket 1.5, I can't figure out how to get an map out of the PageParameters. Going trough the PageParameters NamedPairs and making a map of of that is not to hard. But creating an class (the creation of a ParameterLists are in several places) does not feel as a good solution.

What is the simpler solution to this?

ParameterList response = new ParameterList( pageParameters);

-- EDIT -- Code that solved the problem for me.

public static ParameterList toParameterList(PageParameters p){
    HashMap<String, String> h = new HashMap<String, String>();
    for(NamedPair pair: p.getAllNamed()){
        h.put(pair.getKey(), pair.getValue());
    }
    return new ParameterList(h);
}

public static ParameterList toParameterList(IRequestParameters rP) {
    HashMap<String, String> h = new HashMap<String, String>();
    for(String name : rP.getParameterNames()){
        h.put(name, rP.getParameterValue(name).toString());
    }
    return new ParameterList(h);
}
Was it helpful?

Solution

See http://apache-wicket.1842946.n4.nabble.com/Upgrade-1-5-PageParameters-toRequestParameters-tp3871781p3873818.html for the same issue.

The closest is org.apache.wicket.request.mapper.parameter.PageParameters.getAllNamed() You can write a helper function to convert it to Map

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top