Is it possible to call methods of WCMUsePojo class from Sling Model ? | Community
Skip to main content
Anupam_Maiti
Level 2
October 29, 2018
Solved

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

  • October 29, 2018
  • 3 replies
  • 2667 views

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

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Lokesh_Shivalingaiah

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.

3 replies

smacdonald2008
Level 10
October 29, 2018

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

Lokesh_Shivalingaiah
Lokesh_ShivalingaiahAccepted solution
Level 10
October 29, 2018

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.

Feike_Visser1
Adobe Employee
Adobe Employee
October 30, 2018

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