CAPDM Tutorial Applets |
Remote Control using JavaScriptVersion information for this applet can be displayed. Examples |
The applet can be invoked by embedding an APPLET tag into your HTML document (if you look at the source of this document you will see a working example you can copy). The table below details the basic parameters used and additional startup parameters that are specific to this applet.
<APPLET CODEBASE="../../../../classes" ALT="Portfolio Management" CODE="applet.capdm.finance.portfoliomanagement.PortfolioManagementApp" NAME="PortfolioManagement" WIDTH="400" HEIGHT="500"> </APPLET>
| Basic Parameters | Use |
| CODEBASE="../../../../classes" | The CODEBASE of the applet must point at the top-level classes directory in order for the applet to be found. |
| CODE="applet.capdm.finance. portfoliomanagement.PortfolioManagementApp " |
This required attribute gives the name of the file that contains the applet's compiled Applet subclass. This file is relative to the base URI of the applet. |
| ALT="Portfolio Management" | This optional attribute specifies any text that should be displayed if the browser understands the APPLET tag but can't run Java applets. |
| NAME="PortfolioManagement" | This optional attribute specifies a name for the applet instance, which makes it possible for applets on the same page to find (and communicate with) each other. If you intend to use JavaScript/Applet scripting then the applet must be named as shown. |
| WIDTH="400" HEIGHT="500" | These required attributes give the initial width and height (in pixels) of the applet display area, not counting any windows or dialogs that the applet brings up. |
| Applet Startup Parameters | Use |
For more information on the use of the APPLET tag and other attributes you can use but which are not listed above, visit the W3.org specification page at: APPLET tag in HTML 4.
This applet can be called into using Javascript 1.1 while running. Although JavaScript can call the Applet directly, some convenient JavaScript functions have been created which deal with the details of the communication. The following table lists the call Names which can be made, and gives examples of their use and results.
| API Call Name | Parameters | Use and Result |
| setValue(name,value) | 'name' can be one of "CurrentValueA", "CurrentValueB", "InvestA", "InvestB", "AssetAValue1", "AssetAValue2", "AssetAValue3", "AssetAValue4", "AssetAValue5", "AssetBValue1", "AssetBValue2", "AssetBValue3", "AssetBValue4", "AssetBValue5" 'value' is its new value |
Used to set the value of an independent variable in the applet. Note that InvestA and InvestB are interdependent. Setting InvestA to 55 will also change InvestB to 45 - they must add up to 100% |
| setProbabilities(val1, val2, val3, val4, val5) | 'val1' is the probability value for the first value. val2, val3, val4, val5 are the probability values for the others |
Used to set the interdependent probability values. All values are probabilities and should add up to 1 to make sense. |
| getValue() | none | javascript:document.PortfolioManagement.getValue();
Gets the status of the applet |
| getValue(name) |
'name' can be one of "CurrentValueA", |
Returns the current value of the variable from the applet. |
| getValue(name,dp) | 'name' can be one of "CurrentValueA", "CurrentValueB", "InvestA", "InvestB", "AssetAValue1", "AssetAValue2", "AssetAValue3", "AssetAValue4", "AssetAValue5", "AssetBValue1", "AssetBValue2", "AssetBValue3", "AssetBValue4", "AssetBValue5", "Probability1", "Probability2", "Probability3", "Probability4", "Probability5". 'dp' is the number of decimal places of accuracy required |
javascript:getValue("InvestA",45);
Gets the current value of the variable as a string to the number of decimal
places specified |
| showAbout() | none | javascript:showAbout(); Shows the version dialog
box of this applet. |
| reset() | none | javascript:reset(); resets the applet to initial
starting position |