Select value from xtype selection type checkbox CQ5

我的梦境 提交于 2019-12-12 21:21:17

问题


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".



来源:https://stackoverflow.com/questions/17105886/select-value-from-xtype-selection-type-checkbox-cq5

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!