javawicketwicket-1.5wicket-6

How to replace PageParameters constructor (String) in Wicket 6?


I'm doing a migration from wicket 1.4 -> 1.5 -> 6. When I was upgrading to 6 I encounter the following compile error:

The constructor PageParameters(String) is undefined

When I looked into the sources of Wicket 1.4, I noticed that this constructor is deprecated but still there (probably that's why I didn't notice it in the migration to Wicket 1.5).

Example of using it in my code:

cancelButton = new AjaxButton("cancelButton", new I18nModel("Common.Cancel"), groupForm) {
    private static final long serialVersionUID = -6267601642356425767L;
    public void onSubmit(AjaxRequestTarget target, Form<?> form) {
        String paramsString = "mode=" + DISPLAY.toString() +
            (groupId == null ? "" : ",id=" + groupId);
        PageParameters params = new PageParameters(paramsString);
        UiUtils.redirect(GroupPage.class, params);
    }
};

What should I use instead? In Wicket 6 I only see two constructors:

PageParameters() 
PageParameters(final PageParameters copy)

Solution

  • You have to use the add method:

    PageParameters pp = new PageParameters();
    pp.add("mode",value);
    

    After that redirect as usual.