Hi,
I'm currently rewriting a Sightly template as JSP (I usually prefer using Sightly, but I need JSP for this use case).
In our Sightly template, we are loading in a model class that inherits from WCMUsePojo:
<sly data-sly-use.search="edu.nyu.aemnyu.core.components.content.news.Search" data-sly-unwrap>
When I try mimicking this in the JSP template:
Search search = resource.adaptTo(Search.class);
The "activate()" method doesn't seem to get invoked, which tells me I'm doing something wrong.
Am I missing a better way to handle this in JSP? I'm hoping to avoid re-writing the Search class referenced above since its used elsewhere.
Thank you in advance,
Scott
Solved! Go to Solution.
Views
Replies
Total Likes
WcmUsePojo is a bit restricted in its usability, and for that reason the Sling Models have been implemented. You might want to convert pojo to a Sling Model, in most cases it's straight forward.
Hi @scottfinkelstein
I am not sure if you can use WCMUsePojo in the JSP but you can use sling model in JSP
https://sling.apache.org/documentation/bundles/models.html#client-code-1
WcmUsePojo is a bit restricted in its usability, and for that reason the Sling Models have been implemented. You might want to convert pojo to a Sling Model, in most cases it's straight forward.
Thank you both! I converted the WCMUsePojo class to a Sling Model, and that worked within my JSP file. It also worked well in that I was able to use it in our Sightly template, thereby retiring the WCMUsePojo class.
Thanks again!
Scott
I trust you found the AEM community useful. We look forward to seeing you return as either a learner or a contributor. The community is enriched by SMEs like you. Encourage your AEM peers to contribute here as well. Happy AEM learning!
Views
Replies
Total Likes
@scottfinkelstein Did you find the suggestions from users 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
Views
Likes
Replies
Views
Likes
Replies