Nearby lessons

32 of 35

Spring - JSF Integration

📌 What You Will Learn
  • Understand Spring - JSF Integration
  • See working code examples
  • Learn from common mistakes and Q&A

Learn Spring - JSF Integration step by step — simple explanations, complete programs with their output, common beginner mistakes, and exam-style MCQs.

JSF Integration

spring-beans.jar spring-context-support.jar spring-context.jar spring-core.jar spring-jdbc.jar spring-jms.jar spring-orm.jar spring-test.jar spring-tx.jar spring-web.jar spring-webmvc-portlet.jar spring-webmvc-struts.jar spring-webmvc.jar standard-1.0.6.jar struts-core-1.3.10.jar struts-el-1.3.10.jar struts-extras-1.3.10.jar struts-faces-1.3.10.jar struts-mailreader-dao-1.3.10.jar struts-scripting-1.3.10.jar struts-taglib-1.3.10.jar struts-tiles-1.3.10.jar

JSF Introduction

 JSF stands for Java Server Faces, it is MVC based web framework, it can be used to prepare web applications in standard mode.

 JSF is MVC based web Framework, it has very good focus on Presentation layer in enterprise bapplication development.

 JSF is initialially provided by JCP[Java Community Process], later on it was given to SUN Microsystems.

 JSF is provided by SUN Microsystems in the form of the following versions.

  • JSF1.X
  • JSF2.X
  • JSf3.X

JSF Features

 JSF is view layered Framework, it has very good focus on view layer in MVC based applications.

 JSF is component based framework or Technology, it has very good compnent tag library to prepare web applications.  JSF is having very good GUI tag library to prepare web applications with very good look

and feel, JSF is providing very good environment to prepare our own custom tags inorder to prepare our own components.  JSF is having both client side user interface and Server side user interface, it able to manage User interface at server side by preparing Component Tree at Server side.  JSF is having Statefull GUI component, they are able to manage their state at Server side.  JSF is having very good Validations Support, it able to allow to define our own Custom Validators.  JSF is having very good Convertors support, it able to allow to define own convertors.  JSF is having very good Internationalization support inorder prepare web applications w.r.t the Local users  JSF is having very good Renderring mechanisms to generate response in different formats as per the requirements, it allows us to prepare our own renderring mechanisms.  JSF is having very good Event-Notification model to implement Event Handling, it allows our own custom Events in web applications.  JSF is providing very good environment to use Third part vendors provided GUI Components libraries like primefaces, richfaces, ICEFaces,....

JSF Components

To prepare web applications by using JSF then we have to use the following JSF Components.

  • View / Presentation Part
  • Controller or FacesServlet
  • Managed Bean
  • Faces Configuration File
  • Deployment Descriptor or web.xml

View / Presentation Part

The main intention of View part in web applications is,

  • To improve Look And Feel to the web applications.
  • To Get Starting point to the web applications inorder to access.
  • To get data from users inorder to submit to the Server side application.
  • To perform client side data validations by using Java script functions.
  • To submit different request types like GET, POST, HEAD,... from client.

In web application , to prepare view part, we will use the technologies like HTML, JSP, Velocity, Freemarker,......

There are two types of View part we are able to use in web applications.

  • Information View
  • Form based View

Where informational view is able to display information to the user, it will include any form.

EX: status.html, success.html, failure.html,....

Where form based view part is able to include user forms to get data from users and to submit data to server side applications.

In JSF based web applications, to prepare View part we have to use JSF provided tag library.

To prepare View part , JSF has provided the following two types of tags.

  • Core Tags
  • Html Tags

Where core tag library includes the tags which are used for View representations, Conversions, Validatins,....

EX:

<f:convertNUmber/>
<f:convertDateTime/> <f:validateLength/> <f:validateLongRange/>

Where Html tag library include the tags which are repersenting Html Components

EX:

<h:outputText/>
<h:inputText/> <h:inputSecrete/> <h:inputTextArea/>

