| Extending MaxBase using non-default add and modify panels is quite simple, requiring just a bit of practice and understanding of the mechanism that lets you pass data to and from a MaxBase instance. This is the diagram describing the relationship between MaxBase and your Add & Modify panels (explanations below). externalAddModiis a MaxBase property that lets you tell MaxBase which external add & modify panels to use. An add & modify panel is basically an object (often of type java.awt.Frame) that implements the nrio.AMInterface interface. If the externalAddModi property of a MaxBase instance is not set to NULL, whenever an user chooses to add or modify a record, MaxBase will tell your class to kick in and get the user input. If, on the contrary, externalAddModi is set to NULL, MaxBase will use its own GUI to let the user add/modify records. Note: you can set and get the externalAddModi property of MaxBase by using the void setExternalAddModi(AMInterface am) and AMInterface getExternalAddModi(void) methods of MaxBase, or by creating a MaxBase instance with the following constructor: MaxBase(String DbName, String[] resources, LPInterface LP, AMInterface AM) After you have told MaxBase which class of yours (implementing AMInterface) will play externalAddModi, whenever an user presses the "add record" or "modify record" buttons, MaxBase will call your class addRecord or modiRecord methods, as below: Notes: First off, MaxBase doesn't put your class on the foreground, nor will make it visible. That's up to you, at your convenience. As of this release, also, you will be sent only one record at a time to be modified. Finally, when your application has finished gathering the user's input, it must call MaxBase methods externAddStore or externModiStore, depending on whether it was a matter of adding or modifying records, of course, as is shown below: That's it! Now let's get to the description of the methods we introduced here above. The methods required by nrio.AMInterface are: void addRecord(String[][] sRecordStr, String[][] sRecordVal, LPInterface LPfather, MaxBase MBInstance) The above method gets called when the user chooses "add record" from the MaxBase user interface. The parameters passed are:
| sRecordStr is the record structure (String double array):
| [0, 0] is the number of fields which are being passed.
| [i, 0] max. length of the "i"-th field.
| [i, 1] name of the "i"-th field.
| [i, 2] indexing of the "i"-th field.
| sRecordVal contains the actual record values (String double array):
| [0, 1] contains the number of records passed.
| [i, j] is the record j, field i.
Note: At this time, MaxBase only lets you add or modify one record at a time, so the only meaningful value for j in this method is 1. Of course, your add & modify panel could prompt the user for new records until the user hits some kind of 'cancel' button and send them one by one to MaxBase as they are entered. Note2: You may ask 'why should I get empty values from MaxBase? Can't I just build my own string array to store my data?'. Well, I did that so you can get the values from MaxBase, fill them with the data that the user will provide and then send the sRecordVal object back to MaxBase (with the ExternAddStore MaxBase method). Less work on your side. MBInstance is the MaxBase instance that called our add & modify panel. Needed, because you need to know where to send the data entered by the user. LPFather is an instance of an object of type LPInterface (see below) void modiRecord(String[][] sRecordStr, String[][] sRecordVal, LPInterface LPfather, MaxBase MBInstance) This method is similar to addRecord, but in sRecordVal you will find the actual data to modify. Note: in case the user selected more than one record, you will be passed one record at a time, meaning that modiRecord will be called more than once (each time you call back externModiStore, another record will be sent to your class for modification, until all the records have been modified). Adding or modifying MaxBase records is done by calling the following MaxBase methods: void externAddStore(String[][] sAddArr) This method is used to externally add records to a database represented by a MaxBase instance. The parameter matches the sRecordVal parameter of the addRecord method of the AMInterface class. void externModiStore(String[][] sModiArr) This method is used to modify records in a database (represented by a MaxBase instance). The parameter matches the sRecordVal parameter of the modiRecord method of the AMInterface class. Note: you can call MaxBase methods externAddStore and externModiStore without MaxBase having called your class addRecord or modiRecord methods, but if you plan to do so, be warned that in order to process external requests MaxBase requires that its externalAddModi property is not NULL. Note 2: of course, since addRecord and modiRecord do pass a reference to the MaxBase instance to your class, you can also call MaxBase methods other than externAddStore and externModiStore at your convenience. Note 3: (only valid for record modifying) the [0][0] position of the array must be set to one of the MBIOComponent data entry result values (OK, STAY, ABORT, OKSTAY).