Expand my Community achievements bar.

Don’t miss the AEM Skill Exchange in SF on Nov 14—hear from industry leaders, learn best practices, and enhance your AEM strategy with practical tips.
SOLVED

Is it possible to call methods of WCMUsePojo class from Sling Model ?

Avatar

Level 2

Hi,

Is it possible to call methods of WCMUsePojo class from Sling Model, I know it's not very good to use both sling model and WCMUsePojo class together, but we have a requirement where we have to reuse the  method which is provided by third party & can not be refactored.

Thanks in advance.

Warm Regards,

Anupam Maiti

1 Accepted Solution

Avatar

Correct answer by
Level 10

Hi Anupam,

As WCMPojo classes are not exported services, it wouldn’t be available to import and consume within sling models. You may want to do that in the front end using HTL.

View solution in original post

3 Replies

Avatar

Level 10

WCMUsePojo / Sling Models are both ways from an HTL component to use Java logic. You use one way or the other.

You should pick either a Sling Model or WCMUsePojo and then code your Java logic so data is created and displayed in the HTL component.

WCMUsePojo:

Creating an Adobe Experience Manager 6.4 HTL component that uses the WCMUsePojo API

Sling Model:

Creating a custom Touch UI Grid Component for Adobe Experience Manager

NOTE - Most AEM Devs use Sling Models over WCMUSEPOJO

Avatar

Correct answer by
Level 10

Hi Anupam,

As WCMPojo classes are not exported services, it wouldn’t be available to import and consume within sling models. You may want to do that in the front end using HTL.

Avatar

Employee

you *can* instantiate the WCMUsePojo in your sling-models. Not very clean, but that is the only way I see.