Lists and Maps as Managed Beans in JSF

This tips explain how to use List and Map classes directly as Managed Beans. Here notice that you cannot use List and Map interfaces directly as Managed Beans, you can use only the implementations classes like ArrayList, Map, etc. There is no way to call constructor in the interfaces if you use List or Map directly.

also read:

The following example program initialize the values in the faces-config.xml and stored as managed beans. You can use that beans directly in the JSP pages. Note that the sample program uses ‘none’ as the scope for the bean. This is because the resulted managed bean is created as per the request and will not be stored anywhere in the scopes.

JSP File (index.jsp)

<%@taglib prefix="f" uri=""%>
<%@taglib prefix="h" uri=""%>
                <h:dataTable var="loc" value="#{listBean}">
                        <h:outputText value="#{loc}" />
                <h:outputText value="#{mapBean['Apple']}"/>
                <h:outputText value="#{mapBean['Google']}"/>
                <h:outputText value="#{mapBean['Reliance']}"/>


<?xml version='1.0' encoding='UTF-8'?>
<faces-config version="1.2"

            <value>Steve Jobs</value>
            <value>Sergy Brin</value>
            <value>Larry Page</value>
            <value>Anil Ambani</value>
                <value>Steve Jobs</value>
                <value>Larry Page and Sergy Brin</value>
                <value>Anil Ambani</value>



About Krishna Srinivasan

He is Founder and Chief Editor of JavaBeat. He has more than 8+ years of experience on developing Web applications. He writes about Spring, DOJO, JSF, Hibernate and many other emerging technologies in this blog.


  1. Very efficiently written information. It will be beneficial to everyone who usess it, including myself. Keep doing what you are doing looking forward to more posts.


  1. […] JSF Managed Beans can initialize its List properties in the faces-config.xml. There is a property in the faces-config.xml as list-entries. This cane be used for initializing the values and can be accessed directly through the Managed Beans in any JSP pages. You also can directly use the List as Managed Beans. […]

Speak Your Mind