FIX ATDL - StateRule for checkbox with atdl4j

Hi,

I have the following code in an ATDL file:

<lay:Control ID = “c_LongShortBalanced” xsi:type = “lay:RadioButton_t” label = “Long-short Balanced” initValue = “true” radioGroup = “Balance”/>

<lay:Control label=“Enforce Sector Balance” parameterRef=“EnforceSectorBalance” ID=“c_EnforceSectorBalance” xsi:type=“lay:CheckBox_t” checkedEnumRef=“checked” uncheckedEnumRef=“unchecked”>
<flow:StateRule enabled = “true” value = “unchecked”>
<val:Edit field = “c_LongShortBalanced” operator = “EQ” value = “true”/>
</flow:StateRule>
</lay:Control>

I have checked this against the ATDL guide and cannot find anything wrong with the code, yet if I include the StateRule section, the atdl4j program crashes when i try to load the file. I have other StateRules with the same controlling element (a radio button, see above), that work fine. I have tried all combinations of value = checked/unchecked, enabled = true/false and nothing works.

I am wondering if this is a bug in atd4j (as I have seen a post from '13 that references another bug for checkboxes) and if anyone else has experienced this issue. Unfortunately I do not have other ATDL rendering programs available to check this.

Any help much appreciated.

Hugo,

The core issue is that you need to specify initValue on your CheckBox_t control.

I agree that atdl4j is not capturing/displaying the error encountered very well at all (blows up with a stack trace). I helped develop the atdl4j open source implementation back in 2010.

I got your snippet to work (after trial-and-error determining missing initValue attribute as core issue). See full xml below:

<?xml version="1.0" encoding="utf-8"?>

lay:StrategyLayout
<lay:StrategyPanel collapsible=“false” orientation=“HORIZONTAL” title=“Test Case”>
<lay:Control ID=“c_SomeOtherRBState” xsi:type=“lay:RadioButton_t” label=“SomeOtherRBState” initValue=“false” radioGroup=“Balance”/>
<lay:Control ID=“c_LongShortBalanced” xsi:type=“lay:RadioButton_t” label=“Long-short Balanced” initValue=“true” radioGroup=“Balance”/>

	  <lay:Control ID="c_EnforceSectorBalance" xsi:type="lay:CheckBox_t" label="Enforce Sector Balance" initValue="false" parameterRef="EnforceSectorBalance" checkedEnumRef="checked" uncheckedEnumRef="unchecked">
      <flow:StateRule enabled = "true" value = "unchecked">
        <val:Edit field="c_LongShortBalanced" operator="EQ" value="true"/>
      </flow:StateRule>
  </lay:Control>
    
	  </lay:StrategyPanel>
	</lay:StrategyLayout>
</Strategy>

Sorry for double-post. The XML I pasted did not render well in the forum. I’ve attached the XML as an uploaded image.

Thanks Scott. However I had already tested this and have tried it again today. Both with the values checked/unchecked and true/false.

Commenting out just the StateRule section allows the atdl4j program to run and render the file.