I've just committed an implementation of SLING-1303, which allows
bundles to dynamically add new values to the Bindings object used with
scripting. I think it's working nicely, except for the JSP integration.
IIRC, you can't dynamically add scripting variables - the TagExtraInfo
class is invoked at compile time, not runtime.
Assuming this is the case (and I'm the first to admit my JSP API skills
are weak), I'm not sure the best way to present these additional
Bindings values to JSP scripts. As things currently stand, you need to
get the SlingBindings object out of the request attributes and then get
the key you want:
<%...@page import="org.apache.sling.api.scripting.SlingBindings"%>
...
<% SlingBindings bindings = (SlingBindings)
request.getAttribute("org.apache.sling.api.scripting.SlingBindings"); %>
...
<p>jspHelloWorld:<%= bindings.get("jspHelloWorld") %></p>
Ideally, this would be:
<p>jspHelloWorld:<%= jspHelloWorld %></p>
(which is how it works in ESP and Groovy scripts)
but that seems impossible.
Anyone who actually uses JSPs care to comment on what would be the most
natural way to interface with these non-standard Bindings values?
Thanks,
Justin