Expand my Community achievements bar.

SOLVED

JSON isn't loaded in selection field on dialog launch

Avatar

Level 2

Hi all,

This is my component's _cq_dialog 's .content.xml:

<?xml version="1.0" encoding="UTF-8"?> <jcr:root xmlns:sling="http://sling.apache.org/jcr/sling/1.0" 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="nt:unstructured" jcr:title="Store Tile" sling:resourceType="cq/gui/components/authoring/dialog" helpPath="en/cq/current/wcm/default_components.html#Carousel"> <content jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/tabs" type="nav"/> <items jcr:primaryType="nt:unstructured"> <titletext jcr:primaryType="nt:unstructured" jcr:title="Store Tile Properties" sling:resourceType="granite/ui/components/foundation/section"> <layout jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/layouts/fixedcolumns"/> <items jcr:primaryType="nt:unstructured"> <column jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/container"> <items jcr:primaryType="nt:unstructured"> <storelist jcr:primaryType="nt:unstructured" sling:resourceType="granite/ui/components/foundation/form/select" options='/apps/platform-adventure/components/general/store-tile/store.json' fieldLabel="Store" name="./jcr:storeID" optionsRoot = 'mydata' optionsTextField = 'label' optionsValueField = 'id' allowBlank = "false" defaultValue="1" xtype = 'selection' type = 'select'> </storelist> </items> </column> </items> </titletext> </items> </content> </jcr:root>

 

The field gets shown successfully but, the url "/apps/platform-adventure/components/general/store-tile/store.json" isn't loading...It should return this data:

{"mydata":[
  {"id":"1","label":"one"},
  {"id":"2","label":"two"},
  {"id":"3","label":"three"},
  {"id":"4","label":"four"},
  {"id":"5","label":"five"},
  {"id":"6","label":"six"}
]}

 

But the field stays empty.

What am I doing wrong?

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Level 10
2 Replies

Avatar

Correct answer by
Level 10

Here are 4 helpful article which shows how to get this: 

Let me know if this doesn't help you.

Suggestion : Ensure that AEM and Browser cache are cleared to see changes

Avatar

Employee Advisor

Instead of options property you should be creating a node named "datasource" and set sling:resourceType property for dynamic options. Check the following example - http://experience-aem.blogspot.com/2015/04/aem-6-sp2-touchui-adding-dynamic-select-options.html. 

Ref doc - http://docs.adobe.com/docs/en/aem/6-1/ref/granite-ui/api/jcr_root/libs/granite/ui/components/foundation/form/select/index.html