I am developing in a SOA arch with a web service as the business service and a
JSF front-end.
Problem-
The business model nearly always has a hierarchy similar to a classic - "A Department has many Employees." And there can be multiple Departments. So we have class Department and class Employee. With the list of Employees aggregated in the class Department.
Now the view can either be-
1. List the departments with a drill down on employees in a department. This is fine no probs here.
2. List the Employees along with their department details.
displaying view # 2 becomes a pain on the
jsp since one has to iterate over the department list and then iterate(nested) over the employees list. This is the only way we can reference the department of an employee.
A simple solution that can solve this is to have a each employee object keep a reference to its department maybe in the view model. And iterate over only the employee list wherever required with still a reference to the department. Now the solution seems to violate object oriented design principles but it is very practical.
Greatly appreciated any other solutions\ opinions. Thanks!