How can I invoke WCMuse java class from JAVASCRIPT Use api | Community
Skip to main content
August 14, 2018
Solved

How can I invoke WCMuse java class from JAVASCRIPT Use api

  • August 14, 2018
  • 3 replies
  • 2596 views

I have a wcmuse class which works fine with data-sly-use.
Now I want to invoke this class and its methods from Sightly Javascript-use api.

I want to do some extra work hence i need to have data-sly-use functionality in javascript.

Please help.

When I try this code in JS its getting instantiated but the activate method is not invoked :

use(function () {

    var articleList = new Packages.com.xxx.cq.unifiedweb.core.sightly.DocumentationPageHelper;

    var list = articleList.getRecommendedList();

    // you can reference the parameters via the this keyword.

    var retValue = this.value1 + this.seperator + this.value2;

    return {

        newValue: retValue

    };

});

Java class :

public class DocumentationPageHelper extends WCMUse {

@Override

public void activate() throws Exception {

SlingScriptHelper slingScriptHelper = getSlingScriptHelper();

/** Do something **/

}

}

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 smacdonald2008

Answer is no - if you want to use WCMUse API - you call it from HTL code.

Here is breakdown of HTL Articles

1 - show how to work with WCMUsePojo - Creating an Adobe Experience Manager 6.4 HTL component that uses the WCMUsePojo API

2 - how to work with HTL and Sling Models - Creating a custom Touch UI Grid Component for Adobe Experience Manager

3 - how to use JS API - Creating a Tab layout component for Adobe Experience Manager

Typically - you pick one of these methods - you cannot mix them.

3 replies

Ratna_Kumar
Level 10
August 14, 2018

Hi,

I think you cannot invoke in that way as per my knowledge i.e., Java Use API in JS Use API..

You can invoke Java use API and JS use API in HTL file only.

Thanks,

Ratna Kumar.

August 16, 2018

Thanks for your reply but I am using the JS use API in HTL only.

I just want to know if we can call the custom WCMuse class from JS use API?

smacdonald2008
smacdonald2008Accepted solution
Level 10
August 16, 2018

Answer is no - if you want to use WCMUse API - you call it from HTL code.

Here is breakdown of HTL Articles

1 - show how to work with WCMUsePojo - Creating an Adobe Experience Manager 6.4 HTL component that uses the WCMUsePojo API

2 - how to work with HTL and Sling Models - Creating a custom Touch UI Grid Component for Adobe Experience Manager

3 - how to use JS API - Creating a Tab layout component for Adobe Experience Manager

Typically - you pick one of these methods - you cannot mix them.