繁体   English   中英

CQ5 ExtJs小部件

[英]CQ5 ExtJs widgets

我是Adobe CQ5 5.6.1版的新手,并尝试使用ExtJs学习小部件创建,所以我做了一些例子。 我想在这里做的就是在点击按钮时显示警告框但没有得到它。 这是代码。

   <?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    jcr:primaryType="cq:Dialog"
    helpPath="en/cq/current/wcm/default_components.html#Title"
    title="Title Component"
    xtype="panel">
    <items jcr:primaryType="cq:WidgetCollection">
        <webcastAtAGlanceTitle
            jcr:primaryType="cq:Widget"
            fieldLabel="Title"
            maxLength="{Long}25"
            name="./webcastAtAGlanceTitle"
            xtype="textfield"/>
        <selection
            jcr:primaryType="cq:Widget"
            defaultValue="pageProp"
            fieldLabel="Configuration Options"
            name="./selection"
            type="radio"
            xtype="selection">
            <options jcr:primaryType="cq:WidgetCollection">
                <pageProp
                    jcr:primaryType="nt:unstructured"
                    text="Page Properties"
                    value="pageProp"/>
                <RTE
                    jcr:primaryType="nt:unstructured"
                    text="RTE"
                    value="RTE"/>
            </options>
        </selection>
       <testbutton
        jcr:primaryType="cq:Widget"
        autoWidth="{Boolean}true"
        fieldLabel="test button"
        text="Ok"
        xtype="button">
        <listener
            jcr:primaryType="nt:unstructured"
            click="function(){alert(&quot;Hello World&quot;,&quot;All set!!!&quot;);}"/>
    </testbutton>
    </items>
</jcr:root>

我相信这很容易实现。 欣赏输入。

谢谢 !

这根本不需要听众。 或者,您可以使用handler属性指定单击按钮时需要调用的函数。

<testbutton
    jcr:primaryType="cq:Widget"
    autoWidth="{Boolean}true"
    fieldLabel="test button"
    text="Ok"
    xtype="button"
    handler="function(b, e){alert('Hello!!');}" />

b和e分别是传递给处理程序的按钮和事件对象。 有关进一步参考,请查看此Button API

对于侦听器部分,节点名称必须是listeners而不是侦听器。 这应该工作。

<testbutton
    jcr:primaryType="cq:Widget"
    autoWidth="{Boolean}true"
    fieldLabel="test button"
    text="Ok"
    xtype="button">
    <listeners
        jcr:primaryType="nt:unstructured"
        click="function(){alert(&quot;Hello World&quot;,&quot;All set!!!&quot;);}"/>
</testbutton>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM