Vladimir Vivien wrote:
> Ludovic,
> Lookup documentation for the BSFManager. Beanshell manager will allow you
> to register objects that are passed to the scripting language (as long as
Vladimir,
As I said before, I cannot use declareBean, because java objects are created
dynamically. In the Groovy example below, there is a mecanism to intercept
the get() method of the scripting language objects. But I cannot find one
in BSF (e.g. instead of throwing a "name error" in jython, my custom get()
method should be called to try to return an object external to the interpreter).
Any ideas ?
Ludovic.
> On 4/14/07, Ludovic Drolez <
ldrolez@...> wrote:
>
>>
>> Hi !
>>
>> I'm currently trying to add BSF+Jython support in the ZK framework
>> (www.zkoss.org). To make this I need to have a method called, each
>> time the scripting language tried to get the value of a variable.
>>
>> For example the Groovy support in ZK is done this way:
>>
>> =======================================
>> import groovy.lang.Binding;
>> import groovy.lang.GroovyShell;
>> ...
>> public void init(Page owner, String zslang) {
>> super.init(owner, zslang);
>>
>> _global = new Binding(new Variables());
>> _ip = new GroovyShell(_global);
>> }
>> //An inner class of GroovyInterpreter
>> private class Variables extends HashMap {
>> public Object get(Object key) {
>> Object val = super.get(key);
>> if (val != null || containsKey(key) || !(key instanceof String))
>> return val;
>> return getFromNamespace((String)key); //provided by
>> GenericInterpreter
>> }
>> }
>> =======================================
>> (More can be read here:
>>
http://www.zkoss.org/smalltalks/addinterpreter/addinterpreter.dsp)
>>
>> So with groovy, you can register an 'object container' to intercept
>> accesses. If the object is already set in the scripting language, then
>> return it, but if it is not set, it tries to return a ZK object with the
>> same name (using the ZK method getFromNamespace()).
>>
>> I do not see how it could be done with BSF. I cannot register new BSF
>> Beans,
>> because, new ZK objects can be created at any time, so I do not know
>> their
>> names to register them. I need something dynamic, something which is
>> called
>> just before the scripting language tried to use an object.
>>
>> Did I miss something in BSF, or do I need to use the Jython API instead ?
>>
>> Best regards,
>>
>> --
>> Ludovic Drolez.
>>
>>
http://zaurus.palmopensource.com - The Zaurus Open Source Portal
>>
http://www.drolez.com - Personal site - Linux and PalmOS stuff
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail:
bsf-user-unsubscribe@...
>> For additional commands, e-mail:
bsf-user-help@...
>>
>>
>
--
Ludovic Drolez.
http://zaurus.palmopensource.com - The Zaurus Open Source Portal
http://www.drolez.com - Personal site - Linux and PalmOS stuff
---------------------------------------------------------------------
To unsubscribe, e-mail:
bsf-user-unsubscribe@...
For additional commands, e-mail:
bsf-user-help@...