Expand my Community achievements bar.

SOLVED

How can I invoke WCMuse java class from JAVASCRIPT Use api

Avatar

Level 1

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 **/

}

}

1 Accepted Solution

Avatar

Correct answer by
Level 10

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.

View solution in original post

3 Replies

Avatar

Level 10

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.

Avatar

Level 1

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?

Avatar

Correct answer by
Level 10

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.