org.apache.tiles.TilesContainer Java Examples

The following examples show how to use org.apache.tiles.TilesContainer. 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: TilesView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean checkResource(final Locale locale) throws Exception {
	TilesContainer container = ServletUtil.getContainer(getServletContext());
	if (!(container instanceof BasicTilesContainer)) {
		// Cannot check properly - let's assume it's there.
		return true;
	}
	BasicTilesContainer basicContainer = (BasicTilesContainer) container;
	TilesApplicationContext appContext = new ServletTilesApplicationContext(getServletContext());
	TilesRequestContext requestContext = new ServletTilesRequestContext(appContext, null, null) {
		@Override
		public Locale getRequestLocale() {
			return locale;
		}
	};
	return (basicContainer.getDefinitionsFactory().getDefinition(getUrl(), requestContext) != null);
}
 
Example #2
Source File: TilesView.java    From lams with GNU General Public License v2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(
		Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

	ServletContext servletContext = getServletContext();
	TilesContainer container = ServletUtil.getContainer(servletContext);
	if (container == null) {
		throw new ServletException("Tiles container is not initialized. " +
				"Have you added a TilesConfigurer to your web application context?");
	}

	exposeModelAsRequestAttributes(model, request);
	JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext));
	if (this.alwaysInclude) {
		ServletUtil.setForceInclude(request, true);
	}
	container.render(getUrl(), request, response);
}
 
Example #3
Source File: TilesView.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
public boolean checkResource(final Locale locale) throws Exception {
	TilesContainer container = ServletUtil.getContainer(getServletContext());
	if (!(container instanceof BasicTilesContainer)) {
		// Cannot check properly - let's assume it's there.
		return true;
	}
	BasicTilesContainer basicContainer = (BasicTilesContainer) container;
	TilesApplicationContext appContext = new ServletTilesApplicationContext(getServletContext());
	TilesRequestContext requestContext = new ServletTilesRequestContext(appContext, null, null) {
		@Override
		public Locale getRequestLocale() {
			return locale;
		}
	};
	return (basicContainer.getDefinitionsFactory().getDefinition(getUrl(), requestContext) != null);
}
 
Example #4
Source File: TilesView.java    From spring4-understanding with Apache License 2.0 6 votes vote down vote up
@Override
protected void renderMergedOutputModel(
		Map<String, Object> model, HttpServletRequest request, HttpServletResponse response) throws Exception {

	ServletContext servletContext = getServletContext();
	TilesContainer container = ServletUtil.getContainer(servletContext);
	if (container == null) {
		throw new ServletException("Tiles container is not initialized. " +
				"Have you added a TilesConfigurer to your web application context?");
	}

	exposeModelAsRequestAttributes(model, request);
	JstlUtils.exposeLocalizationContext(new RequestContext(request, servletContext));
	if (this.alwaysInclude) {
		ServletUtil.setForceInclude(request, true);
	}
	container.render(getUrl(), request, response);
}
 
Example #5
Source File: ActionHelper.java    From attic-stratos with Apache License 2.0 6 votes vote down vote up
/**
 *
 * @param actionUrl url should be start with "/"
 * @param request HttpServletRequest
 * @param response HttpServletResponse
 * @throws Exception Exception
 */
public static void render(String actionUrl, HttpServletRequest request,
                   HttpServletResponse response) throws Exception {
    TilesContainer container = TilesAccess.getContainer(
            request.getSession().getServletContext());
    if(log.isDebugEnabled()){
        log.debug("Rendering tiles main.layout with page : "+actionUrl+"("+request.getSession().getId()+")");        	
    }
    AttributeContext attributeContext = container.startContext(request, response);
    Attribute attr = new Attribute(actionUrl);
    attributeContext.putAttribute("body", attr);
    try {
        container.render("main.layout", request, response);
        container.endContext(request, response);
    } catch (Exception e) {
        if (log.isDebugEnabled()) {  // Intentionally logged at debug level
            log.debug("Error occurred while rendering." +
                      " We generally see this 'harmless' exception on WebLogic. Hiding it.", e);
        }
    }
}
 
Example #6
Source File: TilesView.java    From spring-analysis-note with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	super.afterPropertiesSet();

	ServletContext servletContext = getServletContext();
	Assert.state(servletContext != null, "No ServletContext");
	this.applicationContext = ServletUtil.getApplicationContext(servletContext);

	if (this.renderer == null) {
		TilesContainer container = TilesAccess.getContainer(this.applicationContext);
		this.renderer = new DefinitionRenderer(container);
	}
}
 
Example #7
Source File: TilesView.java    From java-technology-stack with MIT License 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	super.afterPropertiesSet();

	ServletContext servletContext = getServletContext();
	Assert.state(servletContext != null, "No ServletContext");
	this.applicationContext = ServletUtil.getApplicationContext(servletContext);

	if (this.renderer == null) {
		TilesContainer container = TilesAccess.getContainer(this.applicationContext);
		this.renderer = new DefinitionRenderer(container);
	}
}
 
Example #8
Source File: TilesView.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	super.afterPropertiesSet();

	this.applicationContext = ServletUtil.getApplicationContext(getServletContext());
	if (this.renderer == null) {
		TilesContainer container = TilesAccess.getContainer(this.applicationContext);
		this.renderer = new DefinitionRenderer(container);
	}
}
 
Example #9
Source File: TilesView.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
@Override
public void afterPropertiesSet() throws Exception {
	super.afterPropertiesSet();

	this.applicationContext = ServletUtil.getApplicationContext(getServletContext());
	if (this.renderer == null) {
		TilesContainer container = TilesAccess.getContainer(this.applicationContext);
		this.renderer = new DefinitionRenderer(container);
	}
}
 
Example #10
Source File: TilesConfigurer.java    From spring-analysis-note with MIT License 4 votes vote down vote up
@Override
protected TilesContainer createDecoratedContainer(TilesContainer originalContainer, ApplicationContext context) {
	return (useMutableTilesContainer ? new CachingTilesContainer(originalContainer) : originalContainer);
}
 
Example #11
Source File: TilesConfigurer.java    From java-technology-stack with MIT License 4 votes vote down vote up
@Override
protected TilesContainer createDecoratedContainer(TilesContainer originalContainer, ApplicationContext context) {
	return (useMutableTilesContainer ? new CachingTilesContainer(originalContainer) : originalContainer);
}
 
Example #12
Source File: TilesConfigurer.java    From lams with GNU General Public License v2.0 4 votes vote down vote up
@Override
protected TilesContainer createDecoratedContainer(TilesContainer originalContainer, ApplicationContext context) {
	return (useMutableTilesContainer ? new CachingTilesContainer(originalContainer) : originalContainer);
}
 
Example #13
Source File: TilesConfigurer.java    From spring4-understanding with Apache License 2.0 4 votes vote down vote up
@Override
public TilesContainer createContainer(ApplicationContext context) {
	TilesContainer container = super.createContainer(context);
	return (useMutableTilesContainer ? new CachingTilesContainer(container) : container);
}