You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bsf-user@jakarta.apache.org by mario nee <ma...@xmoon.org> on 2005/02/28 18:25:47 UTC
loose reference
Hello, when i try this code
v = new Vector();
bsfManager.declareBean("v", v, v.getClass());
test_code = "v = new Vector(); v.addElement(\"001\"); print(v.size());";
bsfManager.exec("beanshell", "(java)",1,1,test_code);
bsfManager.lookupBean("v")
v is an empty Vector instead of a vector with 1 element.
Why ?
---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-user-help@jakarta.apache.org
Re: loose reference
Posted by mario nee <ma...@xmoon.org>.
ok, thank you.
Greetings, Mario Neè
Rainer Hahnekamp wrote:
>Hi,
>
>I think the problem is that you initialize a new Vector object in Java
>named v and another Vector in Beanshell which is also named v. Finally
>you end up having two different objects having just the same name. If
>you want to fill the "Java" v your code should look like this:
>
>test_code = "v = bsf.lookupBean(\"v\"); v.addElement(\"001\");
>print(v.size());"
>
>Now the v object outside of BSF should have one element.
>
>Greetings,
>-Rainer Hahnekamp
>
>Am Montag, den 28.02.2005, 18:25 +0100 schrieb mario nee:
>
>
>>Hello, when i try this code
>>
>>
>>v = new Vector();
>>bsfManager.declareBean("v", v, v.getClass());
>>test_code = "v = new Vector(); v.addElement(\"001\"); print(v.size());";
>>bsfManager.exec("beanshell", "(java)",1,1,test_code);
>>bsfManager.lookupBean("v")
>>
>>v is an empty Vector instead of a vector with 1 element.
>>Why ?
>>
>>---------------------------------------------------------------------
>>To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
>>For additional commands, e-mail: bsf-user-help@jakarta.apache.org
>>
>>
>>
>>
>
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
>For additional commands, e-mail: bsf-user-help@jakarta.apache.org
>
>
>
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-user-help@jakarta.apache.org
Re: loose reference
Posted by Rainer Hahnekamp <Ra...@aon.at>.
Hi,
I think the problem is that you initialize a new Vector object in Java
named v and another Vector in Beanshell which is also named v. Finally
you end up having two different objects having just the same name. If
you want to fill the "Java" v your code should look like this:
test_code = "v = bsf.lookupBean(\"v\"); v.addElement(\"001\");
print(v.size());"
Now the v object outside of BSF should have one element.
Greetings,
-Rainer Hahnekamp
Am Montag, den 28.02.2005, 18:25 +0100 schrieb mario nee:
> Hello, when i try this code
>
>
> v = new Vector();
> bsfManager.declareBean("v", v, v.getClass());
> test_code = "v = new Vector(); v.addElement(\"001\"); print(v.size());";
> bsfManager.exec("beanshell", "(java)",1,1,test_code);
> bsfManager.lookupBean("v")
>
> v is an empty Vector instead of a vector with 1 element.
> Why ?
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: bsf-user-help@jakarta.apache.org
>
>
---------------------------------------------------------------------
To unsubscribe, e-mail: bsf-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: bsf-user-help@jakarta.apache.org