Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ssl/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Aem 在CQ5中获取默认选中复选框_Aem - Fatal编程技术网

Aem 在CQ5中获取默认选中复选框

Aem 在CQ5中获取默认选中复选框,aem,Aem,我试图在编辑组件对话框时选中默认复选框。以下是该字段的属性: jcr:primaryType: widget checked: true (boolean) *Documentation says this determines default checked status type: checkbox (string) *read this as a fix to making checkbox selections stick xtype: selection (string) name:

我试图在编辑组件对话框时选中默认复选框。以下是该字段的属性:

jcr:primaryType: widget
checked: true (boolean) *Documentation says this determines default checked status
type: checkbox (string) *read this as a fix to making checkbox selections stick
xtype: selection (string)
name: ./foo (string)
fieldValue: true (string)
是的,它看起来有点不稳定。我做了一些实验,这些特性的组合对我很有用:

defaultValue (String) true
fieldLabel (String) Foo Mode
inputValue (String) false
jcr:primaryType (Name) cq:Widget
name (String) ./foomode
type (String) checkbox
xtype (String) selection
defaultValue属性似乎是键


您的主要类型确实有cq:Widget,而不是Widget,是吗?

要将其保存为布尔值

<nodeName
jcr:primaryType="cq:Widget" 
fieldLabel="check this nodename" 
name="./nodeName" 
defaultValue="{Boolean}false" 
type="checkbox"
xtype="selection" />

<nodeNameHint
  jcr:primaryType="cq:Widget"
  ignoreData="{Boolean}true"
  name="./nodeName@TypeHint"
  value="Boolean"
  xtype="hidden"/>

要设置默认值为checked的复选框,并将属性保存为JCR中的布尔属性类型(而不是字符串),请使用以下经典UI设置:

<myCheckbox
    jcr:primaryType="cq:Widget"
    fieldLabel="My Checkbox"
    name="./myCheckbox"
    value="true"
    defaultValue="true"
    checkboxBoolTypeHint="{Boolean}true"
    type="checkbox"
    xtype="selection"/>

或在Granite Touch UI中使用以下设置:

<myCheckbox
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/checkbox"
    text="My Checkbox"
    name="./myCheckbox"
    value="true"
    checked="true"/>
<myCheckboxType
    jcr:primaryType="nt:unstructured"
    sling:resourceType="granite/ui/components/foundation/form/hidden"
    name="./myCheckbox@TypeHint"
    value="Boolean"/>


上有详细的编写和演示。

非常感谢。我不会自己设计这种组合。来吧,Adobe,更好地管理您的文档!我遇到了完全相同的问题,并且由于CQ文档不精确而变得更糟。更深入地看,上述组合将成功地在对话框上呈现一个“checked”复选框,但这不会导致设置表示此复选框元素的基础JCR属性,也就是说,没有为此复选框预先创建的./foomode属性,只有在用户访问对话框并点击“OK”后才会创建该复选框按钮。只有在POST请求创建节点属性后,才会创建节点属性。此外,请记住,除非选中复选框,否则不会提交复选框。这不是CQ的功能,它在HTML规范中,由浏览器实现。如果无论复选框是否选中,都要创建节点属性,请使用SlingPostServlet的@UseDefaultWhenMissing后缀。请参阅Apache Sling文档:。