You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by "James Phillpotts (JIRA)" <ji...@apache.org> on 2012/06/22 16:49:42 UTC

[jira] [Commented] (SLING-2455) JSTL EL does not work in all cases

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

James Phillpotts commented on SLING-2455:
-----------------------------------------

This could be fixed by implementing an ELResolver that did something along the lines of the following for getValue:

if (base instanceof Node) {
  Node n = (Node)base;
  if (n.hasProperty(property.toString())) {
    context.setPropertyResolved(true);
    return n.getProperty(property.toString());
}
return null;

You'd then need appropriate implementations for getType, setValue and isReadOnly.
                
> JSTL EL does not work in all cases
> ----------------------------------
>
>                 Key: SLING-2455
>                 URL: https://issues.apache.org/jira/browse/SLING-2455
>             Project: Sling
>          Issue Type: Bug
>          Components: Scripting
>         Environment: Mac OSX
>            Reporter: Sandro Boehme
>            Priority: Minor
>
> At the latest trunk (rev.1309704) a jstl expression within a <c:forEach> tag throws the jsp compile error "org.apache.sling.scripting.jsp.jasper.el.JspValueExpression cannot be resolved to a type"
> Example jsp:
> <%@ page session="false"%>
> <%@ page isELIgnored="false"%>
> <%@ page import="javax.jcr.*,org.apache.sling.api.resource.Resource"%>
> <%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
> <%@ taglib prefix="sling" uri="http://sling.apache.org/taglibs/sling/1.0"%>
> <sling:defineObjects />
> <html>
> <head>
> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
> </head>
> <body>
> <%--
> The following two tags dont work.
> --%>
> 	<c:forEach var="property" items="${currentNode.properties}">
> 		${property.name}
> 	</c:forEach>
> 	<c:set var="nodePath" scope="request" value="${currentNode.path}"/>
> <%--
> The following two tags do work.
> --%>
> 	<c:forEach var="property" items="<%=currentNode.getProperties()%>">
> 		${property.name}<br/>
> 	</c:forEach>
> 	
> 	<c:if test="${currentNode.path=='/content/mynode'}">
> 		<br/>in if statement
> 	</c:if>
> </body>
> </html>
> I know you know how to do that but just to make it easier for you, here are the commands:
> curl -u admin:admin -F"sling:resourceType=el" -F"prop1=val1" -F"prop2=val2" http://localhost:8080/content/mynode
> curl -X MKCOL -u admin:admin http://localhost:8080/apps/el
> curl -u admin:admin -T el.jsp http://localhost:8080/apps/el/html.jsp
> URL to test: http://localhost:8080/content/mynode.html

--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators: https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira