Initialize a model class in a different model class
Hi Community,
I have a query, please help me with this question.
I am trying to call a get method in a model class which is inside another model class, I will give a simple example below.
I hope the below example is sufficient enough to answer my Question, Thank you for the replies.
Class HelloWorldModelImpl:
@Model(adaptables = {Resource.class, SlingHttpServletRequest.class}, adapters= HelloWorldModel.class,
resourceType = HelloWorldModelImpl.class, defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class HelloWorldModelImpl {
//
private EmployeeModel employeeModel;
public String getEmpID(){
return employeeModel.getEmpID();
}
public String getEmpName(){
return employeeModel.getEmpName();
}
}
Class EmployeeModel:
@Model(adaptables = Resource.class,defaultInjectionStrategy = DefaultInjectionStrategy.OPTIONAL)
public class EmployeeModel{
@ValueMapValue
private String empId;
@ValueMaapValue
private String empName;
public String getEmpID(){
return empId;
}
public String getEmpName(){
return empName;
}
}
Thanks