Example usage for org.apache.wicket.request.mapper.parameter PageParameters getAllNamed

List of usage examples for org.apache.wicket.request.mapper.parameter PageParameters getAllNamed

Introduction

In this page you can find the example usage for org.apache.wicket.request.mapper.parameter PageParameters getAllNamed.

Prototype

@Override
    public List<NamedPair> getAllNamed() 

Source Link

Usage

From source file:at.molindo.wicketutils.utils.WicketUtils.java

License:Apache License

public static LinkedHashMap<String, Object> toMap(PageParameters params) {
    int indexed = params.getIndexedCount();
    List<NamedPair> named = params.getAllNamed();

    LinkedHashMap<String, Object> map = new LinkedHashMap<String, Object>((indexed + named.size()) * 2);

    for (int i = 0; i < indexed; i++) {
        String index = Integer.toString(i);
        Object value = params.get(i).to(Object.class);

        Object prev = map.put(index, value);
        if (prev != null) {
            map.put(index, merge(prev, value));
        }/* w w w  . j ava2  s . com*/
    }

    for (NamedPair p : named) {
        map.put(p.getKey(), p.getValue());
    }

    return map;
}

From source file:com.axway.ats.testexplorer.pages.testcase.statistics.charts.ChartsPanel.java

License:Apache License

private void parsePageParameters(PageParameters parameters) {

    for (NamedPair attr : parameters.getAllNamed()) {
        if ("timeOffSet".equals(attr.getKey())) {
            if (attr.getValue() != null && !attr.getValue().isEmpty()) {
                this.timeOffSet = Float.parseFloat(attr.getValue().toString());
            }/* www  . j a va  2s.  c o  m*/
        } else if (!"dbname".equals(attr.getKey()) && !"currentTestcase".equals(attr.getKey())
                && !"tab".equals(attr.getKey())) {
            List<DbStatisticDescription> sysUserStats = new ArrayList<DbStatisticDescription>();
            List<DbStatisticDescription> actionStats = new ArrayList<DbStatisticDescription>();
            for (String stat : attr.getValue().toString().split(",")) {
                DbStatisticDescription statData = DbStatisticDescription.fromURL(stat);
                testcaseIds.add(statData.testcaseId);
                if (statData.statisticId != -1) {
                    sysUserStats.add(statData);
                } else {
                    actionNames.add(statData.name);
                    actionStats.add(statData);
                }
            }
            if (!sysUserStats.isEmpty()) {
                userAndSystemStatistics.put(attr.getKey(), sysUserStats);
            }
            if (!actionStats.isEmpty()) {
                actionStatistics.put(attr.getKey(), actionStats);
            }
        }
    }
}

From source file:com.evolveum.midpoint.web.util.DefaultPageParametersEncoder.java

License:Apache License

/**
 * Encodes URL like this: /mountpoint/paramName1/paramValue1/paramName2/paramValue2
 *//*  w  w w .j  a  v  a2 s  . c o  m*/
@Override
public Url encodePageParameters(PageParameters pageParameters) {
    Url url = new Url();

    for (PageParameters.NamedPair pair : pageParameters.getAllNamed()) {
        url.getSegments().add(pair.getKey());
        url.getSegments().add(pair.getValue());
    }

    return url;
}

From source file:com.evolveum.midpoint.web.util.MidPointPageParametersEncoder.java

License:Apache License

/**
 * Encodes a URL in the form://from www .ja  v  a  2 s.  c  o m
 * <p/>
 * /mountpoint/paramName1/paramValue1/paramName2/paramValue2
 * <p/>
 * (i.e. a URL using the pre wicket 1.5 Hybrid URL strategy)
 */
@Override
public Url encodePageParameters(PageParameters pageParameters) {
    Url url = new Url();

    for (PageParameters.NamedPair pair : pageParameters.getAllNamed()) {
        url.getSegments().add(pair.getKey());
        url.getSegments().add(pair.getValue());
    }

    if (LOGGER.isTraceEnabled() && !pageParameters.isEmpty()) {
        LOGGER.trace("Parameters '{}' encoded to: '{}'", pageParameters, url.toString());
    }

    return url;
}

From source file:com.evolveum.midpoint.web.util.OnePageParameterEncoder.java

License:Apache License

/**
 * Encodes URL like this: /mountPoint/paramValue1
 *///from ww  w.ja  v a  2  s . co  m
@Override
public Url encodePageParameters(PageParameters pageParameters) {
    Url url = new Url();

    for (PageParameters.NamedPair pair : pageParameters.getAllNamed()) {
        if (!PARAMETER.equals(pair.getKey())) {
            continue;
        }

        url.getSegments().add(pair.getValue());
        break;
    }

    return url;
}

From source file:com.modusoperandi.dragonfly.widgets.map.MapWidgetBMPage.java

License:Open Source License

private String addDataToMap(final PageParameters parameters) {

    Map<String, String> configuration = new HashMap<>();

    parameters.getAllNamed().stream().forEach((parameter) -> {
        configuration.put(parameter.getKey(), getWithDefault(parameter));
    });// ww  w.  j  a va 2  s  .co m

    return addDataToMap(configuration);
}

