Select value from xtype selection type checkbox CQ

2019-07-18 07:24发布

问题:

Hello I am running an issue right now. I would like to make the checkbox state: checked but I could not make the defaultValue="value"

<channels jcr:primaryType="cq:Widget" fieldLabel="Channels"
                defaultValue="Value" name="channels" options="/bin/sample/private/getJSON.json"
                 optionsValueField="Value" type="checkbox" xtype="selection">

I have tried to do this: Getting Default Checked Checkbox in CQ5

but it didn't solve the issue.

回答1:

This is an example of what I have used to set the default state of the checkbox as 'checked'. Take note of defaultValue="true"

<channels
   jcr:primaryType="cq:Widget"
   fieldLabel="Channels"
   name="channels"
   type="checkbox"
   defaultValue="true"
   xtype="selection"/>


回答2:

Try writing it this way.

<channels jcr:primaryType="cq:Widget" 
          fieldLabel="Channels"
          defaultValue="{Boolean}true" 
          name="channels" options="/bin/sample/private/getJSON.json"
          optionsValueField="Value" 
          type="checkbox" 
          xtype="selection">


回答3:

the issue you refer to is to create the checkbox using js / json. if you look at what is actually getting stored in the JCR you will see that the value against a checkbox is not actually a boolean, but is a string. which can be true / flase, or on / off if the item is inside a checkboxgroup.

In your case, to make it automatically checked in your dialog.xml file you need to use checked="true".



标签: adobe aem