In JSP based web applications, to prepare Usaer form we have to use the following steps.

  • Declare view part by using <f:view> tag.
  • Include Html header part and body part in <f:view> tag.
  • Prepare user form by using <h:form> tag.
  • Prepare Panelgrid by using <h:panelGrid> tag inorder to prepare layout for GUI component.
  • Prepare html components by using the following html tags.
<h:outputText> ---> Label <h:inputText> ----> Text Field. <h:inputSecret> --> Password field. <h:commandButton/>--> Button.

Controller or FacesServlet

In General, in web applications, the main intention of controller is,

  • Getting request from Client.
  • Identifying Mdel component.
  • Instatiating Model component and executing Business logic.
  • Identifying View part.
  • Forwarding request to View part.

In JSF Based web applications, FacesServlet is acting as controller, it was provided by JSF in the form of a predefined class like "javax.faces.webapp.FacesServlet".

In JSF based web applications, FacesServlet will get Request from client and it will process the request by performing the following request processing lifecycle actions.

  • Restore View
  • Apply Request values.
  • Process Validations.
  • Update Model Values.
  • Invoke Application.
  • Render Response.

Managed Bean

In MVC based applications, the main intention of Bean classes is,

  • To manage User form Data.
  • To implement Data validations.
  • To implement Application Business Logic,....

In JSF Based web applications, Java Bean class is called as Managed Bean class, it is acting as model component.

IN JSF Based web application, To prepare Managed Beans, we have to use the following rules and regulations.

  • Managed Bean class must be a POJO class, it must not be extended and implementd any predefined library.
  • It will take all properties as per User forms.
  • It will include a seperate set of SetXXX() and getXXX() methods for each and every

property.

  • It will include buisness methods which are bounded with action attribute in

CommandButton in User forms.

  • If we want to provide constructor in Managed Bean class then provid constructor, it must

be public and 0- arg.

  • If we want to provide our own comparisions between managed Bean objets then we must

override equals() method

  • If we want to generate Hashcode values to Managed Bean objects then we have to

override hashCode() method.

Example07
JCode Cell
1 
2package com.durgasoft.beans;
3 
4public class LoginBean {
5private String uname;
6private String upwd;
7 
8public String getUname() {
9 return uname;
10}
11public void setUname(String uname) {
12this.uname = uname;
13}
14public String getUpwd() {
15return upwd;
16}
17public void setUpwd(String upwd) {
18this.upwd = upwd;
19}
20 
21public String checkLogin() {
22if(uname.equals("durga") && upwd.equals("durga")) {
23 return "success";
24}else {
25 return "failure";
26}
27}
28}
29

Faces Configuration File

The main intention of Faces Configuration File in JSf is to provide the following configuration details

  • Managed Beans configuration.
  • Navigations
  • Validators
  • Convertors.

In Simple JSF applications, we will provide managed beans configuration and navigations in Faces Configuration File. To prepare Faces Configuration file we have to use the following XML tags.

  • <faces-config>
  • <managed-bean>
  • <managed-bean-name> --- </managed-bean-name>
  • <managed-bean-class> --- </managed-bean-class>
  • <managed-bean-scope> --- </managed-bean-scope>
  • </managed-bean>
  • <navigation-rule>
  • <from-view-id>----</from-view-id>
  • <navigation-case>
  • <from-outcome>----</from-outcome>
  • <to-view-id>----</to-view-id>
  • </navigation-case>
  • <navigation-case>
  • <from-outcome>----</from-outcome>
  • <to-view-id>-----</to-view-id>
  • </navigation-case>
  • </navigation-rule>
  • </faces-config>

 Where <faces-config> is root tag, it will include JSF configuration details.  Where <managed-bean> tag is able to single Managed Bean class configuration.  Where <managed-bean-name> is able to take bean logical name of the managed bean

class.  Where <managed-bean-class> will take fully qualified name of the Managed bean class.  Where <managed-bean-scope> will take a particular scope to keep managed bean

object.  Where <navigation-rule> tag will take the total navigation model of a particular bean.  Where <from-view-id> tag will take the name and location of the JSP page from which we

