opensubscriber
   Find in this group all groups
 
Unknown more information…

b : bsf-user@jakarta.apache.org 26 January 2007 • 12:32AM -0500

Re: declareBean() vs. registerBean() (Re: overhead of new BSFManager()
by Daling Xu

REPLY TO AUTHOR
 
REPLY TO GROUP




Hi Rony,
  
  Thank you for you assistance.
  
  I modified my code for the approach using manager.registerBean() :
  
  BSFManager manager = new BSFManager();
  manager.registerBean( "myBeanName", new MyBeanClazz("str for regBean");
  manager.exec( "javascript", "test", 0,0, "bsf.lookupBean(\"myBeanName\").myMethod();" );
  
  This time it works and printed out the string in the console. Thanks.
  
  It looks that the BSFManager defaultly declared a bean "bsf" so the script can always use it just like a predefined object in the javascript.
  
  But for my ObjectRegistery approach, even I tried to call bsf.lookupBean in the script code, it still doesn't work, anything still missing here?
  
  Linda
  
  

"Rony G. Flatscher" <Rony.Flatscher@wu-w...> wrote:
  Hi Linda,

there is a difference between declaring and registering a bean:
declareBean() tries to inform the BSF engine explicitly about the bean,
such - if supported by the language - that it gets implicitly defined
for the script, whereas declared beans need to be looked up by the
script before being able to use it.

Or with other words: have the script look-up the bean before using it.
E.g., in Javascript:

myBean = bsf.lookupBean ("myBean"); /* retrieve a registered Java
object */

HTH,

---rony




---------------------------------
Finding fabulous fares is fun.
Let Yahoo! FareChase search your favorite travel sites to find flight and hotel bargains.

Bookmark with:

Delicious   Digg   reddit   Facebook   StumbleUpon

Related Messages

opensubscriber is not affiliated with the authors of this message nor responsible for its content.