Author: apetrelli
Date: Thu Feb 28 12:16:04 2008
New Revision: 632110
URL: http://svn.apache.org/viewvc?rev=632110&view=rev
Log:
TILES-259
Moved rendition of the template, via <tiles:insertTemplate> in the Tiles
container, by using an AttributeContext.
Modified:
tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/TilesContainer.java
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java
Modified:
tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/TilesContainer.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/TilesContainer.java?rev=632110&r1=632109&r2=632110&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/TilesContainer.java
(original)
+++
tiles/framework/trunk/tiles-api/src/main/java/org/apache/tiles/TilesContainer.java
Thu Feb 28 12:16:04 2008
@@ -80,6 +80,15 @@
void endContext(Object... requestItems);
/**
+ * Renders the current context, as it is.
+ *
+ * @param requestItems the current request objects.
+ * @throws TilesException If something goes wrong during rendition.
+ * @since 2.1.0
+ */
+ void renderContext(Object... requestItems) throws TilesException;
+
+ /**
* @param definition the requested definition
* @param requestItems the current request objects.
* @throws TilesException is processing fails.
Modified:
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java?rev=632110&r1=632109&r2=632110&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
(original)
+++
tiles/framework/trunk/tiles-core/src/main/java/org/apache/tiles/impl/BasicTilesContainer.java
Thu Feb 28 12:16:04 2008
@@ -156,6 +156,22 @@
endContext(tilesContext);
}
+ /** [EMAIL PROTECTED] */
+ public void renderContext(Object... requestItems) throws TilesException {
+ TilesRequestContext request = getRequestContext(requestItems);
+ AttributeContext attributeContext = getAttributeContext(request);
+
+ if (!isPermitted(request, attributeContext.getRoles())) {
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Access to current attribute context denied. "
+ + "User not in role '" + attributeContext.getRoles());
+ }
+ return;
+ }
+
+ render(request, attributeContext);
+ }
+
/**
* Returns the Tiles application context used by this container.
*
Modified:
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java
URL:
http://svn.apache.org/viewvc/tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java?rev=632110&r1=632109&r2=632110&view=diff
==============================================================================
---
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java
(original)
+++
tiles/framework/trunk/tiles-jsp/src/main/java/org/apache/tiles/jsp/taglib/InsertTemplateTag.java
Thu Feb 28 12:16:04 2008
@@ -23,9 +23,9 @@
import java.io.IOException;
+import org.apache.tiles.TilesException;
import org.apache.tiles.jsp.context.JspUtil;
-import javax.servlet.ServletException;
import javax.servlet.jsp.JspException;
/**
@@ -64,22 +64,18 @@
/** [EMAIL PROTECTED] */
protected void render() throws JspException {
- // FIXME This code should be changed once the overriding template
- // facility will be available, so it can be managed by the Tiles
- // container.
JspUtil.setForceInclude(pageContext, true);
try {
- pageContext.include(template, flush);
- } catch (ServletException e) {
- Throwable rootCause = e.getRootCause();
- if (rootCause != null) {
- // Replace the ServletException with a JspException
- throw new JspException(rootCause);
- } else {
- throw new JspException(e);
+ attributeContext.setTemplate(template);
+ container.renderContext(pageContext);
+ if (flush) {
+ pageContext.getOut().flush();
}
} catch (IOException e) {
- throw new JspException(e);
+ throw new JspException("Error during flush", e);
+ } catch (TilesException e) {
+ throw new JspException("Error during rendering of template '"
+ + template + "'", e);
}
}
}