use of com.opensymphony.xwork2.LocaleProviderFactory in project struts by apache.
the class StrutsTilesLocaleResolver method resolveLocale.
@Override
public Locale resolveLocale(Request request) {
HttpServletRequest httpRequest = ServletUtil.getServletRequest(request).getRequest();
ActionContext ctx = ServletActionContext.getActionContext(httpRequest);
if (ctx == null) {
LOG.error("Cannot obtain HttpServletRequest from [{}]", request.getClass().getName());
throw new ConfigurationException("There is no ActionContext for current request!");
}
LocaleProviderFactory localeProviderFactory = ctx.getInstance(LocaleProviderFactory.class);
return localeProviderFactory.createLocaleProvider().getLocale();
}
use of com.opensymphony.xwork2.LocaleProviderFactory in project struts by apache.
the class Dispatcher method wrapRequest.
/**
* <p>
* Wrap and return the given request or return the original request object.
* </p>
*
* <p>
* This method transparently handles multipart data as a wrapped class around the given request.
* Override this method to handle multipart requests in a special way or to handle other types of requests.
* Note, {@link org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper} is
* flexible - look first to that object before overriding this method to handle multipart data.
* </p>
*
* @param request the HttpServletRequest object.
* @return a wrapped request or original request.
* @throws java.io.IOException on any error.
* @see org.apache.struts2.dispatcher.multipart.MultiPartRequestWrapper
* @since 2.3.17
*/
public HttpServletRequest wrapRequest(HttpServletRequest request) throws IOException {
// don't wrap more than once
if (request instanceof StrutsRequestWrapper) {
return request;
}
if (isMultipartSupportEnabled(request) && isMultipartRequest(request)) {
MultiPartRequest multiPartRequest = getMultiPartRequest();
LocaleProviderFactory localeProviderFactory = getContainer().getInstance(LocaleProviderFactory.class);
request = new MultiPartRequestWrapper(multiPartRequest, request, getSaveDir(), localeProviderFactory.createLocaleProvider(), disableRequestAttributeValueStackLookup);
} else {
request = new StrutsRequestWrapper(request, disableRequestAttributeValueStackLookup);
}
return request;
}
Aggregations