[ 
https://issues.apache.org/jira/browse/SLING-5653?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15232144#comment-15232144
 ] 

Robert Munteanu commented on SLING-5653:
----------------------------------------

Fix looks good to me, I arrived at the same code after you mentioned the 
{{TagData.REQUEST_TIME_VALUE}}.

Would it make sense to include an IT as well?

{noformat}
diff --git 
a/launchpad/integration-tests/src/main/resources/integration-test/taglib-test.jsp
 
b/launchpad/integration-tests/src/main/resources/integration-test/taglib-test.jsp
index ca9edc9..5c88e7c 100644
--- 
a/launchpad/integration-tests/src/main/resources/integration-test/taglib-test.jsp
+++ 
b/launchpad/integration-tests/src/main/resources/integration-test/taglib-test.jsp
@@ -13,6 +13,10 @@ AdaptTo Tag
     Test 3: Test Non-Adaptable Handling
     result: <c:catch var="adaptionException"><sling:adaptTo adaptable="res" 
adaptTo="org.apache.sling.api.resource.ValueMap" var="props3" 
/></c:catch><c:choose><c:when test="${not empty adaptionException}">SUCCESS: 
${adaptionException}</c:when><c:otherwise>ERROR<c:set var="success" 
value="false" /></c:otherwise></c:choose>
 
+    Test 4: Test adapting when the class name is a run-time expression
+    <c:set var="dest" value="org.apache.sling.api.resource.ValueMap"/> 
+    result: <sling:adaptTo adaptable="${resource}" adaptTo="${dest}" 
var="props5"/><c:choose><c:when test="${not empty 
props5}">SUCCESS</c:when><c:otherwise>ERROR<c:set var="success" value="false" 
/></c:otherwise></c:choose>
+    
 Encode Tag
     Test 1: HTML Encode
     Result: HTML_ENCODE:<sling:encode value="&Hello World!<script></script>" 
mode="HTML" />
{noformat}

> adaptTo tag fails when adaptTo parameter is an expression
> ---------------------------------------------------------
>
>                 Key: SLING-5653
>                 URL: https://issues.apache.org/jira/browse/SLING-5653
>             Project: Sling
>          Issue Type: Bug
>          Components: Scripting
>    Affects Versions: Scripting JSP-Taglib 2.2.4
>            Reporter: Robert Munteanu
>             Fix For: Scripting JSP-Taglib 2.2.6
>
>         Attachments: SLING-5653-tentative.patch, 
> SLING-5653-unexpected-object.png
>
>
> The following code sample fails:
> {code:java}
> <c:set var="dest" value="org.apache.sling.api.resource.ValueMap"/> 
> <sling:adaptTo adaptable="${resource}" adaptTo="${dest}" var="props5"/>
> {code}
> Root cause seems to be
> {noformat}Caused by: java.lang.ClassCastException: java.lang.Object cannot be 
> cast to java.lang.String
>       at javax.servlet.jsp.tagext.TagData.getAttributeString(TagData.java:138)
>       at 
> org.apache.sling.scripting.jsp.taglib.tei.AdaptToTEI.getClassName(AdaptToTEI.java:26){noformat}



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to