You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@sling.apache.org by fm...@apache.org on 2007/10/05 09:57:28 UTC
svn commit: r582112 - in
/incubator/sling/trunk/scripting-jsp-taglib/src/main:
java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
resources/META-INF/taglib.tld
Author: fmeschbe
Date: Fri Oct 5 00:57:28 2007
New Revision: 582112
URL: http://svn.apache.org/viewvc?rev=582112&view=rev
Log:
SLING-41 Create synthetic content in sling:include if real content does not exist
Modified:
incubator/sling/trunk/scripting-jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
incubator/sling/trunk/scripting-jsp-taglib/src/main/resources/META-INF/taglib.tld
Modified: incubator/sling/trunk/scripting-jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting-jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java?rev=582112&r1=582111&r2=582112&view=diff
==============================================================================
--- incubator/sling/trunk/scripting-jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java (original)
+++ incubator/sling/trunk/scripting-jsp-taglib/src/main/java/org/apache/sling/scripting/jsp/taglib/IncludeTagHandler.java Fri Oct 5 00:57:28 2007
@@ -24,9 +24,11 @@
import javax.servlet.jsp.tagext.BodyContent;
import javax.servlet.jsp.tagext.TagSupport;
+import org.apache.sling.component.ComponentException;
import org.apache.sling.component.ComponentRequest;
import org.apache.sling.component.ComponentResponse;
import org.apache.sling.component.Content;
+import org.apache.sling.content.jcr.SyntheticContent;
import org.apache.sling.scripting.jsp.util.JspComponentResponseWrapper;
import org.apache.sling.scripting.jsp.util.TagUtil;
import org.slf4j.Logger;
@@ -52,6 +54,9 @@
/** path argument */
private String path;
+ /** componentId argument */
+ private String componentId;
+
/**
* Called after the body has been processed.
*
@@ -74,8 +79,24 @@
path = request.getContent().getPath() + "/" + path;
}
- // get the request dispatcher for the (relative) path
- dispatcher = request.getRequestDispatcher(path);
+ // if the componentId is set, try to resolve the path, if no
+ // content exists for the path create a synthetic content
+ if (componentId != null) {
+ try {
+ content = request.getContent(path);
+ if (content == null) {
+ content = new SyntheticContent(path, componentId);
+ }
+ } catch (ComponentException ce) {
+ TagUtil.log(log, pageContext, "Problem trying to load content", ce);
+ }
+ }
+
+ // get the request dispatcher for the (relative) path (if not set
+ // with the base content above
+ if (dispatcher == null) {
+ dispatcher = request.getRequestDispatcher(path);
+ }
}
try {
@@ -115,5 +136,9 @@
public void setPath(String path) {
this.path = path;
+ }
+
+ public void setComponentId(String componentId) {
+ this.componentId = componentId;
}
}
Modified: incubator/sling/trunk/scripting-jsp-taglib/src/main/resources/META-INF/taglib.tld
URL: http://svn.apache.org/viewvc/incubator/sling/trunk/scripting-jsp-taglib/src/main/resources/META-INF/taglib.tld?rev=582112&r1=582111&r2=582112&view=diff
==============================================================================
--- incubator/sling/trunk/scripting-jsp-taglib/src/main/resources/META-INF/taglib.tld (original)
+++ incubator/sling/trunk/scripting-jsp-taglib/src/main/resources/META-INF/taglib.tld Fri Oct 5 00:57:28 2007
@@ -69,6 +69,21 @@
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
+ <attribute>
+ <description>
+ The component ID of a content to include. If the content
+ to be included is specified with the path attribute,
+ which cannot be resolved to a Content, the tag may
+ create a synthetic Content object out of the path and
+ this componentId. If the componentId is set the path
+ must be the exact path to a Content object. That is,
+ adding parameters, selectors and extensions to the path
+ is not supported if the componentId is set.
+ </description>
+ <name>componentId</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
</tag>
<tag>