jakarta-bsf-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rony G. Flatscher" <Rony.Flatsc...@wu-wien.ac.at>
Subject Re: NetRexx 2.x / BSF2.3 issue getting "current" BSFManager instance...
Date Thu, 09 Jan 2003 23:05:16 GMT
Keith:

>... from within the Rexx script.  The problem seems to be that
>when I call into (BSFManager.exec() or BSFManager.eval(); they
>seem to act the same in this respect) the script, the only way I
>can figure to get a valid reference to a BSFManager is to instantiate
>one within the script, which, of course, doesn't know beans about the
>Java classes  I've painstakingly tried to expose to the script.
>
Hmm, in the samples of the IBM forerunner of BSF there is a short 
example with NetRexx:

------------------------------------------- cut here 
--------------------------------------
/* pick up the center panel bean */
p = java.awt.Panel bsf.lookupBean("centerPanel");

/* set the layout manager to border */
p.setLayout(java.awt.BorderLayout());

/* add a few things */
p.add("Center", java.awt.Label("Middle from NetRexx"));
p.add("North", java.awt.TextField("north text from NetRexx"));
p.add("South", java.awt.TextField("south text from NetRexx"));
p.add("East", java.awt.Button("inner east from NetRexx"));
p.add("West", java.awt.Button("inner west from NetRexx"));

/* configure p a bit */
p.setBackground(java.awt.Color(255, 0, 0));

/* configure the frame that p is in */
f = java.awt.Frame p.getParent();
f.setTitle("Hello from NetRexx (title reset from NetRexx)");
------------------------------------------- cut here 
--------------------------------------

So the called NetRexx program seems to have the object "bsf" implicitly 
available to
it and able to use it for lookup purposes.

---

Here's a version of pure Rexx (runs e.g. with the free and open source 
Regina Rexx interpreter on any of its many platforms (cf. 
<http://regina-rexx.sourceforge.net>) using 'bsf4rexx' (this interface 
requires to denote the needed datatypes explicitly), a trailing comma 
indicates that the statement continues on the next line:

------------------------------------------- cut here 
--------------------------------------
/* to be put: "samples/scriptedui/ui.rex"    */
/* pick up the center panel bean, Rexx program modelled after ui.nrx */
p = bsf("lookupBean", "centerPanel")

/* set the layout manager to border */
call bsf "invoke", p, "setLayout", "obj", bsf("registerBean", "", 
"java.awt.BorderLayout")

/* add a few things */
call bsf "invoke", p, "add", "str", "Center", "obj",,  
         bsf("registerBean", "", "java.awt.Label", "str", "Middle from 
Rexx")
call bsf "invoke", p, "add", "str", "North", "obj",,
         bsf("registerBean", "", "java.awt.Label", "str", "North text 
from Rexx")
call bsf "invoke", p, "add", "str", "South", "obj",,
         bsf("registerBean", "", "java.awt.Label", "str", "South from Rexx")
call bsf "invoke", p, "add", "str", "East", "obj",,
         bsf("registerBean", "", "java.awt.Label", "str", "Inner east 
from Rexx")
call bsf "invoke", p, "add", "str", "West", "obj",,
         bsf("registerBean", "", "java.awt.Label", "str", "Inner west 
from Rexx")

/* configure p a bit */
call bsf "invoke", p, "setBackground", "obj", bsf("getStaticValue", 
"java.awt.Color", "yellow")

/* configure the frame that p is in */
f = bsf("invoke", p, "getParent")
call bsf "invoke", f, "setTitle", "str", "Hello from REXX (title reset 
from Rexx)"
------------------------------------------- cut here 
--------------------------------------



Here's a version of the object-oriented version of Rexx as produced by 
IBM (free for Linux
and included in OS/2 Warp resp. eComStation, trial packages for the 
Windows version)
(cf. <http://www.software.ibm.com/ad/obj-rexx/>), the message operator 
is the tilde (~):

------------------------------------------- cut here 
--------------------------------------
/* to be put: "samples/scriptedui/ui-oo.rex"    */
/* pick up the center panel bean, Object Rexx program modelled after 
ui.nrx */
p = .bsf~lookupBean("centerPanel")

/* set the layout manager to border */
p~setLayout("obj", .bsf~new("java.awt.BorderLayout"))

/* add a few things */
p~add("str", "Center", "obj", .bsf~new("java.awt.Label", "str", "Middle 
from Object Rexx"))
p~add("str", "North",  "obj", .bsf~new("java.awt.Label", "str", "North 
text from Object Rexx"))
p~add("str", "South",  "obj", .bsf~new("java.awt.Label", "str", "South 
text from Object Rexx"))
p~add("str", "East",   "obj", .bsf~new("java.awt.Label", "str", "Inner 
east text from Object Rexx"))
p~add("str", "West",   "obj", .bsf~new("java.awt.Label", "str", "Inner 
west text from Object Rexx"))

/* configure p a bit */
p~setBackground("obj", .bsf~getStaticValue("java.awt.Color", "green"))

/* configure the frame that p is in */
f=p~getParent
f~setTitle("str", "Hello from Object REXX (title reset from Object Rexx)")

::requires "BSF.cls"    -- get Object Rexx wrapper support for BSF
------------------------------------------- cut here 
--------------------------------------

More on Rexx can be found at: <http://www.RexxLA.org>.

---

I am in the process of enhancing and cleaning up "bsf4rexx" (cf. 
<http://wi.wu-wien.ac.at/rgf/rexx/orx12/JavaBeanScriptingWithRexx_orx12.pdf>) 
for the IBM version of BSF first (so it can be used wherever the IBM 
version is deployed) and will then port it to Apache, giving it the 
Apache license, such that that the Rexx support can be included into the 
Apache distribution together with the Regina interpreter.

Hope that helps a little,

---rony





Mime
View raw message