The class used to setup an applet-based DB access is, once again, MaxBase, but this time you must write a Java applet that instantiates it with the constructor:
MaxBase(MBAParam)
Everytime you will use the above constructor from within your applet, a new MaxBase frame will be created, and it will be physically detached from the browser (and the rest of the applet). The MBAParam object takes care of the customization of MaxBase, and it is usually built this way:
(This is NetRexx code, might be slightly different from Java)
m = MBAParam(); m.port = getParameter('port'); -- numeric, eg. "7000" m.addmodidel = getParameter('addmodidel'); -- "yes" or "no", -- if "yes" you can add / modify / delete records from the -- applet, default is "no"
m.password = getParameter('password'); -- optional m.host = getDocumentBase().getHost(); -- alphanumeric-numeric, -- eg. "localhost" or "192.34.35.100"
m.filter = getParameter('filter'); -- alphanumeric, eg. "name=m*" m.shown = getParameter('shown'); -- can be a number or "all" m.index = getParameter('index'); -- numeric, eg. "1" = first field
/* The following are triplets of numbers, R G B values (from 0 to 255); eg. 0 0 0 = black) All of them are optional. */
m.frameback = getParameter('frameback'); m.framefore = getParameter('framefore'); m.buttonback = getParameter('buttonback'); m.buttonfore = getParameter('buttonfore'); m.listback = getParameter('listback'); m.listfore = getParameter('listfore'); m.listselback = getParameter('listselback'); m.listselfore = getParameter('listselfore');
As you can see, all of the values with which MaxBase is initialized are taken from the applet parameters (which reside in the HTML code for the page).
Here is the code for a very simple, yet complete, applet that will launch a MaxBase instance:
/* WARNING: This is NetRexx code. Use the NetRexx Java preprocessor to compile it. Get NetRexx from http://www2.hursley.ibm.com/netrexx. It's free, it's smart, it's great! */
options binary nocrossref
import nrio.MaxBase -- Don't forget to add those to the classpath import nrio.MBAParam -- before compiling!
/* This is an example that will show you how to put MaxBase in a web page, letting remote users browse and peruse your DBs. */
class MBApplet extends Applet
method init l = Label("Please wait, Applet loading..", Label.CENTER) m = MBAParam() f = MaxBase
this.setLayout(BorderLayout()) this.add(BorderLayout.CENTER, l)
-- Setup the parameters needed to launch MaxBase. m.port = getParameter('port') m.addmodidel = getParameter('addmodidel') m.password = getParameter('password') m.host = getDocumentBase().getHost() m.filter = getParameter('filter') m.shown = getParameter('shown') m.index = getParameter('index') m.frameback = getParameter('frameback') m.framefore = getParameter('framefore') m.buttonback = getParameter('buttonback') m.buttonfore = getParameter('buttonfore') m.listback = getParameter('listback') m.listfore = getParameter('listfore') m.listselback = getParameter('listselback') m.listselfore = getParameter('listselfore')
f = MaxBase(m, URL("http://my_base_url/")) -- Launch MaxBase
/* What is the my_base_url URL? It is the base URL, in the web server, where the nrio directory is stored. MaxBase needs it to load toolbar and dialog icons. */ f.setVisible(1)
l.setText("Applet running..") -- Not needed, but..
The HTML file used to launch this applet could be like this:
<applet code="MBApplet.class" align="baseline" width="200" height="150"> <param name="host" value="your.host.dot.com"><param name="port" value="6789_is_the_default"></applet> |