org.springframework.web.servlet.view.AbstractTemplateView Java Examples
The following examples show how to use
org.springframework.web.servlet.view.AbstractTemplateView.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: I18nFunction.java From java-platform with Apache License 2.0 | 5 votes |
@Override public Object call(Object[] paras, Context ctx) { RequestContext requestContext = (RequestContext) ctx .getGlobal(AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE); Assert.notNull(requestContext); Assert.notNull(paras); Assert.isTrue(paras.length > 0); String code = (String) paras[0]; Object[] args = paras.length > 1 ? Arrays.copyOfRange(paras, 1, paras.length) : null; return requestContext.getMessage(code, args); }
Example #2
Source File: SpringWebThymeleafContextConverter.java From ogham with Apache License 2.0 | 5 votes |
@Override public IContext convert(fr.sii.ogham.core.template.context.Context context) throws ContextException { IContext base = delegate.convert(context); // the web context may be lost due to @Async method call if (isAsyncCall()) { return base; } // partially borrowed from org.thymeleaf.spring5.view.ThymeleafView final Map<String, Object> springModel = new HashMap<>(30); HttpServletRequest request = webContextProvider.getRequest(context); HttpServletResponse response = webContextProvider.getResponse(context); ServletContext servletContext = webContextProvider.getServletContext(context); if (pathVariablesSelector != null) { @SuppressWarnings("unchecked") final Map<String, Object> pathVars = (Map<String, Object>) request.getAttribute(pathVariablesSelector); if (pathVars != null) { springModel.putAll(pathVars); } } final RequestContext requestContext = new RequestContext(request, response, servletContext, springModel); // For compatibility with ThymeleafView addRequestContextAsVariable(springModel, springRequestContextVariableName, requestContext); // For compatibility with AbstractTemplateView addRequestContextAsVariable(springModel, AbstractTemplateView.SPRING_MACRO_REQUEST_CONTEXT_ATTRIBUTE, requestContext); thymeleafRequestContextWrapper.wrapAndRegister(requestContext, request, response, servletContext, springModel); return contextMerger.merge(thymeleafWebContextProvider.getWebContext(context, base, request, response, servletContext, applicationContext, springModel), base); }