Expand my Community achievements bar.

SOLVED

xtype combo / selection with dynamic options in submit action dialog

Avatar

Level 3

To the dialog of a custom submit action I want to add a dropdown that gets its options dynamically from a javascript function.

The xml for the dialog item is:

<?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" jcr:primaryType="cq:Widget" name="...." fieldLabel="...." fieldDescription="...." allowBlank="true" type="select" xtype="selection" optionsProvider="function() { return [{value:'1',text:'One'},{value:'2',text:'Two'}];}"/> 

This does not work!

But the variant below works:

<?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" jcr:primaryType="cq:Widget" name="..." fieldLabel="..." fieldDescription="..." allowBlank="true" type="select" xtype="selection"> <options jcr:primaryType="cq:WidgetCollection"> <one jcr:primaryType="nt:unstructured" text="One" value="1" /> <two jcr:primaryType="nt:unstructured" text="Two" value="2" /> </options> </jcr:root>

I have no clue why the first configuration is not working. 'optionsProvider' is a configuration option documented at http://docs.adobe.com/docs/en/cq/5-6/widgets-api/index.html.

Can somebody explain why the first configuration is not working?

1 Accepted Solution

Avatar

Correct answer by
Level 3

I've found a working solution on my own:

<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Widget" name="PROPERTY-NAME" fieldLabel="FIELD-LABEL" fieldDescription="..." type="select" xtype="selection" allowBlank="true"> <listeners jcr:primaryType="nt:unstructured" beforerender="function(){this.setOptions([{value:&quot;1&quot;,text:&quot;one&quot;},{value:&quot;2&quot;,text:&quot;two&quot;}])}"/></jcr:root> </jcr:root>

This is the configuration of a drop down list labeled as 'FIELD-LABEL' with two items 'one' and 'two'. The value either '1' or '2' of the selected item will be reflected in the property 'PROPERTY-NAME' among the submitted properties.

View solution in original post

1 Reply

Avatar

Correct answer by
Level 3

I've found a working solution on my own:

<jcr:root xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0" jcr:primaryType="cq:Widget" name="PROPERTY-NAME" fieldLabel="FIELD-LABEL" fieldDescription="..." type="select" xtype="selection" allowBlank="true"> <listeners jcr:primaryType="nt:unstructured" beforerender="function(){this.setOptions([{value:&quot;1&quot;,text:&quot;one&quot;},{value:&quot;2&quot;,text:&quot;two&quot;}])}"/></jcr:root> </jcr:root>

This is the configuration of a drop down list labeled as 'FIELD-LABEL' with two items 'one' and 'two'. The value either '1' or '2' of the selected item will be reflected in the property 'PROPERTY-NAME' among the submitted properties.