Hi,
Can you package up a test project demonstrating this?
Justin
On 11/29/10 1:53 PM, Levine, David wrote:
> Thanks, Bertrand.
>
> It is odd: my BindingsValuesProvider implementing class is in a separate OSGi
> bundle from the Velocity bundle, and it is defined as a service. I can see
> it in the Felix console - it has a Service ID assigned to it and a Component
> ID. So I would think this is a good thing. But I'm not seeing the binding
> in the scripts.
>
> My class is fairly simple:
>
> /*
> * @scr.component immediate="true" metatype="no"
> * @scr.service
> *
> * @scr.property name="service.description" value="Test Bindings"
> * @scr.property name="service.vendor" value="CU"
> *
> * @scr.property name="javax.script.name" value="any"
> */
> public class CUBindingsValuesProvider implements BindingsValuesProvider {
> public void addBindings(Bindings bindings) {
> bindings.put("testData","Hello world");
> }
> }
>
> In my Velocity template I attempt to access it via ${testData} and in JSP I
> attempt to access it via <c:out value="${bindings.testData}"/> but nothing
> shows up in either case.
>
> I have the "javax.script.name" property set to "any", similar to the
> CurrentNodeBindingsValuesProvider example on the wiki. I tried removing the
> property entirely (in case "any" is the incorrect way of specifying this...
> although this is what is done on the wiki page) but it did not help.
>
> --David
>
>
> -----Original Message-----
> From: Bertrand Delacretaz [mailto:[email protected]]
> Sent: Monday, November 29, 2010 1:02 PM
> To: [email protected]
> Subject: Re: BindingValuesProvider
>
> Hi David,
>
> On Mon, Nov 29, 2010 at 6:28 PM, Levine, David <[email protected]> wrote:
>> ...I'd like to now take this a step further and add a few additional
>> scripting variables
>> as discussed here:
>> https://cwiki.apache.org/SLING/adding-new-scripting-variables.html
>>
>> So I want to create a class which implements the BindingsValuesProvider
>> interface. OK...
>> but what do I do with it once I create it?...
>
> There are a few examples in [1] that are used in integration tests [2].
>
> No configuration is needed - all active OSGi services which implement
> BindingsValuesProvider are used by script engines, and the
> javax.script.name service property can be used to restrict them to a
> specific script engine. I guess the value of that would be "velocity"
> in your case, haven't checked.
>
> -Bertrand
>
> [1]
> http://svn.apache.org/repos/asf/sling/trunk/launchpad/test-services/src/main/java/org/apache/sling/launchpad/testservices/scripting
>
> [2]
> http://svn.apache.org/repos/asf/sling/trunk/launchpad/integration-tests/src/main/java/org/apache/sling/launchpad/webapp/integrationtest/ScriptBindingsValuesProviderTest.java
>
> ***
> Scanned
>
> **
> This e-mail message is intended only for the designated recipient(s) named
> above. The information contained in this e-mail and any attachments may be
> confidential or legally privileged. If you are not the intended recipient,
> you may not review, retain, copy, redistribute or use this e-mail or any
> attachment for any purpose, or disclose all or any part of its contents. If
> you have received this e-mail in error, please immediately notify the sender
> by reply e-mail and permanently delete this e-mail and any attachments from
> your computer system.