Expand my Community achievements bar.

Dive into Adobe Summit 2024! Explore curated list of AEM sessions & labs, register, connect with experts, ask questions, engage, and share insights. Don't miss the excitement.

Access model class outside component HTML

Avatar

Level 4

Hi All,

Can we access a model class parameters outside the component HTML.

for example,

i want to access sampleModel.class parameters written for sample.html from sample2.html or from parent HTML having sample component as a child.

If no, what will be the workaround to access dialog properties of sample component from its parent component?

Following is the structure and i want to access all properties of all sample components:

parent component

     -jcr:content

          -parsys

               -sample

               -sample_6733100011

Note: properties.<porperty_name> doesnt work.

4 Replies

Avatar

Level 5

As far as I understand, sample and sample_6733100011 are the same component dropped twice in a single  parsys but I am not clear about  where do you want to access the properties of sample component.

Avatar

Level 4

Hi Pooja,

yes, they both are same component and i want to display one property called "data" as follows:

${properties['parsys/sample/data'] @context='unsafe'}

This works fine for sample component, but in future author may drag and drop as many sample component as they want. and the name will be different for every new sample component dropped under parsys.

So how can i get the values looping over parsys node?

I can do that via sling models, i was wondering if we have any such method in sightly or any scriplet with which i can list all the 'data' property of sample component?

Avatar

Level 5

I think every sample component dropped in parsys will have their own data property and sling model will fetch the property of respective component.

Set this values for all the components dropped and null should not come if the property is set for that component as it resolves on the basis current resource only. You can follow this link for your reference

Avatar

Level 4

Hi Pooja,

You didnt get my question.

the question was about looping over child components of parsys.

i wanted to know a method by which i can loop over child components i.e. all sample components dropped in parsys.

Anyways, i found another solution.

Thanks a lot for your time.