List of usage examples for org.springframework.web.servlet.view InternalResourceView setAttributesMap
public void setAttributesMap(@Nullable Map<String, ?> attributes)
From source file:org.jasig.cas.services.web.RegisteredServiceThemeBasedViewResolver.java
/** * Uses the viewName and the theme associated with the service. * being requested and returns the appropriate view. * @param viewName the name of the view to be resolved * @return a theme-based UrlBasedView/*w ww. java 2s . c om*/ * @throws Exception an exception */ @Override protected AbstractUrlBasedView buildView(final String viewName) throws Exception { final RequestContext requestContext = RequestContextHolder.getRequestContext(); final WebApplicationService service = WebUtils.getService(requestContext); final RegisteredService registeredService = this.servicesManager.findServiceBy(service); final String themeId = service != null && registeredService != null && registeredService.getAccessStrategy().isServiceAccessAllowed() && StringUtils.hasText(registeredService.getTheme()) ? registeredService.getTheme() : defaultThemeId; final String themePrefix = String.format("%s/%s/ui/", pathPrefix, themeId); LOGGER.debug("Prefix {} set for service {} with theme {}", themePrefix, service, themeId); //Build up the view like the base classes do, but we need to forcefully set the prefix for each request. //From UrlBasedViewResolver.buildView final InternalResourceView view = (InternalResourceView) BeanUtils.instantiateClass(getViewClass()); view.setUrl(themePrefix + viewName + getSuffix()); final String contentType = getContentType(); if (contentType != null) { view.setContentType(contentType); } view.setRequestContextAttribute(getRequestContextAttribute()); view.setAttributesMap(getAttributesMap()); //From InternalResourceViewResolver.buildView view.setAlwaysInclude(false); view.setExposeContextBeansAsAttributes(false); view.setPreventDispatchLoop(true); LOGGER.debug("View resolved: {}", view.getUrl()); return view; }