Important: please read about multi-user issues if you haven't already done so.

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');
m.host = getDocumentBase().getHost(); -- alphanumeric-numeric,
         		-- eg. "localhost" or "192.34.35.100"
m.filter = getParameter('filter'); -- alphanumeric, eg. "name=m*"
m.showed = getParameter('showed'); -- 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)*/
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: (it also shows how to expand MaxBase features)

/*
    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!
import nrio.MBPlugin

/*
   This is an example that will show you how to put MaxBase
   in a web page, letting remote users browse and peruse
   your DBs. It will show also how to expand MaxBase by means
   of the new (appeared in 1.11) PluginFactory technique.
*/

class MBApplet extends Applet implements MBPlugin

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.showed = getParameter('showed')
 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) -- Launch MaxBase

 f.setPluginFactory(this) -- We (the applet) are going to expand MaxBase feature set.

 l.setText("Applet running..") -- Not needed, but..



/*
   Whenever the user enters a panel, MaxBase calls this routine,
   passing it (as the parameter) the name of the menu that's going
   to be displayed. We will add a button, named "test", to the
   main menu.
*/

method sendMenu(sMenu = String) returns String[]
 s = String[]

 if sMenu = "main" then
 do
  s = String[1]
  s[0] = "test"
  return s
 end
 else
  return null


/*
   When the user presses the "test" button in the main menu,
   MaxBase notifies us. We are going to write a line in the
   console when this happens.
*/

method pluginLaunch(sTextLabel = String)
  if sTextLabel = "test" then 
   say sTextLabel

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>


Max Marsiglietti © 1997
Layout and artwork Andrea Resmini 1997