Is there a JSON xtype available for dialog fields in AEM 6.5 (Classic UI)? | Community
Skip to main content
Level 2
September 6, 2023
Solved

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

  • September 6, 2023
  • 2 replies
  • 1011 views

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)?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by EstebanBustamante

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-model-vs-pure-htl-92ff8d036ba1 

 

Hope this helps

2 replies

Saravanan_Dharmaraj
Community Advisor
Community Advisor
September 6, 2023

@justyusaf100x you can check this example given with some customization to store the nested multifield values as json

http://experience-aem.blogspot.com/2015/06/aem-61-classic-ui-nested-composite-multifield-panel.html?m=1

 

 

EstebanBustamante
Community Advisor and Adobe Champion
EstebanBustamanteCommunity Advisor and Adobe ChampionAccepted solution
Community Advisor and Adobe Champion
September 7, 2023

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-model-vs-pure-htl-92ff8d036ba1 

 

Hope this helps

Esteban Bustamante
Level 2
September 7, 2023

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);