JSF Using Message Bundle In JSF Page

Using Message Bundle In JSF Page

  • Edit tool/src/bundle/org/sakaiproject/tool/tasklist/bundle/Messages.properties
    • Using key value pairs
    • task_list_title=Task List
      task_list_add=Add Task
      task_list_date=Date Created
      task_list_text=Task
      task_list_id=ID
      task_list_delete=Delete
      task_list_owner=Owner
      
  • Modify "tool/src/webapp/tasklist/TaskList.jsp" to take advantage of message bundle
    <%@ taglib uri="http://sakaiproject.org/jsf/sakai" prefix="sakai" %>
    <%@ taglib uri="http://java.sun.com/jsf/html" prefix="h" %>
    <%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %> 
     <f:loadBundle basename="org.sakaiproject.tool.tasklist.bundle.Messages" var="msgs"/>
     
    <f:view>
    	<sakai:view_container title="Task List Tool">
    		<sakai:view_content>
    			<h:form id="tasks">
    			 	<sakai:view_title value="#{msgs.task_list_title}"/>
    			 	<h:outputText value="Hello, #{TaskListBean.currentUserDisplayName}"/>
    			 </h:form>
      		</sakai:view_content>	
    	</sakai:view_container>
    </f:view>
    
  • Modify tool/src/webapp/WEB-INF/faces-config.xml to configure the message bundle
    • Add the following:
      •     <!-- Message Bundle -->
            <application>
                <message-bundle>org.sakaiproject.tool.tasklist.bundle.Messages</message-bundle>
                <locale-config>
                    <default-locale>en</default-locale>
                </locale-config>
            </application>