I have been trying to integrate Spring framework within AEM6/CQ5.
I am following this tutorial. LINK
As per the tutorial I have installed the NEBA package. All NEBA bundles are active in OSGi console.
Then I created my own Maven CQ5 project, I added the dependencies of Neba annotations and Spring. My project was also successfully deployed in CQ5(bundle is active).
I tried to use a ResourceModel annotation of NEBA. But this model does not appear in the model registry of NEBA. I mapped the ResourceModel to a content component that i created "linkComponent".
When the user drags and drops this on any parsys the resource node has the properties linkName and linkURL.
I tried accessing these values in JSP but I failed.
Please See code below : package com.zensar.neba;
import org.apache.sling.api.resource.Resource;
import io.neba.api.annotations.Path;
import io.neba.api.annotations.ResourceModel;
@ResourceModel(types = "zensar-neba/components/content/linkComponent")
public class LinkComponent {
private String linkName;
private String linkURL;
public String getLinkName() {
return linkName;
}
public void setLinkName(String linkName) {
this.linkName = linkName;
}
public String getLinkURL() {
return linkURL;
}
public void setLinkURL(String linkURL) {
this.linkURL = linkURL;
}
}
Please See JSP Code of linkComponent below:
<%@include file="/libs/foundation/global.jsp"%>
<%@taglib prefix="neba" uri="http://neba.io/1.0"%>
<neba:defineObjects />
Link Component
<a href="${m.linkURL}"> Click Here ${m.linkName}</a>
Then I tried creating an Controller using Spring annotation but I got "Path not found" what am I missing.
Please see code below:
package com.zensar.neba;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
public class DemoController {
@RequestMapping("/echo/{param}")
@ResponseBody
public String echo(@PathVariable("param") String paramToEcho) {
return "Hello "+ paramToEcho;
}
}
I called the controller link this : http://localhost:4502/bin/mvc.do/echo/Oliver
IMPORTANT NOTE: All my bundles are active