Java Code Examples for org.apache.wicket.request.mapper.parameter.PageParameters#getValues()

The following examples show how to use org.apache.wicket.request.mapper.parameter.PageParameters#getValues() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WicketUtil.java    From yes-cart with Apache License 2.0 6 votes vote down vote up
/**
 * Transform wicket 1.5 page parameter to more traditional map.  Expensive operation.
 *
 * @param pageParameters given parameters to transform.
 * @return parameters transformed to map
 */
public Map<String, List<String>> pageParametersAsMultiMap(final PageParameters pageParameters) {
    final Map<String, List<String>> map = new LinkedHashMap<>();
    if (pageParameters != null) {
        for (String key : pageParameters.getNamedKeys()) {
            if (!commandConfig.isInternalCommandKey(key)) {
                final List<String> vals = new ArrayList<>();
                for (final StringValue value : pageParameters.getValues(key)) {
                    vals.add(value.toString());
                }
                map.put(key, vals);
            }
        }
    }
    return map;
}
 
Example 2
Source File: WicketUtil.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
/**
 * Get the filtered request parameters that does not
 * not contain given key and value.
 *
 * @param parameters original request parameters
 * @param key        key part to remove
 * @param value      value part to remove
 * @return new filtered {@link PageParameters}
 */
public PageParameters getFilteredRequestParameters(final PageParameters parameters,
                                                          final String key,
                                                          final String value) {
    final PageParameters rez = getFilteredRequestParameters(parameters);
    final List<StringValue> vals = rez.getValues(key);
    if (vals.size() > 0) {
        rez.remove(key, value);
    } else {
        rez.remove(key);
    }
    return rez;
}
 
Example 3
Source File: WicketUtilTest.java    From yes-cart with Apache License 2.0 5 votes vote down vote up
@Test
public void testGetFilteredRequestParametersForSearch() {
    PageParameters parametersToFilter = new PageParameters()
        .add("query", "val1")
        .add("query", "val2")
        .add("query", "val3");
    assertEquals(1, parametersToFilter.getNamedKeys().size());
    assertEquals(3, parametersToFilter.getValues("query").size());
    parametersToFilter.remove("query", "val2");
    assertEquals(2, parametersToFilter.getValues("query").size());
    for (StringValue val : parametersToFilter.getValues("query")) {
        assertFalse("val2".equals(val.toString()));
    }
}