Expand my Community achievements bar.

July 31st AEM Gems Webinar: Elevate your AEM development to master the integration of private GitHub repositories within AEM Cloud Manager.

HTL does not show data on the page

Avatar

Level 3

Hello Community!

I was working on WCMUserPojo to retrieve data from multifield.

I could get multifield data in json all the way to HTL However, I have a problem.

Seemed like HTL knows how many elements in the json but it does not show the text I wanted to show.

In my HTL I have following code

1319524_pastedImage_0.png

in my MultiFieldSubMenuController

1319546_pastedImage_2.png

In my MultiFieldSubmenu

1319547_pastedImage_3.png

Out puts of Logger are

1319548_pastedImage_4.png

Actual out put on the page is

1319549_pastedImage_5.png

I also tried to add context to see what happen but it gave me the same result.

Does anybody know why HTL does not show data inside of the object and its solution?

Thank you for your time.

Ryu

5 Replies

Avatar

Employee

Are you sure there that setId / setText get valid values?

Avatar

Level 3

Hello Feike Visser

I checked added Logger in getText and getId methods. It seemed like MultiFieldSubMenu class has never gotten called by HTL.

As my understanding, sly-use gets whole Json array from Java Class and list through the each items in the Json array and ${ var } notation can gives you each field of json value. so, I'm not sure if I need get method for each field...

Let's me know what you think

thanks !

Ryu

Avatar

Employee

To me you are mixing concepts of JSON and Java, in your example you transform JSON into Java, so at the point HTL is not dealing anymore with JSON

Avatar

Level 3

I'm sorry

I think I didn't quite explain right for previous comment.

As you can see from the code I provided. Only place jason string shows up is that when they insert variables into MultiFieldSubMenu node.because multifeld in dialog holds json object. We need to convert into Java object.

So by the time it gets passed to HTL, the object in the HTL is arraylist that's has MultiFieldSubMenu class nodes.

It iterates each item but it still missing the class variables. The ${item.text}, for example, does not call the getText method in MultiFieldSubMenu.

LOGGER output shows the array lists contain adequate class nodes, so I think if it iterated each item belong to the MultiFieldSubMenu not MultiFieldSubMenu controller class.

There is tutorial made by adobe Adobe Experience Manager Help | Creating an AEM 6.2 HTML Template Language component that uses a Mul...

I referenced the document while making this example.

Avatar

Level 3

Although I just found a solution, I don't think this is a proper fix. But it works on my AEM

In the MultiFieldSubMenuController class, I added iterator values.

1323348_pastedImage_1.png

and get methods for both items

1323350_pastedImage_3.png

I thought the once iterated item in the slightly list, I thought it points to whatever element in side of object but it seemed like not.
HTL still looking for get method inside of Controller class.

Even I found work around, I still want to see proper way to retrieve MultiFields values.

Thanks,

Ryu