JSF Message Resources

Reading Time: < 1 minute

in src/main/resource create file called “MessageResources.properties” in which we will define our messages here

footerText=This text is defined in the MessageResource.properties file

Then add the below lines into your “faces-config.xml” file to identify the messages bundle into the application;


then in any of your .xhtml file you are good to implement the resource you define in your properties file

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
<html xmlns="http://www.w3.org/1999/xhtml"
	<title>${project.artifactId} Application</title>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<h:outputStylesheet name="css/screen.css" />
	<h:panelGroup id="page" layout="block">
		<h:panelGroup id="header" layout="block">
			<h1><a href="home.jsf">fastapp</a></h1>
		<h:panelGroup id="container" layout="block">
			<h:panelGroup id="sidebar" layout="block">
				<h1>Sidebar</h1> Content for the sidebar goes here
			<h:panelGroup id="content" layout="block">
				<ui:insert name="content">Main Content</ui:insert>
		<h:panelGroup id="footer" layout="block">#{messages.footerText}



Reading Time: < 1 minute

I have come to use two solutions to prevent this exception. First of all I implement my managed bean clases to Serializable interface and add the below line into web.xml

    <!-- This line is to prevent ViewExpiredException -->