How can we pass sling model data to another service class
I wanted to pass sling model data to another service class and retrieve the response to sightly via same sling model class. Is there any way?
I wanted to pass sling model data to another service class and retrieve the response to sightly via same sling model class. Is there any way?
Hi @vainavee
Use @inject to adopt the service. Then inside init method call that particular method of that service by passing required inputs from slingmodel. Once you get the data back from service store it in a variable. Create getter of that particular variable. In sightly using use object read the variable.
@Inject
private <Service> service;
private String test = null;
@PostConstruct
protected void init() {
test = this.service.<Method>(<required Param>);
}
public void getTest(){
return test;
}
-----------------
Sightly :
<div data-sly-use.cmp="<slingmodel path>">
<h1> Var : ${cmp.test} </h1>
</div>
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.