Expand my Community achievements bar.

SOLVED

In AEM 6.5 how to iterate the values ​of a list modified by a method in the model?

Avatar

Level 1

 

With a multifield and textarea component I am trying to sightly print the values ​​inserted into the textareas and then print the modified values ​​by means of a method in the sling model.

I wrote <data-sly-list.commenta="${comments.listChildren}">

${comment.text}

${model.modifyText}

 

It continues to print only the values ​​entered from the dialog without printing those modified with the model

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Community Advisor

Hi @Vodjakxa 
check the context

${model.modifyText @ context='html'}

 

Could you please share below:
1. How text and modifyText stored in the content page node.

2. Sling Model code?

 

If text and modifyText are stored in the same node then you can return list from sling Model and display both like 

<sly data-sly-list.commenta="${comments.listChildren}">
 <div>Text : ${commenta.text @ context='html'} </div>
 <div> Modify Text : ${commenta.modifyText @ context='html'} </div>
</sly>

 



Arun Patidar

View solution in original post

3 Replies

Avatar

Correct answer by
Community Advisor

Hi @Vodjakxa 
check the context

${model.modifyText @ context='html'}

 

Could you please share below:
1. How text and modifyText stored in the content page node.

2. Sling Model code?

 

If text and modifyText are stored in the same node then you can return list from sling Model and display both like 

<sly data-sly-list.commenta="${comments.listChildren}">
 <div>Text : ${commenta.text @ context='html'} </div>
 <div> Modify Text : ${commenta.modifyText @ context='html'} </div>
</sly>

 



Arun Patidar

Avatar

Level 1

In the content page node comments are saved as children of comments. And for now it only prints the values ​​entered via the dialog. My intention is to be able to print those modified method values ​​in the model, called modifyText. In the model I added @RequestAttribute to the text attribute

Avatar

Level 5

Hi @Vodjakxa 

 

In your sling model, return the modified item list through getters and setters.

 

Please iterate through modified list using data-sly-list in sightly and print the modifyText 

${list.modifyText}

 

Hope this helps !