are getting request.  Where <navigation-case> is providing single forward configuration.  Where <from-out-come> tag will take the return value from Business method from

Managed Bean class.  Where <ti-view-id> will take the name and location of the target page to which we want to

forward request.

Example08
JCode Cell
1 
2<faces-config>
3<managed-bean>
4<managed-bean-name>loginBean</managed-bean-name>
5<managed-bean-class>com.durgasoft.beans.LoginBean</managed-bean-class>
6<managed-bean-scope>session</managed-bean-scope>
7</managed-bean>
8<navigation-rule>
9<from-view-id>/loginform.jsp</from-view-id>
10<navigation-case>
11<from-outcome>success</from-outcome>
12<to-view-id>/success.jsp</to-view-id>
13</navigation-case>
14<navigation-case>
15<from-outcome>failure</from-outcome>
16<to-view-id>/failure.jsp</to-view-id>
17</navigation-case>
18</navigation-rule>
19</faces-config>
20

Deployment Descriptor or web.xml

In general, in web applications, deployement descriptor is web.xml file, it able to provide the following configuration details.

  • Welcome Files configuration.
  • Display Names Configuration.
  • Servlets Configuration.
  • Filters configuration.
  • Listeers Configurations.
  • Initialization parameters configuration.
  • Context Parameters Configurations.

