WicketUtil { public PageParameters getRetainedRequestParameters(final PageParameters pageParameters, final Set<String> nameFilter) { final PageParameters rez = getFilteredRequestParameters(pageParameters); for (String keyName : rez.getNamedKeys()) { if (!nameFilter.contains(keyName)) { rez.remove(keyName); } } return rez; } WicketUtil();  WicketUtil(final CommandConfig commandConfig); HttpServletRequest getHttpServletRequest(); long getCategoryId(final PageParameters pageParameters); Map<String, String> pageParametersAsMap(final PageParameters pageParameters); Map<String, List<String>> pageParametersAsMultiMap(final PageParameters pageParameters); PageParameters getFilteredRequestParameters(final PageParameters parameters); PageParameters getFilteredRequestParameters(final PageParameters pageParameters,
                                                              final Collection<String> nameFilter); PageParameters getFilteredRequestParameters(final PageParameters parameters,
                                                              final String key,
                                                              final String value); PageParameters getRetainedRequestParameters(final PageParameters pageParameters,
                                                              final Set<String> nameFilter); int getSelectedItemsPerPage(final PageParameters pageParameters, final List<String> itemsPerPageValues); boolean isSelectedProductSortOnPage(final PageParameters pageParameters, final String sortOrder, final String sortField); boolean isSelectedPageActive(final PageParameters pageParameters, final String pageParameterName, final int page); String constructLatinStringValue(final String ... values); static StringResourceModel createStringResourceModel(final Component component,
                                                                final String resourceKey); static StringResourceModel createStringResourceModel(final Component component,
                                                                final String resourceKey,
                                                                final Map<String, Object> parameters);  }
@Test public void testGetRetainedRequestParameters() throws Exception { final CommandConfig commandConfig = context.mock(CommandConfig.class, "config"); context.checking(new Expectations() {{ allowing(commandConfig).isCommandKey("asd"); will(returnValue(false)); allowing(commandConfig).isCommandKey("retained1"); will(returnValue(false)); allowing(commandConfig).isCommandKey("retained2"); will(returnValue(false)); allowing(commandConfig).isCommandKey("cmd1"); will(returnValue(true)); }}); assertNotNull(new WicketUtil(commandConfig).getFilteredRequestParameters(null)); PageParameters parametersToFilter = new PageParameters() .add("cmd1", "val1") .add("asd", "dsa") .add("retained1", "ppp") .add("retained2", "zzz"); assertEquals(4, parametersToFilter.getNamedKeys().size()); assertEquals(3, new WicketUtil(commandConfig).getFilteredRequestParameters(parametersToFilter).getNamedKeys().size()); PageParameters filtered = new WicketUtil(commandConfig).getRetainedRequestParameters(parametersToFilter, new HashSet<>(Arrays.asList("retained1", "retained2"))); assertNotNull(filtered); assertEquals(2, filtered.getNamedKeys().size()); assertEquals("ppp", filtered.get("retained1").toString()); assertEquals("zzz", filtered.get("retained2").toString()); }