In a jsp i use a jsf EL expression like this :
#{Employee.Department.Name}
In the database the n:1 relation between Employee and Department tables is not mandatory so previous EL expression can raise a null pointer exception because Employee.Department can be null.
This is a very frequent situation so i belive there must be a "standard" approch to solve this problem. My current solution is like this one :
Code:
if (Employee.Department == null) {
Employee.Department = new Department();
}
but actually i think this is a bad solution.
Is there a more elegant way to solve this problem ?
TIA
s7