JSF Configuring JSF Environment And Dependencies

  • Configure tool/src/webapp/WEB-INF/web.xml
    <?xml version="1.0"?>
    <!DOCTYPE web-app PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
      "http://java.sun.com/dtd/web-app_2_3.dtd">
    <web-app>
    	<display-name>sakai-tasklist</display-name>
    	<description>Sakai Task List</description>
    
    	<context-param>
    		<param-name>javax.faces.STATE_SAVING_METHOD</param-name>
    		<param-value>client</param-value>
    	</context-param>
    
    
    	<!-- Sakai request filter -->
    	<filter>
    		<filter-name>sakai.request</filter-name>
    		<filter-class>org.sakaiproject.util.RequestFilter</filter-class>
    	</filter>
    	<filter-mapping>
    		<filter-name>sakai.request</filter-name>
    		<servlet-name>Faces Servlet</servlet-name>
    		<dispatcher>REQUEST</dispatcher>
    		<dispatcher>FORWARD</dispatcher>
    		<dispatcher>INCLUDE</dispatcher>
    	</filter-mapping>
    	
    	<!-- Faces Servlet -->
    	<servlet>
    		<servlet-name>sakai.tasklist</servlet-name>
    		<servlet-class>org.sakaiproject.jsf.util.JsfTool</servlet-class>
    		<init-param>
    			<param-name>default</param-name>
    			<param-value>TaskList</param-value>
    		</init-param>
    		<init-param>
    			<param-name>path</param-name>
    			<param-value>/tasklist</param-value>
    		</init-param>
    		<init-param>
    			<param-name>default.last.view</param-name>
    			<param-value>true</param-value>
    		</init-param>
    		<load-on-startup>1</load-on-startup>
    	</servlet>
    	
    	<!-- Faces Servlet -->
    	<servlet>
    		<servlet-name>Faces Servlet</servlet-name>
    		<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    		<load-on-startup>2</load-on-startup>
    	</servlet>
    	<servlet-mapping>
    		<servlet-name>Faces Servlet</servlet-name>
    		<url-pattern>*.jsf</url-pattern>
    	</servlet-mapping>
    	<listener>
    		<listener-class>
    			org.sakaiproject.util.ToolListener
    		</listener-class>
    	</listener>
    	<listener>
    		<listener-class>
    			org.sakaiproject.util.ContextLoaderListener
    		</listener-class>
    	</listener>
    </web-app>
    
  • Configure tool/src/webapp/WEB-INF/applicationContext.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN//EN" "http://www.springframework.org/dtd/spring-beans.dtd">
    <!-- documented by aaronz@vt.edu -->
    <beans>
    
    	<!-- create a tasklistManager bean, use the memory implementation -->
    	<bean id="org.sakaiproject.tool.tasklist.api.TaskListManager"
    		class="org.sakaiproject.tool.tasklist.impl.TaskListManagerMemoryImpl"
    		singleton="true">
    	</bean>
    
    	<!-- create a tasklistService bean -->
    	<bean id="org_sakaiproject_tool_tasklist_api_TaskListService"
    		class="org.sakaiproject.tool.tasklist.impl.TaskListServiceImpl"
    		singleton="true">
    		<property name="taskListManager">
    			<ref bean="org.sakaiproject.tool.tasklist.api.TaskListManager" />
    		</property>
    		<property name="toolManager">
    			<ref bean="org.sakaiproject.tool.api.ToolManager" />
    		</property>
    		<property name="userDirectoryService">
    			<ref bean="org.sakaiproject.user.api.UserDirectoryService" />
    		</property>
    	</bean>
    
    </beans>
    
  • Configure /tool/src/webapp/WEB-INF/faces-config.xml
    <?xml version="1.0"?>
    
    <!DOCTYPE faces-config PUBLIC
      "-//Sun Microsystems, Inc.//DTD JavaServer Faces Config 1.0//EN"
      "http://java.sun.com/dtd/web-facesconfig_1_0.dtd">
    <faces-config>
    
    	<!-- Message Bundle -->
        <application>
            <message-bundle>org.sakaiproject.tool.tasklist.bundle.Messages</message-bundle>
            <locale-config>
                <default-locale>en</default-locale>
            </locale-config>
        </application>
    
    	<!-- Navigation Rules -->
        <navigation-rule>
    		<from-view-id>/tasklist/TaskList.jsp</from-view-id>
    		<navigation-case>
    			<from-outcome>newTask</from-outcome>
    			<to-view-id>/tasklist/TaskList.jsp</to-view-id>
    		</navigation-case>
    		<navigation-case>
    			<from-outcome>deleteTasks</from-outcome>
    			<to-view-id>/tasklist/TaskList.jsp</to-view-id>
    		</navigation-case>
    	</navigation-rule>
    	
        <!-- Backing Bean -->
        <managed-bean>
            <description>Task List Tool: Task List Bean</description>
            <managed-bean-name>TaskListBean</managed-bean-name>
            <managed-bean-class>org.sakaiproject.tool.tasklist.jsf.TaskListBean</managed-bean-class>
            <managed-bean-scope>session</managed-bean-scope>
    		<managed-property>
    			<description>Task List Service</description>
    			<property-name>taskListService</property-name>
    			<value>#{org_sakaiproject_tool_tasklist_api_TaskListService}</value>
    		</managed-property>
        </managed-bean>
        
    </faces-config>
    
  • Configure tool/project.xml
    <?xml version="1.0" encoding="UTF-8"?>
    
    <project>
    	<pomVersion>3</pomVersion>
    	<extend>../../master/project.xml</extend>
    	<name>Programmer's Cafe - Task List</name>
    	<groupId>sakaiproject</groupId>
    	<id>sakai-tasklist-tool</id>
    	<currentVersion>${sakai.version}</currentVersion>
    	<organization>
    		<name>Sakai Foundation</name>
    		<url>http://sakaiproject.org/</url>
    	</organization>
    	<inceptionYear>2006</inceptionYear>
    
       	<properties>
    		<deploy.type>war</deploy.type>
    	</properties>
    
    	<dependencies>
    
    		<!-- The sakaiproject plugin let's us build our tool without building
    			the entire sakai code base -->
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai</artifactId>
    			<version>${sakai.plugin.version}</version>
    			<type>plugin</type>
    		</dependency>
    
    		<!-- we are running a webapp in tomcat so we need the servlet api -->
    		<dependency>
    			<groupId>servletapi</groupId>
    			<artifactId>servletapi</artifactId>
    			<version>2.4</version>
    		</dependency>
    
    
    		<!-- Spring and Hibernate dependencies. -->
    		<dependency>
    			<groupId>${sakai.hibernate.groupId}</groupId>
    			<artifactId>${sakai.hibernate.artifactId}</artifactId>
    			<version>${sakai.hibernate.version}</version>
    		</dependency>
    
    	  	<dependency>
      			<groupId>springframework</groupId>
    			<artifactId>spring</artifactId>
    			<version>${sakai.spring.version}</version>
      		</dependency>
    
    
    		<!-- Various Sakai dependencies -->
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-authz-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<!-- this is needed to use the ServerConfigurationService -->
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-component-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<!-- this is needed to access the SqlService -->
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-db-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-entity-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-event-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-site-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-tool-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-user-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-util</artifactId>
    			<version>${sakai.version}</version>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-util-api</artifactId>
    			<version>${sakai.version}</version>
    		</dependency>
    
    
    		<!-- Sakai tag library -->
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-jsf-widgets</artifactId>
    			<version>${sakai.version}</version>
    			<url>http://sakaiproject.org/</url>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
    		<!-- Adaptor to use tag library with MyFaces -->
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-jsf-widgets-myfaces</artifactId>
    			<version>${sakai.version}</version>
    			<url>http://sakaiproject.org/</url>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
    
            <!-- MyFaces JSF Impl -->
    		<dependency>
    			<groupId>myfaces</groupId>
    			<artifactId>myfaces-all</artifactId>
    			<version>1.1.1</version>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
            <dependency>
                <groupId>myfaces</groupId>
                <artifactId>tomahawk</artifactId>
                <version>1.1.1</version>
                <properties>
                    <war.bundle>true</war.bundle>
                </properties>
            </dependency>
    
    		<!-- this is required for any Sakai JSF tool -->
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-jsf-tool</artifactId>
    			<version>${sakai.version}</version>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
    		<dependency>
    			<groupId>sakaiproject</groupId>
    			<artifactId>sakai-jsf-app</artifactId>
    			<version>${sakai.version}</version>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
    
    		<!-- commons jars required for JSF -->
    		<dependency>
    			<groupId>commons-digester</groupId>
    			<artifactId>commons-digester</artifactId>
    			<version>1.6</version>
                <properties>
                    <war.bundle>true</war.bundle>
                </properties>
    		</dependency>
    
    		<dependency>
    			<groupId>commons-beanutils</groupId>
    			<artifactId>commons-beanutils</artifactId>
    			<version>1.7.0</version>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
    		<dependency>
    			<groupId>commons-codec</groupId>
    			<artifactId>commons-codec</artifactId>
    			<version>1.3</version>
    			<properties>
    				<war.bundle>true</war.bundle>
    			</properties>
    		</dependency>
    
    
            <!-- Commons JARS put in shared/lib by Sakai -->
    		<dependency>
    			<groupId>commons-lang</groupId>
    			<artifactId>commons-lang</artifactId>
    			<version>${sakai.commons.lang.version}</version>
    		</dependency>
    
    		<dependency>
    			<groupId>commons-logging</groupId>
    			<artifactId>commons-logging</artifactId>
    			<version>1.0.4</version>
    		</dependency>
    
    	</dependencies>
    
    	<build>
    		<sourceDirectory>src/java</sourceDirectory>
    		<resources>
    			<resource>
    				<directory>${basedir}/src/bundle</directory>
    				<includes>
    					<include>**/*.properties</include>
    				</includes>
    			</resource>
    			<resource>
    				<directory>${basedir}/src/java</directory>
    				<includes>
    					<include>**/*.xml</include>
    				</includes>
    			</resource>
    		</resources>
    	</build>
    	
    </project>