Example usage for org.apache.wicket.request IRequestParameters getParameterNames

List of usage examples for org.apache.wicket.request IRequestParameters getParameterNames

Introduction

In this page you can find the example usage for org.apache.wicket.request IRequestParameters getParameterNames.

Prototype

Set<String> getParameterNames();

Source Link

Document

Returns immutable set of all available parameter names.

Usage

From source file:org.brixcms.web.nodepage.BrixNodePageUrlMapper.java

License:Apache License

@SuppressWarnings("unchecked")
private String addQueryStringParameters(BrixPageParameters pageParameters, PageInfo pageInfo,
        IRequestParameters requestParameters) {
    final String pageInfoString = pageInfo != null ? pageInfo.toString() : null;

    String iface = null;/*  w  w w .j  av  a  2 s . c  om*/

    for (String name : requestParameters.getParameterNames()) {
        List<StringValue> values = requestParameters.getParameterValues(name);
        if (name.equals(getInterfaceParameter()) && values.size() > 0) {
            iface = values.get(0).toString();
        } else if (name.equals(pageInfoString) && values.size() == 1 && "".equals(values.get(0).toString())) {
            // don't add this to page parameters
        } else {
            for (StringValue value : values) {
                pageParameters.addQueryParam(name, value);
            }
        }
    }

    return iface;
}

From source file:org.cast.isi.ISIApplication.java

License:Open Source License

/**
 * Converts requestParameters to PageParameters.
 *
 * @param requestParameters//from  ww  w  .j  a va2 s  .c o m
 * @return
 */
private PageParameters requestParameters2PageParameters(IRequestParameters requestParameters) {
    PageParameters pageParameters = new PageParameters();
    for (String name : requestParameters.getParameterNames()) {
        List<StringValue> values = requestParameters.getParameterValues(name);
        for (StringValue value : values) {
            pageParameters.add(name, value.toString());
        }
    }
    return pageParameters;
}

From source file:org.efaps.mobile.wicket.MobileSession.java

License:Apache License

/**
 *
 *//* w w w. jav a 2s  .  c om*/
public void openContext() {
    if (isAuthenticated()) {
        try {
            if (!Context.isTMActive()) {
                final ServletWebRequest request = (ServletWebRequest) RequestCycle.get().getRequest();

                final Map<String, String[]> parameters = new HashMap<String, String[]>();
                final IRequestParameters reqPara = request.getRequestParameters();
                for (final String name : reqPara.getParameterNames()) {
                    final List<StringValue> values = reqPara.getParameterValues(name);
                    final String[] valArray = new String[values.size()];
                    int i = 0;
                    for (final StringValue value : values) {
                        valArray[i] = value.toString();
                        i++;
                    }
                    parameters.put(name, valArray);
                }
                final Map<String, Object> sessionAttributes = new HashMap<String, Object>();
                for (final String attribute : getAttributeNames()) {
                    sessionAttributes.put(attribute, getAttribute(attribute));
                }
                Context.begin(this.userName, super.getLocale(), sessionAttributes, parameters, null, true);
                // set the locale in the context and in the session
                setLocale(Context.getThreadContext().getLocale());
                setAttribute(UserAttributesSet.CONTEXTMAPKEY, Context.getThreadContext().getUserAttributes());
                Context.getThreadContext().setPath(request.getContextPath());
            }
        } catch (final EFapsException e) {
            MobileSession.LOG.error("could not initialise the context", e);
            throw new RestartResponseException(new InternalErrorPage());
        }
    }
}

From source file:org.efaps.ui.wicket.components.FormContainer.java

License:Apache License

/**
 * Handle the multipart to store the files and parameters in the context also.
 * @return true if multipart/*from  ww w . j  a va  2 s  . c o m*/
 */
@Override
protected boolean handleMultiPart() {
    final boolean ret = super.handleMultiPart();
    try {
        if (isMultiPart() && getRequest() instanceof MultipartServletWebRequest) {
            for (final Entry<String, List<FileItem>> entry : ((MultipartServletWebRequest) getRequest())
                    .getFiles().entrySet()) {
                for (final FileItem fileItem : entry.getValue()) {
                    final FileParameter parameter = new FileParameter(entry.getKey(), fileItem);
                    Context.getThreadContext().getFileParameters().put(entry.getKey(), parameter);
                }
            }

            final Map<String, String[]> parameters = new HashMap<>();
            final IRequestParameters reqPara = getRequest().getRequestParameters();
            for (final String name : reqPara.getParameterNames()) {
                final List<StringValue> values = reqPara.getParameterValues(name);
                final String[] valArray = new String[values.size()];
                int i = 0;
                for (final StringValue value : values) {
                    valArray[i] = value.toString();
                    i++;
                }
                parameters.put(name, valArray);
            }
            Context.getThreadContext().getParameters().putAll(parameters);
        }
    } catch (final EFapsException e) {
        throw new RestartResponseAtInterceptPageException(new ErrorPage(e));
    }
    return ret;
}

From source file:org.efaps.ui.wicket.EFapsSession.java

License:Apache License

/**
 * Method that opens a new Context in eFaps, setting the User, the Locale,
 * the Attributes of this Session {@link #sessionAttributes} and the
 * RequestParameters for the Context./* w w w .j  a va2  s .  com*/
 *
 * @see #attach()
 */
