I'm new to JSF and I'm wondering if it's possible to inject different subclasses of a base class as a MangedProperty, depending on different situations? For instance, I have this managed bean:
@ManagedBean
@SessionScoped
public class Claim implements Serializable {
private Loss lossDetails; //need to inject one of two subclasses
}
And the following base class:
public class Loss implements Serializable {
private String lossCause;
private String lossDescription;
}
Which has two subclasses:
public class AutoLoss extends Loss implements Serializable {
private List<String> vehicles;
//...
}
public class PropLoss extends Loss implements Serializable {
private String property;
private boolean weatherRelated;
//...
}
Depending on selections that are made on my application's JSF pages, I want to inject one of the subclasses as the lossDetails
ManagedProperty in the Claim
managed bean. Since I can't give the two subclasses the same managed bean name and I don't know ahead of time which one needs to be injected, is this something that can be accomplished in JSF? Or is there a different approach I should be considering?
Thanks!