Hi Team,
In my current project there is a requirement to build a Navigation Component with the addition of a categorized order which each child page will be mapped to its respective category. Something like below:
Parent Page (home)
My first idea was to implement a method with this kind or return type "
List<HashMap<String,List<NavigationItem>>> getCategorizedItems().
The list insertion is doing fine but in Slightly, I'm not able to iterate over the second list that is inside the Hashmap. Is this a good approach?. if not, It'd helpful for me gather your suggestions for a better way to handle this scenario.
I checked some post "almost related" for iterating but none of them worked for me (not sure if I'm missing something or even if it's possible).
Any guidance that you can give me guys. I'll be appreciate it.
Regards
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi,
I think you should use a couple of sling models with the @ChildResource annotation, this is more clean and follow the best practices. If this gets more complex, perhaps even using a JSON structure is not a bad idea.
You can learn more about the annotation here:
https://allaembykiran.wordpress.com/2021/01/13/nested-multi-field/
https://www.digitalum.eu/blog/english/sling-models-part-4-structure-nodes-and-build-models/
https://sling.apache.org/documentation/bundles/models.html#available-injectors
Hope this helps.
@Luis_Ochoa Did you find the suggestion helpful? Please let us know if more information is required. Otherwise, please mark the answer as correct for posterity. If you have found out solution yourself, please share it with the community.
Views
Replies
Total Likes