Sri February 2016

how to store xtype value as String Array CQ5 / AEM

I have dialog with set of xtypes defined. One of xtype is "selection" with type "select". Now each option has a value type "String[]" , but when I add the component to a page and look at the option selected content.

It is stored as "String" rather than "String[]".

Could anyone tell me how to make/force a xtype store its values in a "String[]" , rather than "String".

Thank you, Sri

Answers


Mateusz ChromiƄski February 2016

You can use one of the Sling parameters to manipulate the content creation through the SlingPostServlet. Read more: here

In reality, just add a hidden field to your dialog that will pass the @TypeHint parameter with the expected property type. If your xtype saves data to e.g. cities property you can add the following:

<citiesTypeHint
    jcr:primaryType="cq:Widget"
    name="cities@TypeHint"
    value="String[]"
    xtype="hidden"


Manisha February 2016

When you are adding xtype in dialog.xml, add it as :

property=value

This will create a property of String type with value as value.

If you want an array put the value in [], as :

property="[value1],[value2],[value3],..."

This will create a property of String[] type with value as value. If you want to add more, separate then with coma.

If you want to define dataType, as :

property="{dataType}value"

This will create a property of dataType type with value as value. Where dataType may be any DataType like Boolean, Date, Long, etc

If you are adding Property with crx/de then click on add multi button in the bottom right corner.

Hope this Helps...:)

Post Status

Asked in February 2016
Viewed 2,491 times
Voted 4
Answered 2 times

Search




Leave an answer