use of org.apache.tiles.TilesContainer in project spring-framework by spring-projects.
the class TilesView method afterPropertiesSet.
@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);
}
}
use of org.apache.tiles.TilesContainer in project spring-framework-debug by Joker-5.
the class TilesView method afterPropertiesSet.
@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);
}
}
use of org.apache.tiles.TilesContainer in project spring-framework-5.2.9.RELEASE by somepeopleHavingDream.
the class TilesView method afterPropertiesSet.
@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);
}
}
use of org.apache.tiles.TilesContainer in project struts by apache.
the class TilesResult method doExecute.
/**
* Dispatches to the given location. Does its forward via a RequestDispatcher. If the
* dispatch fails a 404 error will be sent back in the http response.
*
* @param location the location to dispatch to.
* @param invocation the execution state of the action
* @throws Exception if an error occurs. If the dispatch fails the error will go back via the
* HTTP request.
*/
public void doExecute(String location, ActionInvocation invocation) throws Exception {
StrutsTilesAnnotationProcessor annotationProcessor = new StrutsTilesAnnotationProcessor();
TilesDefinition tilesDefinition = null;
Object action = invocation.getAction();
String actionName = invocation.getInvocationContext().getName();
if (StringUtils.isEmpty(location)) {
LOG.trace("location not set -> action must have one @TilesDefinition");
tilesDefinition = annotationProcessor.findAnnotation(action, null);
String tileName = StringUtils.isNotEmpty(tilesDefinition.name()) ? tilesDefinition.name() : actionName;
location = tileName;
LOG.debug("using new location name '{}' and @TilesDefinition '{}'", location, tilesDefinition);
}
setLocation(location);
ServletContext servletContext = ServletActionContext.getServletContext();
ApplicationContext applicationContext = ServletUtil.getApplicationContext(servletContext);
TilesContainer container = TilesAccess.getContainer(applicationContext);
HttpServletRequest httpRequest = ServletActionContext.getRequest();
HttpServletResponse httpResponse = ServletActionContext.getResponse();
Request request = new ServletRequest(applicationContext, httpRequest, httpResponse);
boolean definitionValid = false;
try {
LOG.debug("checking if tiles definition exists '{}'", location);
definitionValid = container.isValidDefinition(location, request);
} catch (TilesException e) {
LOG.warn("got TilesException while checking if definiton exists, ignoring it", e);
}
if (!definitionValid) {
if (tilesDefinition == null) {
LOG.trace("tilesDefinition not found yet, searching in action");
tilesDefinition = annotationProcessor.findAnnotation(action, location);
}
if (tilesDefinition != null) {
Definition definition = annotationProcessor.buildTilesDefinition(location, tilesDefinition);
if (container instanceof MutableTilesContainer) {
LOG.debug("registering tiles definition with name '{}'", definition.getName());
((MutableTilesContainer) container).register(definition, request);
} else {
LOG.error("cannot register tiles definition as tiles container is not mutable!");
}
} else {
LOG.warn("could not find @TilesDefinition for action: {}", actionName);
}
}
container.render(location, request);
}
use of org.apache.tiles.TilesContainer in project struts by apache.
the class PortletTilesResult method executeRenderResult.
protected void executeRenderResult(String location) throws TilesException {
setLocation(location);
PortletContext portletContext = PortletActionContext.getPortletContext();
RenderRequest request = PortletActionContext.getRenderRequest();
RenderResponse response = PortletActionContext.getRenderResponse();
TilesContainer container = getCurrentContainer(request, portletContext);
ApplicationContext applicationContext = container.getApplicationContext();
Request currentRequest = new RenderPortletRequest(applicationContext, portletContext, request, response);
container.render(location, currentRequest);
}
Aggregations