We have two View Objects which are not connected with ViewLink. Let say they are EmployeesView and JobsView from HR schema. In database these two tables are connected with FK, but we don't use them in this example.
Our goal is to access attributes of JobView from EmployeesViewRowImpl class. Let say for some sort of calculation or setting of transient attribute - for example setting the JobTitle transient attribute added to EmployeesView.
This approach is different from my previous post (http://sasocelarcadf.blogspot.com/2012/12/adf-bc-view-objects-attributes-from.html) because here we don't use View Link.
1. We create transient attribute named JobTitle in EmployeesView
2. We create EmployeesViewRowImpl class, and inside is getJobTitle() method which is the source for JobTitle transient attribute.
3. We create JobsViewImpl class and add the method named getJobTitle which returns job title for given job ID:
Tip: If we want to use this method as Groovy expression for example for defaulting the JobTitle transient attribute in EmployeesView we can use:
In this case the Default value type of transient attribute must be Expression.
4. Go back to EmployeesViewRowImpl class and adapt getJobTitle() method. With vo.getJobTitle(getJobId() we call the upper method.
5. Using Model tester we can see the result:
6. If we don't need method in JobsViewImpl, we can perform everything inside EmployeesViewRowImpl:
Our goal is to access attributes of JobView from EmployeesViewRowImpl class. Let say for some sort of calculation or setting of transient attribute - for example setting the JobTitle transient attribute added to EmployeesView.
This approach is different from my previous post (http://sasocelarcadf.blogspot.com/2012/12/adf-bc-view-objects-attributes-from.html) because here we don't use View Link.
1. We create transient attribute named JobTitle in EmployeesView
2. We create EmployeesViewRowImpl class, and inside is getJobTitle() method which is the source for JobTitle transient attribute.
3. We create JobsViewImpl class and add the method named getJobTitle which returns job title for given job ID:
public String getJobTitle(String jobId){
this.getRowSet().first();
Row rw = null;
rw = this.getRow(new Key(new Object[]{jobId}));
return (String) rw.getAttribute("JobTitle");
}
Tip: If we want to use this method as Groovy expression for example for defaulting the JobTitle transient attribute in EmployeesView we can use:
adf.source.getApplicationModule().findViewObject("JobsView1").getJobTitle(JobId);
In this case the Default value type of transient attribute must be Expression.
4. Go back to EmployeesViewRowImpl class and adapt getJobTitle() method. With vo.getJobTitle(getJobId() we call the upper method.
public String getJobTitle() {
ApplicationModule vAppModule = this.getApplicationModule();
JobsViewImpl vo = (JobsViewImpl)vAppModule.findViewObject("JobsView1");
return vo.getJobTitle(getJobId());
}
5. Using Model tester we can see the result:
6. If we don't need method in JobsViewImpl, we can perform everything inside EmployeesViewRowImpl:
public String getJobTitle() {
ApplicationModule vAppModule = this.getApplicationModule();
ViewObject vo = vAppModule.findViewObject("JobsView1");
RowSet rs = vo.getRowSet();
Row rw = null;
rw = rs.getRow(new Key(new Object[]{getJobId()}));
return (String) rw.getAttribute("JobTitle");
}