March 21, 2020
Estimated Post Reading Time ~

Sample WCMUse Java File for AEM

The VehicleService.Java WCMUse class below, build and deploy it using maven to your AEM.

package com.aem;

import org.apache.sling.api.SlingHttpServletRequest;
import com.day.cq.wcm.api.Page;
import java.util.HashMap;
import java.util.Map;
import com.adobe.cq.sightly.WCMUse;

public class VehicleService extends WCMUse {
private Map<String, String> map;

@Override
public void activate() throws Exception {
SlingHttpServletRequest request = getRequest();
Page currentPage = getCurrentPage();
createVehicleDetails(request, currentPage);
}
/**
* This will Create vehicle map
*
* @return
*/
private void createVehicleDetails(SlingHttpServletRequest request, Page currentPage) {
map = new HashMap<String, String>();
map.put("name", "NewVehicle");
map.put("price", "1000");
}

/**
* This will return vehicle
*
* @return vehicle map
*/

Map<String,String> getVehicleDetails() {
return map;
}
}


By aem4beginner

No comments:

Post a Comment

If you have any doubts or questions, please let us know.