WcmUsePojo Vs Sling Models | Community
Skip to main content
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
puradawidAccepted solution
Level 3
Sep 5, 2017 9:19 PM UTC

There is no the best solution for that. It depends on many various things smacdonald2008​ wrote already (with massive exhausing explanation). Although tldr: using Sling Models coexist with using a lot of annotations (like JPA a little, at least for me) and Use classes are rather manual processing from a resource to specific class. Moreover, and forgive my ignorance, Sling Models are using (100% sure) adaptTo method and I am not sure which mechanism Use classes are using (I think its some injections during HTL but I might be wrong). Personally I have got away from Use classes in favour of Sling Models but it was related to that I need mostly plain classes without any processing so essentially few fields with annotations and getters are doing their job well.

4 replies

briankasingli-4
Level 2
Aug 1, 2018 10:55 PM UTC

I recommend Sling Models because there are very restrictive test libraries that support WCMUsePojo. Sling Models FTW!

Translate
puradawidAccepted solution
Level 3
Sep 5, 2017 9:19 PM UTC

There is no the best solution for that. It depends on many various things smacdonald2008​ wrote already (with massive exhausing explanation). Although tldr: using Sling Models coexist with using a lot of annotations (like JPA a little, at least for me) and Use classes are rather manual processing from a resource to specific class. Moreover, and forgive my ignorance, Sling Models are using (100% sure) adaptTo method and I am not sure which mechanism Use classes are using (I think its some injections during HTL but I might be wrong). Personally I have got away from Use classes in favour of Sling Models but it was related to that I need mostly plain classes without any processing so essentially few fields with annotations and getters are doing their job well.

Translate
smacdonald2008
Level 10
Sep 5, 2017 7:29 PM UTC

Also - both approaches are valid too. Here is a getting started article for HTL and WCMUsePojo -- Scott's Digital Community: Creating an AEM HTML Template Language component that uses the WCMUsePojo class

Translate
smacdonald2008
Level 10
Sep 5, 2017 7:28 PM UTC

See this thread -- good write up -- How To Switch From WCMUsePojo To Sling Models in AEM

Hope this helps.

Translate