<text>
Value of list is $list.selectedValue.
Value of ref1 is $ref1.
Value of ref2 is $ref2.
Value of text is $text.
</text>
</template>
When you run the above template, what you see in the second step of the Wizard depends on the value chosen in the list box presented in the first step. For example, if the chosen value is "Optional macro 1," then you will receive the macro ref1 in the second step. Otherwise, you will receive the macro ref2. Although the same editor is used for both macros, note the difference in the labels, "Reference 1" and "Reference 2", as well as the changes in the Wizard output.
The following example shows the Wizard output in the case where "Optional macro 2" is chosen.
Figure 29. Optional Macro 2 choice
The output for this example is as follows:
Value of list is ref2.
Value of ref1 is null.
Value of ref2 is value2.
Value of text is text_value.
In the template, the screen numbered 20 was skipped because the only macro it contained, ref1, returned the value SKIP from the method getSkipStatus. The following code of the MyVarname Java class, represents the macro type for the macros ref1 and ref2.
import java.util.Hashtable;
import com.savvion.rulewizard.data.*;
import com.savvion.rulewizard.util.Debugger;
public class MyVarname extends MacroString {
String show_for_option = null;
public int getSkipStatus() {
if (show_for_option == null)
return NO_SKIP;
public void addProperty(String name, String value) {
super.addProperty(name, value);
if (name != null && name.equals("show_for_option"))
show_for_option = value;
}
public Hashtable getPropertiesToSave() {
Hashtable pts = super.getPropertiesToSave();
if (show_for_option != null)
pts.put("show_for_option", show_for_option);
return pts;
}
}
The addProperty and getPropertiesToSave methods just read and save the property show_for_option, which indicates which value of the option reference the macro should be present. The getSkipStatus method reads the value of the option reference and compares it to the value of the property show_for_option. If the values are equal, then the NO_SKIP value returns, meaning the macro is present. Otherwise, SKIP is returned, meaning the macro is invisible.