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 2008/05/23 10:56:35 UTC
svn commit: r659479 - 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 May 23 01:56:35 2008
New Revision: 659479
URL: http://svn.apache.org/viewvc?rev=659479&view=rev
Log:
SLING-473 Apply slightly modified patch to support full range of
RequestDispatcher options as tag attributes. Thanks to
Dominique Jaeggi for providing the patch.
The RequestDispatcherOptions handling is now done as follows:
* A RequestDispatcherOptions object is always created
* The options are set from optional attributes, a non-set
attribute has no influence
* If during processing a synthetic resource is to be created
for inclusion, the resource type overwrite in the
RequestDispatcherOptions is removed
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=659479&r1=659478&r2=659479&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 May 23 01:56:35 2008
@@ -59,6 +59,15 @@
/** resource type argument */
private String resourceType;
+ /** replace selectors argument */
+ private String replaceSelectors;
+
+ /** additional selectors argument */
+ private String addSelectors;
+
+ /** replace suffix argument */
+ private String replaceSuffix;
+
/**
* Called after the body has been processed.
*
@@ -69,12 +78,14 @@
final SlingHttpServletRequest request = TagUtil.getRequest(pageContext);
- // check for resource otherwise resolve from path
- RequestDispatcherOptions opts = null;
- if (resourceType != null) {
- opts = new RequestDispatcherOptions();
- opts.setForceResourceType(resourceType);
- }
+ // set request dispatcher options according to tag attributes. This
+ // depends on the implementation, that using a "null" argument
+ // has no effect
+ final RequestDispatcherOptions opts = new RequestDispatcherOptions();
+ opts.setForceResourceType(resourceType);
+ opts.setReplaceSelectors(replaceSelectors);
+ opts.setAddSelectors(addSelectors);
+ opts.setReplaceSuffix(replaceSuffix);
// ensure the path (if set) is absolute and normalized
if (path != null) {
@@ -93,9 +104,12 @@
// check whether the path (would) resolve, else SyntheticRes.
Resource tmp = request.getResourceResolver().resolve(path);
if (tmp == null && resourceType != null) {
- opts = null; // not needed
resource = new SyntheticResource(
request.getResourceResolver(), path, resourceType);
+
+ // remove resource type overwrite as synthetic resource
+ // is correctly typed as requested
+ opts.remove(RequestDispatcherOptions.OPT_FORCE_RESOURCE_TYPE);
}
}
}
@@ -140,6 +154,9 @@
flush = false;
resource = null;
resourceType = null;
+ replaceSelectors = null;
+ addSelectors = null;
+ replaceSuffix = null;
path = null;
}
@@ -158,4 +175,16 @@
public void setResourceType(String rsrcType) {
this.resourceType = rsrcType;
}
+
+ public void setReplaceSelectors(String selectors) {
+ this.replaceSelectors = selectors;
+ }
+
+ public void setAddSelectors(String selectors) {
+ this.addSelectors = selectors;
+ }
+
+ public void setReplaceSuffix(String suffix) {
+ this.replaceSuffix = suffix;
+ }
}
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=659479&r1=659478&r2=659479&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 May 23 01:56:35 2008
@@ -7,9 +7,9 @@
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
-
+
http://www.apache.org/licenses/LICENSE-2.0
-
+
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
@@ -84,6 +84,32 @@
<required>false</required>
<rtexprvalue>true</rtexprvalue>
</attribute>
+ <attribute>
+ <description>
+ When dispatching, replace selectors by the value
+ provided by this option.
+ </description>
+ <name>replaceSelectors</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+ When dispatching, add the value provided by this option to the selectors.
+ </description>
+ <name>addSelectors</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
+ <attribute>
+ <description>
+ When dispatching, replace the suffix by the value
+ provided by this option.
+ </description>
+ <name>replaceSuffix</name>
+ <required>false</required>
+ <rtexprvalue>true</rtexprvalue>
+ </attribute>
</tag>
<tag>