From source file:de.alpharogroup.wicket.base.util.parameter.PageParametersExtensions.java

License:Apache License

/**
 * Copies all given source {@link org.apache.wicket.request.mapper.parameter.PageParameters} to
 * the given destination {@link org.apache.wicket.request.mapper.parameter.PageParameters}.
 *
 * @param source/*from   ww w  . j  av  a  2  s  .c  o m*/
 *            The source {@link org.apache.wicket.request.mapper.parameter.PageParameters}.
 * @param destination
 *            The destination {@link org.apache.wicket.request.mapper.parameter.PageParameters}.
 * @return The destination {@link org.apache.wicket.request.mapper.parameter.PageParameters}
 *         with the copied keys and values.
 */
public static PageParameters copy(final PageParameters source, final PageParameters destination) {
    Args.notNull(source, "source");
    Args.notNull(destination, "destination");
    final List<INamedParameters.NamedPair> namedPairs = source.getAllNamed();
    for (final INamedParameters.NamedPair namedPair : namedPairs) {
        destination.add(namedPair.getKey(), namedPair.getValue());
    }
    return destination;
}

From source file:de.alpharogroup.wicket.base.util.parameter.PageParametersExtensions.java

License:Apache License

/**
 * Copies all given source {@link org.apache.wicket.request.mapper.parameter.PageParameters} to
 * the given session {@link org.apache.wicket.Session}.
 * /*w w  w  .j  a v  a 2s.  c o m*/
 * @param source
 *            The source {@link org.apache.wicket.request.mapper.parameter.PageParameters}.
 * @param session
 *            The session where the
 *            {@link org.apache.wicket.request.mapper.parameter.PageParameters} are stored.
 */
public static void copyToWicketSession(final PageParameters source, final Session session) {
    final List<INamedParameters.NamedPair> namedPairs = source.getAllNamed();
    for (final INamedParameters.NamedPair namedPair : namedPairs) {
        session.setAttribute(namedPair.getKey(), namedPair.getValue());
    }
}

From source file:fiftyfive.wicket.util.ParameterSpec.java

License:Apache License

/**
 * Creates a BookmarkablePageLink to the page managed by this ParameterSpec.
 * The link will have parameters dictated by the ParameterSpec constructor
 * or <code>registerParameter()</code> calls. The values of those
 * parameters will be taken from properties of the specified model bean.
 * For example, the link may require "id" and "slug" values, meaning
 * <code>getId()</code> and <code>getSlug()</code> will be called on the
 * model object at render time to populate the parameters of the link.
 *
 * @param id The wicket:id of the link in the HTML markup
 * @param model A model representing the bean that will be used to
 *              populate the parameters of the link
 *//*www.  j  a va 2 s .co m*/
public BookmarkablePageLink createLink(String id, final IModel<T> model) {
    BookmarkablePageLink bpl = new BookmarkablePageLink(id, this.pageClass) {
        @Override
        protected void onBeforeRender() {
            PageParameters params = createParameters(model.getObject());
            for (PageParameters.NamedPair pair : params.getAllNamed()) {
                getPageParameters().set(pair.getKey(), pair.getValue());
            }
            super.onBeforeRender();
        }

        @Override
        protected void onDetach() {
            model.detach();
            super.onDetach();
        }
    };
    return bpl;
}

From source file:fiftyfive.wicket.util.ParameterSpec.java

License:Apache License

/**
 * Use this method in your page constructor to parse the
 * PageParameters. The specified bean will be populated by calling the
 * appropriate setters as defined by this ParameterSpec. For example, if
 * the ParameterSpec has been created parameters that map "id" and "slug"
 * properties, the <code>setId()</code> and <code>setSlug()</code>
 * methods of the bean will be called with values taken from the
 * PageParameters.//from w w w. j  av  a 2  s.c o  m
 *
 * @param params Values will be taken from these PageParameters
 * @param beanToPopulate Values will be set using appropriate setters on
 *                       this bean
 * 
 * @throws AbortWithHttpErrorCodeException with a 404 status code if
 * {@code throw404OnParseError} is {@code true} and a parsing exception
 * occurs. For example, this could happen if the bean property for "id" is
 * of type Long, but the parameter value being parsed is not numeric.
 * If {@code throw404OnParseError} is {@code false}, skip past properties
 * with parsing errors.
 */
public void parseParameters(PageParameters params, T beanToPopulate, boolean throw404OnParseError) {
    for (PageParameters.NamedPair pair : params.getAllNamed()) {
        String key = pair.getKey();
        String expr = this.mapping.get(key);
        String val = pair.getValue();
        if (val != null) {
            try {
                PropertyResolver.setValue(expr, beanToPopulate, val, null);
            } catch (ConversionException ce) {
                if (throw404OnParseError) {
                    throw new AbortWithHttpErrorCodeException(404, "Not found");
                }
            }
        }
    }
}