I am using a ContextListener to build a list containing domain objects during the application's context initialization.
Now I want to display this list (which represents DB table rows) in the first page that renders.
I have assigned this list to the
Servlet Context and I have referenced this context in my page like this:
FacesContext fc = FacesContext.getCurrentInstance();
ServletContext sc = (ServletContext) fc.getExternalContext().getContext();
List patients = sc.getAttribute("PATIENT_LIST");
The PATIENT_LIST attribute is set in the context listener.
First, is this a sensible way to initialize such a list in a
JSF environment?
Second, because I have not used a backing bean to hold the list, how do I use the JSF tags such as <h:dataTable...> to render the contents of this list?
(Using JSTL for this is easy but I need to use JSF tags.)
Afterthought, perhaps I should implement a backing bean and assign the list to that bean during initialization and dispense with the Servlet Context approach.
TIA...