Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

WCMUsePojo and getRequest()

Avatar

Avatar
Give Back
Level 1
juliac53382245
Level 1

Likes

2 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 1
View profile

Avatar
Give Back
Level 1
juliac53382245
Level 1

Likes

2 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 1
View profile
juliac53382245
Level 1

01-11-2019

Hi,

I am attempting to implement a new feature on our site, with code provided by a vendor. They have provided a .jar and example .jsp files. I am in the process of converting the jsp to HTL/WCMUsePojo class. In their .jsp example they have:

IXFSDKParameters parameters = new IXFSDKParameters(request);

IXFSDKClient client = new IXFSDKClient(ixfConfig, response, parameters);

From what I have found online, it appears in my WCMUsePojo class I should be able to get the request and response objects from getRequest() and getResponse(). I have tried getRequest() but it returns null.

Is there anything I'm missing in the java class? Our site uses many classes that extend WCMUsePojo but we have not tried to access the request/response objects from them before.

Thank you!

Replies

Avatar

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,430 likes

Total Posts

3,304 posts

Correct Reply

937 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile

Avatar
Coach
MVP
Arun_Patidar
MVP

Likes

1,430 likes

Total Posts

3,304 posts

Correct Reply

937 solutions
Top badges earned
Coach
Contributor 2
Ignite 10
Give Back 700
Boost 1000
View profile
Arun_Patidar
MVP

01-11-2019

Hi,

It should return current request for the components which extends WCMUsePojo

WCMUsePojo ("The Adobe AEM Quickstart and Web Application.")

Can you share the sample code, where you are getting request object.

Avatar

Avatar
Give Back
Level 1
juliac53382245
Level 1

Likes

2 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 1
View profile

Avatar
Give Back
Level 1
juliac53382245
Level 1

Likes

2 likes

Total Posts

3 posts

Correct Reply

0 solutions
Top badges earned
Give Back
Ignite 1
Boost 1
View profile
juliac53382245
Level 1

04-11-2019

Hi Arun,

Adding the data-sly-use call in my navigation component did not pass the request object. I was able to get it working by passing request/response as parameters to my WCMUsePojo class.

<div data-sly-use.dataProvider="${'com.site.aem.dataproviders.NewLinkProvider' @prop=request,propr=response}"></div>

When I tried data-sly-use in my template (basepage.html) it does not have the same issue. I am able to get the correct request/response without passing the parameters.

<html lang="en-US" data-sly-use.dataProvider="${'com.site.aem.dataproviders.NewLinkProvider'}">

Are the request/response objects not available when data-sly-use is added in a component?

This is my class below with the parameters code removed.

public class NewLinkProvider extends WCMUsePojo {

    private static final Logger logger = LoggerFactory.getLogger(NewLinkProvider.class);

    private String headOpenData;

    private String bodyOpenData;

    private String bodyStringData;

    @Override

    public void activate() throws Exception {

        

          //IXF Configuration items have been removed

            IXFSDKParameters parameters = new IXFSDKParameters(getRequest());

            IXFSDKClient client = new IXFSDKClient(ixfConfig, getResponse(), parameters);

            this.headOpenData = client.getHeadOpen();

            this.bodyOpenData = client.getBodyOpen();

            this.bodyStringData = client.getBodyString("body_1");

    }

    public String getHeadOpenData() {

        return headOpenData;

    }

    public String getBodyOpenData() {

        return bodyOpenData;

    }

    public String getBodyStringData() {

        return bodyStringData;

    }

}