List of usage examples for org.apache.wicket.protocol.http.servlet ServletWebRequest getContextPath
@Override
public String getContextPath()
From source file:org.efaps.mobile.wicket.MobileSession.java
License:Apache License
/** * *//*from ww w.j a v a 2 s . co 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./* w w w .j av a 2 s . c o m*/ * * @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)); } } }