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

AEM 6.4. Retrieve values from another dialog.

  • September 11, 2018
  • 15 replies
  • 12281 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

dfrusoneAuthor
New Participant
September 11, 2018

Not really. I need the component 2 renders directly the html the values from dialog 1

smacdonald2008
New Participant
September 11, 2018

Yes - you can do that (reuse values from another dialog) or build  your component dialog that lets an author set all values required for for that component.

I personally prefer the 1-1 approach. While its true, you are setting more nodes in the JCR dialog branch, its cleaner! In the end, the component has all values as properties. Then all values can be injected into the model simply by using @Inject.

Endoriel
New Participant
September 11, 2018

From what I understand you basically want a dynamic dropdown.

Once dialog A is saved - it just becomes content so what you want in the B component is to dynamically populate your dropdown with values based on content. For that there are a lot of examples. It was just answered here: Select value in dropdown in touch ui dialog based on the value selected in editable template (You need to determine the values in Java by traversing your content and picking up those card names).

dfrusoneAuthor
New Participant
September 11, 2018

Ok and what if i have 2 components and i need to render dialog A properties in component B?

It something dynamyc and i cant let author do that.

Like i have "some cards components" and i have another component that must fill itself with "these card names" when the author adds them.

smacdonald2008
New Participant
September 11, 2018

You can set all values a component needs within its own dialog and then use Sling Models and @Inject as discussed here -- Building Experience Manager Components using Granite/Coral Resource Types