You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@sling.apache.org by Justin Edelson <ju...@gmail.com> on 2010/01/25 20:43:01 UTC
New BindingsValuesProvider interface and JSPs
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
Re: New BindingsValuesProvider interface and JSPs
Posted by Justin Edelson <ju...@gmail.com>.
On 1/26/10 10:05 AM, Felix Meschberger wrote:
> Hi,
>
> On 26.01.2010 15:45, Justin Edelson wrote:
>
>> On 1/26/10 4:14 AM, Carsten Ziegeler wrote:
>>
>>> Felix Meschberger wrote:
>>>
>>>
>>>> Hi,
>>>>
>>>> On 25.01.2010 20:43, Justin Edelson wrote:
>>>>
>>>>
>>>>> 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 can assure you that you are not alone -- I am sitting in that very
>>>> same boat with you ;-)
>>>>
>>>>
>>> Then we are already three....
>>>
>>>
>>>
>> Well, the three of us and Bertrand are the only people who have
>> committed to bundles/scripting/jsp or bundles/scripting/jsp-taglib, so
>> this doesn't bode well :)
>>
>>>> I agree with you, that whis would be a really good thing --
>>>> unfortunately, I also have not found the ideal solution until now. There
>>>> are few workaround approaches, I can see right now:
>>>>
>>>> (1) Provide the sling variable as part of the<sling:defineObjects> tag
>>>> and then you can access the properties using EL:
>>>>
>>>> ${sling.jspHelloWorld}
>>>>
>>>>
>>>>
>> Hmmm. I may be missing something, but sling is an instance of
>> SlingScriptHelper.... I guess I could make ScriptHelper also implement a
>> Map backed by the Bindings object. Off to find a JSP book in my basement...
>>
> My bad - sorry for the confusion. I confused the two classes. I wanted
> to talk about the Bindings but used the SlingScriptHelper called "sling".
>
> For real scripting languages (like Groovy, ECMAScript, etc.) these
> bindings are just mapped into the global namespace and thus there is no
> need for a bingings variable.
>
> For JSP there is no such thing (AFAICT). So I would assume we just
> provide the bindings under a "good" name using<sling:defineObjects>,
> e.g. bindings (better names welcome).
>
Ah. This makes more sense. I'll give it a shot.
> The we could have
>
> ${bindings.jspHelloWorld}
>
> (if that works with EL, I hope so....)
>
> Regards
> Felix
>
Re: New BindingsValuesProvider interface and JSPs
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
On 26.01.2010 15:45, Justin Edelson wrote:
> On 1/26/10 4:14 AM, Carsten Ziegeler wrote:
>> Felix Meschberger wrote:
>>
>>> Hi,
>>>
>>> On 25.01.2010 20:43, Justin Edelson wrote:
>>>
>>>> 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 can assure you that you are not alone -- I am sitting in that very
>>> same boat with you ;-)
>>>
>> Then we are already three....
>>
>>
> Well, the three of us and Bertrand are the only people who have
> committed to bundles/scripting/jsp or bundles/scripting/jsp-taglib, so
> this doesn't bode well :)
>>> I agree with you, that whis would be a really good thing --
>>> unfortunately, I also have not found the ideal solution until now. There
>>> are few workaround approaches, I can see right now:
>>>
>>> (1) Provide the sling variable as part of the<sling:defineObjects> tag
>>> and then you can access the properties using EL:
>>>
>>> ${sling.jspHelloWorld}
>>>
>>>
> Hmmm. I may be missing something, but sling is an instance of
> SlingScriptHelper.... I guess I could make ScriptHelper also implement a
> Map backed by the Bindings object. Off to find a JSP book in my basement...
My bad - sorry for the confusion. I confused the two classes. I wanted
to talk about the Bindings but used the SlingScriptHelper called "sling".
For real scripting languages (like Groovy, ECMAScript, etc.) these
bindings are just mapped into the global namespace and thus there is no
need for a bingings variable.
For JSP there is no such thing (AFAICT). So I would assume we just
provide the bindings under a "good" name using <sling:defineObjects>,
e.g. bindings (better names welcome).
The we could have
${bindings.jspHelloWorld}
(if that works with EL, I hope so....)
Regards
Felix
Re: New BindingsValuesProvider interface and JSPs
Posted by Justin Edelson <ju...@gmail.com>.
On 1/26/10 4:14 AM, Carsten Ziegeler wrote:
> Felix Meschberger wrote:
>
>> Hi,
>>
>> On 25.01.2010 20:43, Justin Edelson wrote:
>>
>>> 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 can assure you that you are not alone -- I am sitting in that very
>> same boat with you ;-)
>>
> Then we are already three....
>
>
Well, the three of us and Bertrand are the only people who have
committed to bundles/scripting/jsp or bundles/scripting/jsp-taglib, so
this doesn't bode well :)
>> I agree with you, that whis would be a really good thing --
>> unfortunately, I also have not found the ideal solution until now. There
>> are few workaround approaches, I can see right now:
>>
>> (1) Provide the sling variable as part of the<sling:defineObjects> tag
>> and then you can access the properties using EL:
>>
>> ${sling.jspHelloWorld}
>>
>>
Hmmm. I may be missing something, but sling is an instance of
SlingScriptHelper.... I guess I could make ScriptHelper also implement a
Map backed by the Bindings object. Off to find a JSP book in my basement...
Justin
Re: New BindingsValuesProvider interface and JSPs
Posted by Carsten Ziegeler <cz...@apache.org>.
Felix Meschberger wrote:
> Hi,
>
> On 25.01.2010 20:43, Justin Edelson wrote:
>> 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 can assure you that you are not alone -- I am sitting in that very
> same boat with you ;-)
Then we are already three....
>
> I agree with you, that whis would be a really good thing --
> unfortunately, I also have not found the ideal solution until now. There
> are few workaround approaches, I can see right now:
>
> (1) Provide the sling variable as part of the <sling:defineObjects> tag
> and then you can access the properties using EL:
>
> ${sling.jspHelloWorld}
>
> (2) Provide a tag to access the properties:
>
> <sling:get name="jspHelloWorld" />
>
> IIRC the sling variable is already present as part of the
> <sling:defineObjects> tag.
>
I think we should go with the defineObjects tag.
Carsten
--
Carsten Ziegeler
cziegeler@apache.org
Re: New BindingsValuesProvider interface and JSPs
Posted by Felix Meschberger <fm...@gmail.com>.
Hi,
On 25.01.2010 20:43, Justin Edelson wrote:
> 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 can assure you that you are not alone -- I am sitting in that very
same boat with you ;-)
> 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.
I agree with you, that whis would be a really good thing --
unfortunately, I also have not found the ideal solution until now. There
are few workaround approaches, I can see right now:
(1) Provide the sling variable as part of the <sling:defineObjects> tag
and then you can access the properties using EL:
${sling.jspHelloWorld}
(2) Provide a tag to access the properties:
<sling:get name="jspHelloWorld" />
IIRC the sling variable is already present as part of the
<sling:defineObjects> tag.
WDYT ?
Regards
Felix
>
> 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
>