Introduction to exporting a POD to M-Business JavaScript engine

M-Business JavaScript engine code on HTML pages in M-Business Client can call native code in M-Business client extension API (PODS). Any POD can export objects to M-Business JavaScript engine, and M-Business JavaScript engine code can call avantgo.createObject() to get an object exported by a POD. When JavaScript code invokes a method on a PODS object or reads or writes one of the PODS object's properties, M-Business Anywhere client calls native code in the POD that implemented the object.

The avantgo.createObject() method is part of the PODS system code that is exported to JavaScript and it is available automatically to JavaScript authors. However, in order for avantgo.createObject() to vend objects from your POD, you must do the following:

  • Implement a PODSObjectSrc instance and register it with the PODSObjectMgr. The objectForName() method of the PODSObjectSrc is used by avantgo.createObject(). You do this to make avantgo.createObject() vend your object. See Implementing a PODSObjectSrc instance.

  • Implement getMethod() on the object returned by objectForName(). You do this to make calling methods on your vended object work from JavaScript. See Implementing getMethod( ).

  • Register objects and strings that you do not want to have your object or object source manage directly, so that the memory they use can be freed when no longer needed. See Registering strings and objects to be freed.

  • Optionally, implement a PODSArray instance, if you want to pass array data between PODS methods and M-Business JavaScript engine. See Passing array data between PODS methods and M-Business JavaScript engine.

    Note

    These steps are necessary when you want to vend objects, not when you want to get objects vended by some other POD.

For instructions on accessing your POD from JavaScript, once you have completed the tasks outlined in this chapter, refer to the M-Business Channel Developer Guide section titled Using PODS functions from JavaScript engine. For an example of a POD that vends an object to JavaScript, see ObjectSrc sample: vending objects to JavaScript.