public void openContext() {
    if (isLogedIn()) {
        try {
            if (!Context.isTMActive()) {
                final ServletWebRequest request = (ServletWebRequest) RequestCycle.get().getRequest();
                if (request instanceof EFapsRequest || request instanceof EFapsMultipartRequest) {
                    final Map<String, String[]> parameters = new HashMap<>();
                    final IRequestParameters reqPara = request.getRequestParameters();
                    for (final String name : reqPara.getParameterNames()) {
                        final List<StringValue> values = reqPara.getParameterValues(name);
                        final String[] valArray;
                        if (values == null) {
                            valArray = ArrayUtils.EMPTY_STRING_ARRAY;
                        } else {
                            valArray = new String[values.size()];
                            int i = 0;
                            for (final StringValue value : values) {
                                valArray[i] = value.toString();
                                i++;
                            }
                        }
                        parameters.put(name, valArray);
                    }

                    Context.begin(this.userName, super.getLocale(), this.sessionAttributes, parameters, null,
                            Context.Inheritance.Inheritable);
                    // set the locale in the context and in the session
                    setLocale(Context.getThreadContext().getLocale());
                    setAttribute(UserAttributesSet.CONTEXTMAPKEY,
                            Context.getThreadContext().getUserAttributes());
                    Context.getThreadContext().setPath(request.getContextPath());
                }
            }
        } catch (final EFapsException e) {
            EFapsSession.LOG.error("could not initialise the context", e);
            throw new RestartResponseException(new ErrorPage(e));
        }
    }
}

From source file:org.efaps.ui.wicket.request.EFapsRequestParametersAdapter.java

License:Apache License

/**
 * @param _parameters paramters to work on
 *//*  w  ww  .  jav  a2 s.c o m*/
public EFapsRequestParametersAdapter(final IRequestParameters... _parameters) {
    for (final IRequestParameters p : _parameters) {
        for (final String name : p.getParameterNames()) {
            final List<StringValue> values = p.getParameterValues(name);
            this.parameters.put(name, values);
            EFapsRequestParametersAdapter.LOG.trace("adding parameter from request. Name: '{}', value: {}",
                    name, values);
        }
    }
}

From source file:org.efaps.ui.wicket.util.ParameterUtil.java

License:Apache License

/**
 * Get an array for the StringValues./*from w w  w.  j a v  a  2s  .c  o m*/
 *
 * @param _parameters IRequestParameters
 * @return always StringArray, if parameter does not exist an empty
 *         StringArray
 */
public static Map<String, String[]> parameter2Map(final IRequestParameters _parameters) {
    final Map<String, String[]> ret = new HashMap<>();
    for (final String name : _parameters.getParameterNames()) {
        ret.put(name, ParameterUtil.parameter2Array(_parameters, name));
    }
    return ret;
}

From source file:org.hippoecm.frontend.plugins.richtext.dialog.AbstractAjaxDialogBehavior.java

License:Apache License

protected Map<String, String> getParameters() {
    Request request = RequestCycle.get().getRequest();
    HashMap<String, String> parameters = new HashMap<String, String>();
    final IRequestParameters requestParameters = request.getPostParameters();
    for (String key : requestParameters.getParameterNames()) {
        parameters.put(key, requestParameters.getParameterValue(key).toString());
    }//from  www .  j  a v  a2s . c  o m
    return parameters;
}

From source file:org.jaulp.wicket.base.util.parameter.PageParametersUtils.java

License:Apache License

/**
 * Gets a map with all parameters. Looks in the query and post parameters. Migration method from
 * 1.4.* to 1.5.*.//from   ww  w.j a  v a2  s  . c om
 * 
 * @param request
 *            the request
 * @return a map with all parameters.
 */
public static Map<String, String[]> getParameterMap(Request request) {
    IRequestParameters parameters = request.getRequestParameters();
    final Map<String, String[]> map = new HashMap<>();
    Set<String> parameterNames = parameters.getParameterNames();
    for (String parameterName : parameterNames) {
        List<StringValue> parameterValues = parameters.getParameterValues(parameterName);
        String[] stringArray = {};
        if (parameterValues != null && !parameterValues.isEmpty()) {
            stringArray = new String[parameterValues.size()];
            for (int i = 0; i < parameterValues.size(); i++) {
                stringArray[i] = parameterValues.get(i).toString();
            }
        }
        map.put(parameterName, stringArray);
    }
    return map;
}

From source file:org.openengsb.ui.admin.xlink.ToolChooserPage.java

License:Apache License

/**
 * Returns the Requestparameter as a Map. 
 *//*from  w  ww . j  a v  a2 s.c  om*/
private Map<String, String[]> getRequestParametersAsAMap() {
    Map<String, String[]> parameterMap = new HashMap<String, String[]>();
    IRequestParameters parameters = getRequest().getQueryParameters();
    for (String key : parameters.getParameterNames()) {
        List<StringValue> values = parameters.getParameterValues(key);
        List<String> valuesAsString = new ArrayList<String>();
        for (StringValue stringvalue : values) {
            valuesAsString.add(stringvalue.toString());
        }
        parameterMap.put(key, (String[]) valuesAsString.toArray(new String[0]));
    }
    return parameterMap;
}