Can we create nodes in the cq dialog at runtime?
The requirement is the dialog initially would only have a single dropdown with few fixed fields. So, when an option from the dropdown is selected let's say a value great is selected so when this action happened in the dropdown now it should map the value great to a json which has which component does great map to. Let's say great --- > mapped to "textfield". Now as soon as the backend mapping is done there should be a node created in the same dialog below the dropdown referring to textfield. Can someone help with the approach. we have tried few approaches, but any leads are welcome. TIN
Views
Replies
Total Likes
Is the requirement to show or hide a field based on dropdown selection?
No. Not exactly hiding or showing fields. But when the dropdown value ex: "great" is selected, it is mapped to a OOTB component. According to that mapping we have to create a node at runtime.
Views
Replies
Total Likes
Do you mean that component should be added as a child component? Why do you want to change the dialog nodes? It is not recommended to change dialog nodes dynamically. Content change is fine.
I'm working on something. Yes, it is not recommended but could you please share if there is a way that you know of to add the nodes in jcr repository at in runtime?
Views
Replies
Total Likes
If you want to add a node, use a dialog listener, call a servlet which will perform jcr operations. I am not sure whether this will work in AEM Cloud.
Some dialog listener reference which calls servlet - https://kiransg.com/tag/dialog-level-listener/
@Preethi1234 I see there is no need of creating dialog field on fly. Instead have the textfield hidden by default and show/hide based on you dropdown change listener.
I strongly recommend avoiding the complexity of creating dialog nodes at runtime. Instead, consider using a well-established practice of showing or hiding fields based on the value selected in a drop-down menu. You can even group multiple fields together to enhance the user experience.
@Preethi1234 Did you find the suggestions helpful? Please let us know if you require more information. Otherwise, please mark the answer as correct for posterity. If you've discovered a solution yourself, we would appreciate it if you could share it with the community. Thank you!
Views
Replies
Total Likes
Views
Likes
Replies
Views
Likes
Replies