In JSF based web applications, we have to provide FacesServlet configuration with load-on- startup configuration and we must provide url pattern for FacesServlet i either of the following forms. /faces/* *.jsf *.faces

Example09
JCode Cell
1 
2web-app>
3<servlet>
4<servlet-name>facesServlet</servlet-name>
5<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
6<load-on-startup>1</load-on-startup>
7</servlet>
8<servlet-mapping>
9<servlet-name>facesServlet</servlet-name>
10<url-pattern>*.dss</url-pattern>
11</servlet-mapping>
12</web-app>
13

Deployment Descriptor or web.xml — index.jsp

Example:

Example10
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<title>Insert title here</title>
8</head>
9<body>
10<jsp:forward page="loginform.dss"/>
11</body>
12</html>
13

Deployment Descriptor or web.xml — loginform.jsp

Example11
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
5<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
6<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
7<f:view >
8<html>
9<body>
10<h2 style="color: red;" align="center">Durga Software Solutions</h2>
11<h3 style="color: blue" align="center">User Login Page</h3>
12<h:form>
13<center>
14<h:panelGrid columns="2" >
15<h:outputText value="User Name"/>
16<h:inputText id="uname" value="#{loginBean.uname}"/>
17 
18<h:outputText value="Password"/>
19<h:inputSecret id="upwd" value="#{loginBean.upwd}"/>
20 
21<h:commandButton value="Login" action="#{loginBean.checkLogin}"/>
22</h:panelGrid>
23</center>
24</h:form>
25</body>
26</html>
27</f:view>
28

Deployment Descriptor or web.xml — success.jsp

Example12
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
8<title>Insert title here</title>
9</head>
10<body>
11<br><br>
12<h1 style="color: red;" align="center">Login Success</h1>
13</body>
14</html>
15

Deployment Descriptor or web.xml — failure.jsp

Example13
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
8<title>Insert title here</title>
9</head>
10<body>
11<br><br>
12<h1 style="color: red;" align="center">Login Failure</h1>
13</body>
14</html>
15

Deployment Descriptor or web.xml — LoginBean.java

Example14
JCode Cell
1 
2package com.durgasoft.beans;
3 
4public class LoginBean {
5private String uname;
6private String upwd;
7 
8public String getUname() {
9 return uname;
10}
11public void setUname(String uname) {
12this.uname = uname;
13}
14public String getUpwd() {
15return upwd;
16}
17public void setUpwd(String upwd) {
18this.upwd = upwd;
19}
20 
21public String checkLogin() {
22if(uname.equals("durga") && upwd.equals("durga")) {
23 return "success";
24}else {
25 return "failure";
26}
27}
28}
29

Deployment Descriptor or web.xml — faces-config.xml

Example15
JCode Cell
1 
2<?xml version="1.0" encoding="UTF-8"?>
3 
4<faces-config
5xmlns="http://java.sun.com/xml/ns/javaee"
6xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
8version="1.2">
9<managed-bean>
10<managed-bean-name>loginBean</managed-bean-name>
11<managed-bean-class>com.durgasoft.beans.LoginBean</managed-bean-class>
12<managed-bean-scope>session</managed-bean-scope>
13</managed-bean>
14<navigation-rule>
15<from-view-id>/loginform.jsp</from-view-id>
16<navigation-case>
17<from-outcome>success</from-outcome>
18<to-view-id>/success.jsp</to-view-id>
19</navigation-case>
20<navigation-case>
21<from-outcome>failure</from-outcome>
22<to-view-id>/failure.jsp</to-view-id>
23</navigation-case>
24</navigation-rule>
25</faces-config>
26

Deployment Descriptor or web.xml — web.xml

Example16
JCode Cell
1 
2<?xml version="1.0" encoding="UTF-8"?>
3<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
4<servlet>
5<servlet-name>Faces Servlet</servlet-name>
6<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
7<load-on-startup>1</load-on-startup>
8</servlet>
9<servlet-mapping>
10<servlet-name>Faces Servlet</servlet-name>
11<url-pattern>*.dss</url-pattern>
12</servlet-mapping>
13</web-app>
14

Deployment Descriptor or web.xml

If we want to integrate JSF with Spring Framework then we have to use the following steps.

  • Prepare Presentation part as per JSF Conventions.
  • Prepare Spring Beans and spring configuration file as per Spring Conventions
  • Add Dependent Spring Service Bean to Managed Bean of JSF in faces-config.xml
Example17
JCode Cell
1 
2<faces-config>
3------
4<managed-bean>
5<managed-bean-name>loginBean</managed-bean-name>
6<managed-bean-class>com.durgasoft.beans.LoginBean</managed-bean-class>
7<managed-bean-scope>session</managed-bean-scope>
8<managed-property>
9 <property-name>userService</property-name>
10 <value>#{userService}</value>
11</managed-property>
12</managed-bean>
13--------
14</faces-config>
15

Deployment Descriptor or web.xml — web.xml

Note: The main intention providing Spring Service Bean in faces-config.xml file is to inject Service bean in Jsf Managed Bean inorder to access Business methods.

  • Provide "SpringBeanFacesELResolver" configuration in faces-config.xml
  • <faces-config>
  • <application>
  • <el-resolver>
  • org.springframework.web.jsf.el.SpringBeanFacesELResolver
  • </el-resolver>
  • </application>
  • </faces-config>

Note: SpringBeanFacesResolver first delegates value lookups to the default resolver of the JSF and then to Spring's WebApplicationContext. This allows to inject springbased dependencies into JSF-managed beans.

  • Provide ContextLoaderListener and RequestContextListener in web.xml file

EX:

Example18
JCode Cell
1 
2<web-app>
3 -------
4 <listener>
5 <listener-class>
6 org.springframework.web.context.ContextLoaderListener
7 </listener-class>
8 </listener>
9 
10 <listener>
11 <listener-class>
12 org.springframework.web.context.request.RequestContextListener
13 </listener-class>
14</listener>
15------
16</web-app>
17

Deployment Descriptor or web.xml — index.jsp

Note: These Listeners are used to load the complete Spring context at the time of Startup the Server.

Example:

Example19
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<title>Insert title here</title>
8</head>
9<body>
10<jsp:forward page="loginform.dss"/>
11</body>
12</html>
13

Deployment Descriptor or web.xml — loginform.jsp

Example20
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f" %>
5<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>
6<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
7<f:view >
8<html>
9<body>
10<h2 style="color: red;" align="center">Durga Software Solutions</h2>
11<h3 style="color: blue" align="center">User Login Page</h3>
12<h:form>
13<center>
14<h:panelGrid columns="2" >
15<h:outputText value="User Name"/>
16<h:inputText id="uname" value="#{loginBean.uname}"/>
17 
18<h:outputText value="Password"/>
19<h:inputSecret id="upwd" value="#{loginBean.upwd}"/>
20 
21<h:commandButton value="Login" action="#{loginBean.login}"/>
22</h:panelGrid>
23</center>
24</h:form>
25</body>
26</html>
27</f:view>
28

Deployment Descriptor or web.xml — success.jsp

Example21
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
8<title>Insert title here</title>
9</head>
10<body>
11<br><br>
12<h1 style="color: red;" align="center">Login Success</h1>
13</body>
14</html>
15

Deployment Descriptor or web.xml — failure.jsp

Example22
JCode Cell
1 
2<%@ page language="java" contentType="text/html; charset=ISO-8859-1"
3pageEncoding="ISO-8859-1"%>
4<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
5<html>
6<head>
7<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
8<title>Insert title here</title>
9</head>
10<body>
11<br><br>
12<h1 style="color: red;" align="center">Login Failure</h1>
13</body>
14</html>
15

Deployment Descriptor or web.xml — LoginBean.java

Example23
JCode Cell
1 
2package com.durgasoft.beans;
3 
4import com.durgasoft.service.UserService;
5 
6public class LoginBean {
7private String uname;
8private String upwd;
9private UserService userService;
10 
11public String getUname() {
12return uname;
13}
14public void setUname(String uname) {
15this.uname = uname;
16}
17public String getUpwd() {
18return upwd;
19}
20public void setUpwd(String upwd) {
21this.upwd = upwd;
22}
23 
24public void setUserService(UserService userService) {
25this.userService = userService;
26}
27public UserService getUserService() {
28return userService;
29}
30 
31public String login() {
32return userService.checkLogin(uname, upwd);
33}
34}
35

Deployment Descriptor or web.xml — UserService.java

Example24
JCode Cell
1 
2package com.durgasoft.service;
3 
4public class UserService {
5String status = "";
6public String checkLogin(String uname, String upwd) {
7 if(uname.equals("durga") && upwd.equals("durga")) {
8 status = "success";
9 }else {
10 status = "failure";
11}
12return status;
13}
14}
15

Deployment Descriptor or web.xml — applicationContext.xml

Example25
JCode Cell
1 
2<?xml version="1.0" encoding="UTF-8"?>
3<beans xmlns="http://www.springframework.org/schema/beans"
4xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
5xsi:schemaLocation="http://www.springframework.org/schema/beans
6 http://www.springframework.org/schema/beans/spring-beans.xsd">
7 
8<bean id="userService" class="com.durgasoft.service.UserService"/>
9</beans>
10

Deployment Descriptor or web.xml — faces-config.xml

Example26
JCode Cell
1 
2<?xml version="1.0" encoding="UTF-8"?>
3 
4<faces-config
5xmlns="http://java.sun.com/xml/ns/javaee"
6xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-facesconfig_1_2.xsd"
8version="1.2">
9<application>
10 <el-resolver>
11 org.springframework.web.jsf.el.SpringBeanFacesELResolver
12</el-resolver>
13</application>
14<managed-bean>
15<managed-bean-name>loginBean</managed-bean-name>
16<managed-bean-class>com.durgasoft.beans.LoginBean</managed-bean-class>
17<managed-bean-scope>session</managed-bean-scope>
18<managed-property>
19 <property-name>userService</property-name>
20 <value>#{userService}</value>
21</managed-property>
22</managed-bean>
23<navigation-rule>
24<from-view-id>/loginform.jsp</from-view-id>
25<navigation-case>
26<from-outcome>success</from-outcome>
27<to-view-id>/success.jsp</to-view-id>
28</navigation-case>
29<navigation-case>
30<from-outcome>failure</from-outcome>
31<to-view-id>/failure.jsp</to-view-id>
32</navigation-case>
33</navigation-rule>
34</faces-config>
35

Deployment Descriptor or web.xml — web.xml

Example27
JCode Cell
1 
2<?xml version="1.0" encoding="UTF-8"?>
3<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0">
4<display-name>jsf_spring_app</display-name>
5 
6<servlet>
7<servlet-name>Faces Servlet</servlet-name>
8<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
9<load-on-startup>1</load-on-startup>
10</servlet>
11<servlet-mapping>
12<servlet-name>Faces Servlet</servlet-name>
13<url-pattern>*.dss</url-pattern>
14</servlet-mapping>
15<context-param>
16<param-name>javax.faces.PROJECT_STAGE</param-name>
17<param-value>Development</param-value>
18</context-param>
19 
20<!-- Add Support for Spring -->
21<listener>
22<listener-class>
23 org.springframework.web.context.ContextLoaderListener
24</listener-class>
25</listener>
26 
27<listener>
28<listener-class>
29 org.springframework.web.context.request.RequestContextListener
30</listener-class>
31</listener>
32</web-app>
33

Deployment Descriptor or web.xml

To run above web applications we have to use the following jars

  • Jsfjars
  • Springjars
  • Commons-Logging-version.jar

SF Jars

jsf1.2\jsf-api.jar jsf-impl.jar taglibs-standard-impl-1.2.5.jar taglibs-standard-spec-1.2.5.jar

Spring JARs

spring-aop-4.3.9.RELEASE.jar spring-beans-4.3.9.RELEASE.jar spring-context-4.3.9.RELEASE.jar spring-context-support-4.3.9.RELEASE.jar spring-core-4.3.9.RELEASE.jar spring-expression-4.3.9.RELEASE.jar commons-logiin-1.2.jar MAVEN COURSE MATERIAL

BY Index

MAVEN

Introduction

 Maven is a "Yiddish"[German language] word meaning "Accumulator Of Knowledge".  Maven was originally designed to simplify building processes in Jakarta Turbine project.

There were several projects and each project contained slightly different ANT build files. JARs were checked into CVS.  Apache group then developed Maven which can build multiple projects together, publish projects information, deploy projects, share JARs across several projects and help in collaboration of teams  MAVEN is a "Project Management Framework", it is much more than a simple Build tool, its declarative and standard approach simplifies many aspects of the Project Lifecycle. The main Objective of MAVEN is  A comprehensive model for projects, which is reusable, maintainable, and easier to comprehend [Understand].  Plugins or tools that interact with this declarative model.

MAVEN follows "Convention over Configuration" Principle, which means that developers are not required to create build process themselves, Developers do not have to mention each and every configuration detail. Maven provides sensible default behavior for projects.

MAVEN does the following activities of the project lifecycle automatically.  Provides default Project Structer  Download Required Dependencies [Jars files]  Compiles Source code  Packaging projects as .jar, .war, .ear,....  Starts Server  Deploying Projects into Servers.  Perform Unit Testing  Preparing Test Reports.  Preparing Documentations  Undeploy applications from Servers  Stops Server. Project Object Model [pom.xml file]

  • POM Stands for Project Object Model.

ii. POM is the fundamental unit in Maven. iii. POM is an XML file that contains information about the project and configuration details

used by Maven to build the project. iv. POM contains default values for projects ike build directory, which is target; the source

directory, which is src/main/java; the test source directory, which is src/test/java; and so on.

  • In MAVEN1 , name of pom file is "project.xml", in MAVEN2 it was renamed to pom.xml.

vi. When we execute MAVEN project then MAVEN will look for the project configurations in pom.xml file and gets the needed things and executes the project.

In Building MAVEN Projects, pom.xml file contains the following configurations.

  • Project Description
  • Repository
  • Dependency Management
  • Project Inheritance
  • Build Configuration
  • Build Profiles

Project Description

In pom file, initial we will identify "Projection Description", it contains Project name, version number, packaged type,.....

📝 Key Takeaways
  • Key ideas of Spring - JSF Integration explained simply
  • Ready-to-use code examples
  • Exam-style questions at the end