Hi All,
I was trying to add multifield in the OOTB Navigation Component to facilitate the easy addition of External URLs.
This use case helps our authors to update a few nav links from time to time. We are currently using the Shadow Site procedure, but want more flexibility
Steps I followed:
1. Created a Model class Implementing Navigation following the Sling Delegation Pattern.
@Model(
adaptables = SlingHttpServletRequest.class,
adapters = Navigation.class,
defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL,
resourceType = "myproject/components/navigation"
)
public class myNavModel implements Navigation {
@Self
(type = ResourceSuperType.class)
private Navigation navigation;
2. Since I want to get Multifield values, I created a class for it & traversed those links and titles into my Model Class.
3. Now I have original Navigation Items and Multifield Links both in my Model Class.
4. Since OOTB navigation items were unmodifiable lists.
5. I created a NavigationItem class to help me build nav items for my authored links.
private NavigationItem newNavigationItem(String url, String name) {
NavigationItem item = new NavigationItemImpl(url, name);
return item;
}
/*
NavigationItemImpl-- is my implementation of OOTB- internal- NavigationItemImpl class, since we can't extend it.
*/
NavigationItemImpl-- is my implementation of OOTB- internal- NavigationItemImpl class, since we can't extend it.
6. I can see my authored links & original links both in the new List.
However, upon calling on the page, Sightly throws an error "org.apache.sling.engine.impl.SlingRequestProcessorImpl service: Uncaught SlingException " and sometimes "UnsupportedOperationException".
Please help me solve this further.
Kindly help me to solve this issue.
Thanks,
Aditya Chabuku
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
To Whoever trying to Implement this in future,
The Error was due to HTL, the externalized links I'm sending from BE behave exactly as other Navigation Items, however, they are not pages in AEM & don't have children pages or Children pages Information.
So, when itemContent.html is referring to
data-sly-test="${item.children.size != null}
It doesn't get children size 7 throws an exception.
Instead, I changed the logic simply to
<sly data-sly-test="${item.children}">
HTL understands to execute only when children are present & don't break the page.
Hope this helps,
Aditya Chabuku
To Whoever trying to Implement this in future,
The Error was due to HTL, the externalized links I'm sending from BE behave exactly as other Navigation Items, however, they are not pages in AEM & don't have children pages or Children pages Information.
So, when itemContent.html is referring to
data-sly-test="${item.children.size != null}
It doesn't get children size 7 throws an exception.
Instead, I changed the logic simply to
<sly data-sly-test="${item.children}">
HTL understands to execute only when children are present & don't break the page.
Hope this helps,
Aditya Chabuku