활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
활동이 없어 이 대화는 잠겼습니다. 새 게시물을 작성해 주세요.
I am working on below community article related to Sling Models. I follwed the steps given there but I am not able to map my Java Model/POJO.
https://helpx.adobe.com/experience-manager/using/sling_models.html
I have added below dependency to my pom.xml and I also added below tag inside maven bundle plugin to ensure the model/POJO will be adaptable
My POJO/Model class UserInfo.java is located inside "com.ritwik.poc.sling.models" package.
<Sling-Model-Packages>com.ritwik.poc.sling.models</Sling-Model-Packages>
<
dependency
>
<
groupId
>org.apache.sling</
groupId
>
<
artifactId
>org.apache.sling.models.api</
artifactId
>
<
version
>1.0.0</
version
>
<
scope
>provided</
scope
>
</
dependency
>
But I am getting null userInfo object when adapting from a sling resource .
Resource resource = resourceResolver.getResource("/content/testsling/slingmodel");
com.ritwik.poc.sling.models.UserInfo userInfo = resource.adaptTo(com.ritwik.poc.sling.models.UserInfo.class);
I am able to access resource properties using valuemap api. Kindly help me in fixing the issue.
Thanks
Abhilash Sathi
해결되었습니다! 솔루션으로 이동.
smacdonald2008 wrote...
This is an AEM 6 community article - but we have some ppl getting it to work on 5.6.
Thanks Scott. I thought sling models are part of AEM 5.6 . After looking at your comment I have tried to install two bundles related to Sling Models manually and then its working fine.
org.apache.sling.models.api » 1.0.0
org.apache.sling.models.impl » 1.0.0
I have downloaded above two bundles from maven respository and installed using AEM felix console . Then everything went fine. I would like to thank all active participants in AEM help forums since these are really helpful and informative for all AEM user especially beginers .
It Works perfectly well!! I tested it.
조회 수
답글
좋아요 수
on which version you have tested ? I have tried again but the POJO object is returning null when adpating from a resource
Did you also add this into your pom.xml?
<Sling-Model-Packages>
조회 수
답글
좋아요 수
I have added that Tag in POM. Actual problem is Sling model related bundles are not part of my CQ installation (5.6) . I have downloaded couple bundle and after installing those two everything worked fine. Thanks for you support.
What CQ version are you using?
조회 수
답글
좋아요 수
I just tested on AEM 6 - there was no issue:
[img]SlingModels.png[/img]
On AEM 6 - try installing the package - it works!
조회 수
답글
좋아요 수
smacdonald2008 wrote...
What CQ version are you using?
I am using Adobe AEM 5.6
This is an AEM 6 community article - but we have some ppl getting it to work on 5.6.
조회 수
답글
좋아요 수
smacdonald2008 wrote...
This is an AEM 6 community article - but we have some ppl getting it to work on 5.6.
Thanks Scott. I thought sling models are part of AEM 5.6 . After looking at your comment I have tried to install two bundles related to Sling Models manually and then its working fine.
org.apache.sling.models.api » 1.0.0
org.apache.sling.models.impl » 1.0.0
I have downloaded above two bundles from maven respository and installed using AEM felix console . Then everything went fine. I would like to thank all active participants in AEM help forums since these are really helpful and informative for all AEM user especially beginers .
You have this code:
com.ritwik.poc.sling.models.UserInfo userInfo = resource.adaptTo(com.ritwik.poc.sling.models.UserInfo.class);
to me it should be like:
com.ritwik.poc.sling.models.UserInfo userInfo = resource.adaptTo(com.ritwik.poc.sling.models.UserInfo);
조회 수
답글
좋아요 수