It is possible to use more that one Tiles container in your application.
To use an alternate container, you need to override the getContainerKey method of AbstractTilesInitializer this way:
public class TestAlternateTilesListener extends AbstractTilesListener { /** {@inheritDoc} */ @Override protected TilesInitializer createTilesInitializer() { return new TestAlternateTilesInitializer(); } /** * Test Tiles initializer for Tiles initialization of the alternate container. */ private static class TestAlternateTilesInitializer extends AbstractTilesInitializer { // Other customizations go here. /** {@inheritDoc} */ @Override protected String getContainerKey( TilesApplicationContext applicationContext) { return "myContainerKey"; } } }
Once defined, it is possible to select a non-default container through Java or JSP
It is possible to use, for the current request, a different container stored under another key, by using setCurrentContainer method of TilesAccess class. For example:
TilesAccess.setCurrentContainer(request, applicationContext, "myContainerKey");
If the last parameter is null, the default container is selected.