1
votes

I have a classic UI dialog. This has a drop down in dialog which has "true"/"false" as options

<mydropdown
      jcr:primaryType="cq:Widget"
      allowBlank="{Boolean}false"
      fieldLabel="My Dropdown"
      name="./dropdownValue"
      type="select"
      xtype="selection">
      <options jcr:primaryType="cq:WidgetCollection">
         <test
             jcr:primaryType="cq:Widget"
             text="True"
             value="true"/>
         <test_x0020_1
             jcr:primaryType="cq:Widget"
             text="False"
             value="false"/>
          <test_x0020_2
             jcr:primaryType="cq:Widget"
             text="someothervaluetext"
             value="someothervalue"
       </options>
</mydropdown>

The JCR structure is saving value as String "true", "false". When user edits the dialog, the value should be populated back in the field. "true", "false" value is not getting populated, while "someothervalue" works fine.

Checked the Selection.js in libs, code below is responsible to populating data in dialog

 var count = this.comboBox.store.getTotalCount();
 var i = 0;
 for (; i < count; i++) {
      var data = this.comboBox.store.getAt(i).data;
      if (data.value == this.value) {  // Here data.value is coming as boolean
             this.hiddenField.setValue(data.value);
             this.comboBox.setValue(data.text);
             break;
       }
  }

data.value is coming as boolean though in JCR the value is stored as string. Due to this the condition is evaluating to false and value is not set.

2

2 Answers

2
votes

The only issue I see is the value of the name property. Generally the name is prefixed with ./ so that the property and its corresponding value is set on the node. When the name doesn't start with ./ it is omitted.

Try this and it should work.

name="./dropdownValue"

Sling Post Servlet documentation explains more on how the Sling Post Servlet works.

0
votes

Checked with Adobe Day Care. Adobe confirmed, this is a bug in AEM 6.1. This has been fixed in AEM 6.2. Following is the granite bug reference

CQ-64223 - cq:Widget xtype=selection type=select cannot contains option with value "true" and "false"

For earlier versions, hotfix can be requested from Adobe. For my case "1", "0" works for me as I had to evaluate it with angular ng-if/ng-show