List of usage examples for org.apache.wicket.protocol.http.servlet ServletWebRequest getRequestParameters
public IRequestParameters getRequestParameters()
From source file:org.efaps.mobile.wicket.MobileSession.java
License:Apache License
/** * */// w ww.j a v a 2 s.c o m 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.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.//from w w w .j ava 2 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.onehippo.cms7.reports.plugins.brokenlinkslist.BrokenLinksStore.java
License:Apache License
private int parseIntParameter(ServletWebRequest request, String name, int defaultValue) { StringValue param = request.getRequestParameters().getParameterValue(name); if (!param.isNull()) { try {// www . ja v a2 s .c o m return Integer.parseInt(param.toString()); } catch (NumberFormatException e) { log.warn("Value of parameter '" + name + "' is not an integer: '" + param + "', using default value '" + defaultValue + "'"); } } return defaultValue; }