I have an application that has a bean that holds a list of Contacts which are referenced from various domain objects throughout the application:
@ManagedBean
@SessionScoped
public class ContactHolder implements Serializable {
private ArrayList<Contact> contactsList;
//getters and setters...
}
Contacts can be created and added to contactsList
from various JSF pages and entries in this list need to be referenced as a ManagedProperty in various domain objects throughout the application. For instance, look at some of my domain objects:
@ManagedBean
public class Claim implements Serializable {
private Contact insured; //needs to reference entry in contactsList
}
@ManagedBean
public class Vehicle implements Serializable {
private Contact driver; //needs to reference entry in contactsList
}
Because users will have the choice to select from an existing Contact or creating a new one for each domain object, the same Contact entry in contactsList
could be referenced from more than one domain object. Is there a way to reference/inject a specific Java Collection entry as a ManagedProperty in JSF 2? Or is there a better approach to handling this scenario?
Thanks!