AEM 6.4. Retrieve values from another dialog. | Community
Skip to main content
Level 2
September 11, 2018
Solved

AEM 6.4. Retrieve values from another dialog.

  • September 11, 2018
  • 15 replies
  • 12298 views

Hello i have another question.

I have 2 components. Lets say Component A and component B.

My B is a normal component with a dialog.

My A component has a dialog with 1 field that is the only one authorable.

My need is that my A needs to retrieve some other values dinamycally from the component B dialog and render it.

How can achieve this?

(everything needs to "elaborated in AEM but rendered in Angular)

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 Endoriel

Maybe I'm missing something but I don't really see what's complicated here. From your latest explanations it doesn't seem to be anything to do with dialogs and displaying values from one in the other, rather displaying content created for your card components in your card list component.

If the card components and the card list have the same parent you can just create a custom injector  or add a post construct method in your model for the card list. In this method you get the parent resource of your card list, you iterate through the child resources and test they have the resource type of your card component and then you either adapt them to the card component model and add them to a list or just get the subtitle property and add it to a String list.

Create a getter for this list. In your sightly template you use the card list model and display the content of the list. Make your card components refresh the page when added to the parsys in the edit config so you don't have a stale card list.

Unless I completely misunderstood this seems pretty straight forward to me.

15 replies

arunpatidar
Community Advisor
Community Advisor
September 12, 2018

Hi,

Thanks to elaborating. Now I can say that there is no relationship between components card and card-list. So you won't be able to reuse component dialog using granite include resource type.

Lets assume if you will make Ajax request to component card to get subtitle field value and set to on dialog load in card list component then you can do it but there is no possibility to always find card component until you didn't manually drag and drop, and what if there are more than 1 card component in the page or parsys. How will you make the request, because if you'll add more than 1 components in the same parsys then for other components node name is suffixed by random number.

Arun Patidar
dfrusoneAuthor
Level 2
September 12, 2018

Exactly. That's the problem. 2 or more same components will generate a random suffix.

I was thinking about java, get parents node and then pick everything called "card * something". Then get every subtitle property value and put in an array.

This thing must refresh everytime in case author drop components or delete some.

Also there is a relationship. Because the subtitle property of component Card is the same that "List of card" has to render.

The best thing was to make Component List of card, pick properties directly in the Card component dialog.

arunpatidar
Community Advisor
Community Advisor
September 12, 2018

You can try other way around, read all card list component and and make it available as dropdown in card component.

I'll try same and will update you.

Arun Patidar
Endoriel
EndorielAccepted solution
Level 2
September 12, 2018

Maybe I'm missing something but I don't really see what's complicated here. From your latest explanations it doesn't seem to be anything to do with dialogs and displaying values from one in the other, rather displaying content created for your card components in your card list component.

If the card components and the card list have the same parent you can just create a custom injector  or add a post construct method in your model for the card list. In this method you get the parent resource of your card list, you iterate through the child resources and test they have the resource type of your card component and then you either adapt them to the card component model and add them to a list or just get the subtitle property and add it to a String list.

Create a getter for this list. In your sightly template you use the card list model and display the content of the list. Make your card components refresh the page when added to the parsys in the edit config so you don't have a stale card list.

Unless I completely misunderstood this seems pretty straight forward to me.

dfrusoneAuthor
Level 2
September 12, 2018

This is the way i was achieving it.

I just wanted to understand if there was something else we could work with. Like Component A taking values directly from Component B.

Thats all ^^

By the way, thanks that was the answer