Example setMethod()

The main goal of this example is to show how to use the InterWidgetCommunication method setMethod(). This example uses a line plot (Plot1), a function button (Button1), and two radio buttons. One of the radio buttons sets the href method of Button1 to disappear() and the other one sets the href method of Button1 to reappear(). Button1 has an href function that makes Plot1 disappear or reappear, depending on Button1's href method set by the radio buttons. Plot1 is receiving a random byte as its input. Here is a snapshot of what the html page looks like in a "WYSIWYG" tool:


Figure 1.

To create a lineplot named Plot1 that uses a random byte as its input, the following is used:

<APPLET CODE="LinePlot.class" WIDTH="129" HEIGHT="77" NAME="Plot1">
<PARAM NAME="href" VALUE="Amulet:math.randomByte.value()">
<PARAM NAME="yMin" VALUE="0">
<PARAM NAME="yMax" VALUE="255">
<PARAM NAME="xSamples" VALUE="16">
<PARAM NAME="lineWeight" VALUE="5">
<PARAM NAME="updateRate" VALUE=".5">
< /APPLET>

Plot1 updates every 500ms, getting a random byte that is generated internally by using the href function Amulet:math.randomByte.value().

To create a function button named Button1 that makes Plot1 disappear/reappear when hit, the following is used:

<APPLET CODE="FunctionButton.class" WIDTH="56" HEIGHT="25" NAME="Button1">
<PARAM NAME="href" VALUE="Amulet:document.Plot1.disappear()">
<PARAM NAME="fontSize" VALUE="3">
<PARAM NAME="fontStyle" VALUE="plain">
<PARAM NAME="label" VALUE="action">
<PARAM NAME="onButtonPress" VALUE="depress">
< /APPLET>

Unless one of the radio buttons created below changes the method of Button1, when Button1 is hit, Plot1's method disappear() will be invoked, thus causing Plot1 to remove itself from the LCD.

To create the two Radio Buttons that set the Button1 href method to reappear() or disappear(), the following is used:

<APPLET CODE="RadioButton.class" WIDTH="150" HEIGHT="22" NAME="RB1">
<PARAM NAME="href" VALUE="Amulet:document.Button1.setMethod()">
<PARAM NAME="fontSize" VALUE="2">
<PARAM NAME="fontStyle" VALUE="PLAIN">
<PARAM NAME="buttonValue" VALUE="disappear()">
<PARAM NAME="buttonAlignment" VALUE="left">
<PARAM NAME="label" VALUE="disappear">
<PARAM NAME="groupName" VALUE="actionRB">
<PARAM NAME="initialCondition" VALUE="on">
</APPLET>

<APPLET CODE="RadioButton.class" WIDTH="150" HEIGHT="22" NAME="RB2">
<PARAM NAME="href" VALUE="Amulet:document.Button1.setMethod()">
<PARAM NAME="fontSize" VALUE="2">
<PARAM NAME="fontStyle" VALUE="PLAIN">
<PARAM NAME="buttonValue" VALUE="reappear()">
<PARAM NAME="buttonAlignment" VALUE="left">
<PARAM NAME="label" VALUE="reappear">
<PARAM NAME="groupName" VALUE="actionRB">
<PARAM NAME="initialCondition" VALUE="off">
</APPLET>

When the radio buttons are selected, Plot1 is not affected. They invoke Button1's method setMethod() with the buttonValue of the radio button selected being the argument that is passed. When Button1 is hit, the href function will look like either Amulet:document.Plot1.disappear() or Amulet:document.Plot1.reappear(), depending upon which radio button is selected.

NOTES:



Amulet HTMLCompiler,
Copyright © 2000-2004 by
Amulet Technologies, LLC

Back to Welcome - Contact Amulet - Amulet Home