0
votes

I'm currently building a component that has TouchUI configuration properties separated with three tabs (Standard, CASL, GDPR). Each tab has the same set of options available and my current config names are similar to the following:

./standardMarketingText
./standardThirdpartyText
./gdprMarketingText
./gdprThirdpartyText
./caslMarketingText
./caslThirdpartyText

(There are several other options for standard,gdpr,casl but I left them out for brevity)

While this works, I'm hoping to instead store the values in the JCR as a JSON node per category. For example:

casl = {"marketingText"="m test", "thirdpartyText"="tp test"}
gdpr = {"marketingText"="gdpr m test", "thirdpartyText"="gdpr tp test"}

This way I can load all "casl" (or others) options at once when I need them (there isn't a case where I would only load one "casl" option)

I have attempted using granite/ui/components/foundation/form/multifield however, it asks to "Add field". I only want one set of each, and not provide the ability to add another set of properties under each tab. Is there a way to accomplish this without overriding the multifield resourceType?

1
As far as I know, only multifield allows to store in JSON format, but if you do not want to allow user to enter more than one element then you can restrict by implementing listener. Ps follow this : helpx.adobe.com/experience-manager/using/…Pakira

1 Answers

0
votes

There are multiple ways to achieve what you are looking at, I would look at the reusability as there are similar named properties for different categories (in your case tabs). To group them you could do that at node level by correctly defining the name property for each tab.

For above provided values, you could do something like -

./standard/marketingText
./standard/thirdpartyText
./gdpr/marketingText
./gdpr/thirdpartyText
./casl/marketingText
./casl/thirdpartyText

Your each tab stores the properties in named node (standard, gdpr, casl). In addition you could have a single SlingModel/WCMUsePojo that can adapt to these nodes to provide the Pojo with accessor to property values.

As far as getting JSON is concerned, your SlingModel or WCMUsePojo can provide a method to return JSON based string for the values.