A script-enabled browser is required for this page to function properly.

Subclassing Objects Post-Construction

If you want to subclass Forms objects after construction, call the high-level object methods for subclassing, JdapiObject.createSubclassedChild() and JdapiObject.setSubclassParent(). The first method will create a new instance of the given object which is subclassed from it. This is similar to dragging/copying a Forms object in the Form Builder and selecting "subclass" (there is also a JdapiObject.clone() method which replicates the "copy" behavior). The second method will change the subclassing source of a given Forms object. This is analogous to opening the subclassing source dialog of an object in the Form Builder and changing it. Passing null to JdapiObject.setSubclassParent() will un-subclass the Forms object.

There are some additional supporting methods in the JdapiObject interface:

Note that it is not possible to subclass using generic types. To avoid exceptions being thrown, you must pass in an object of the appropriate type (however, the reference type can be generic), as the following code fragments illustrate (assuming all objects are created elsewhere).

  
Block myBlock = new Block(myForm, "BLOCK1", myOtherBlock); // legal 

Block myBlock = new Block(myForm, "BLOCK1", myPropertyClass); // legal

JdapiObject jo = new Block(myForm, "BLOCK_X"); 
Block myBlock = new Block(myForm, "BLOCK1"); 
myBlock.setSubclassParent(JO); // legal because JO is really a block

Block myBlock = new Block(myForm, "BLOCK1");
myBlock.setSubclassParent(myPropertyClass); // legal

Block myBlock = new Block(myForm, "BLOCK1", myCanvas); //ILLEGAL!
Block myBlock = new Block(myForm, "BLOCK1");
myBlock.setSubClassParent(myCanvas); //ILLEGAL!

JdapiObject JO = new Canvas(myForm, "CANVAS_X");
Block myBlock = new Block(myForm, "BLOCK1");
myBlock.setSubclassParent(JO); // ILLEGAL because JO is really a canvas