Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Is there a JSON xtype available for dialog fields in AEM 6.5 (Classic UI)?

Avatar

Level 2

I have a Classic UI dialog that consists of a multifield & inside that multi-field, I want to create a field that produces a JSON object. If such an xtype does exist, then submitting the field should result in the JCR structure (or CRXDE) saving the data as a JSON object like so: { "base": "...", "hover": "..." }. If a JSON xtype doesn't exist, what's the alternative (except for a multifield which submits one entry, since I'm working with a nested multifield, which means entries are stored inside arrays regardless of the number of entries made)?

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Please keep in mind that the Classic UI is deprecated. You are customizing something that is no longer supported. The reason multifield does not have a JSON format is that the way the data is stored facilitates its manipulation via Sling Models, which is the recommended approach for further working with the data stored in your multifield.

 

Here, you can learn more about how to use a multifield in Touch UI: https://levelup.gitconnected.com/aem-how-to-use-nested-multifields-in-your-components-using-a-sling-... 

 

Hope this helps



Esteban Bustamante

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Please keep in mind that the Classic UI is deprecated. You are customizing something that is no longer supported. The reason multifield does not have a JSON format is that the way the data is stored facilitates its manipulation via Sling Models, which is the recommended approach for further working with the data stored in your multifield.

 

Here, you can learn more about how to use a multifield in Touch UI: https://levelup.gitconnected.com/aem-how-to-use-nested-multifields-in-your-components-using-a-sling-... 

 

Hope this helps



Esteban Bustamante

Hi Esteban,

 

Thanks for this response. I had to use a workaround (in the clientlib) where I set a property to each multifield item (which in this case, is a JSON object). For example:

var updatedCategories = dialog.getField("./navmenu/shop/categories").getValue().map(function (item) {
        var category = JSON.parse(item);
        // Setting the property with a single JSON object (stringified)
        category.images = category.imagesJson[0] || JSON.stringify({ base: "", hover: "" });
        return JSON.stringify(category);
});
dialog.getField("./navmenu/shop/categories").setValue(updatedCategories);