jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Alexander Klimetschek <aklim...@day.com>
Subject Re: JackRabbit + JSP/JSTL
Date Mon, 23 Nov 2009 11:26:38 GMT
On Mon, Nov 23, 2009 at 12:20, Ben Short <ben@benshort.co.uk> wrote:
> Is there any way to access the jcr api in a jsp file in a cleaner way or via
> jstl?

Not directly, but with a small helper such as the ValueMap [1] and its
JCR implementation [2] in Apache Sling.

You use it as follows:
ValueMap map = new JcrPropertyMap(node);
String foo = map.get("foobar", "default"); // using default values and
automatic types, in this case expecting a string property
Integer counter = map.get("counter", Integer.class); // converts to
int (jcr api) or returns null if not present

[1] http://svn.apache.org/repos/asf/sling/trunk/bundles/api/src/main/java/org/apache/sling/api/resource/ValueMap.java
[2] http://svn.apache.org/repos/asf/sling/trunk/bundles/jcr/resource/src/main/java/org/apache/sling/jcr/resource/internal/JcrPropertyMap.java

Regards,
Alex

-- 
Alexander Klimetschek
alexander.klimetschek@day.com

Mime
View raw message