I need to display/edit polymorphic entities.
My abstract class is Person. My concrete classes are PhysicalPerson and MoralP
Another way is to create an abstract method in a base class, which will return you some mark of what instance you have, and implement it in your subclasses, like this:
public abstract class Person {
public abstract boolean isPhysical();
}
public PhysicalPerson extends Person {
public boolean isPhysical() {
return true;
}
}
and then in jsf:
this is a PhysicalPerson.
this is a Moral Person.
However the class checking approach is more universal.