In AEM 6.5 how to iterate the values ​of a list modified by a method in the model? | Community
Skip to main content
Level 2
December 12, 2024
Solved

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

  • December 12, 2024
  • 2 replies
  • 698 views

 

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

Best answer by arunpatidar

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>

 

2 replies

arunpatidar
Community Advisor
arunpatidarCommunity AdvisorAccepted solution
Community Advisor
December 12, 2024

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
VodjakxaAuthor
Level 2
December 13, 2024

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

PRATHYUSHA_VP
Community Advisor
Community Advisor
December 12, 2024

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 !