Repository navigation
Steps in creating the project
-
Design the view pages using Bootstrap.
-
Create a new Maven project in Eclipse.
-
In pom.xml, adding spring-web and spring-webmvc dependencies.
-
In web.xml, providing the physical and logical paths of the dispatcher-servlet. It will act as a front controller. A front controller is responsible for dispatching the request & acts as a single point between client and the entire application.
-
Create a new xml file for configuring dispatcher-servler. It consists of various beans such as viewResolver and multipartResolver. Beans is a collection of singleton objects (i.e those objects having one instance per application).
-
Create a package inside Java Resources for controller. Create a new class inside that controller package named HelloController. It will consist of various Request mappings which will tell the front controller the exact address for the request.
-
For products page, we are using AngularJS. It is a structural framework for dynamic web applications. We also create a Model class for products which will contain data about all the products. Java object will be converted to AngularJS using the JSON converter i.e gson which is finally displayed on the view page.
-
Create a new xml file for configuring hibernate in the application. For this, we create majorly 3 beans i.e.- (i) DataSource: It will contain details about Database connection
(ii) SessionFactory: It is responsible for automatically generating session objects.
(iii) TransactionManager: It is responsible for all the transactions.
-
Create a new package in Java Resources for DAO. Create a new interface ProductDAO inside that package and provide some methods for manipulating the products data.
-
Create a new class ProductDAOImpl inside DAO package. This class will implement ProductDAO interface and will act as a repository.
-
Using the same concepts create the rest of the pages, classes and interfaces for Users also. The User registration will include a form for taking details from users.
-
Implementing Multipart files for product images. For this add 2 more dependencies in pom.xml i.e commons-fileupload and commons-io.
-
Creating xml file for configuring spring-security in the application. For this, we added filters inside web.xml. A filter is used to intercept client requests. Inside spring security configurations, we defines intercept URLs, patterns, and access.
-
Implemented web flow in the application for placing order. Web flow provides a definite structure of the flow which cannot be overridden. To configure web flow, create a new xml file. A web flow definition is always an xml based file.
-
Create a folder flows inside views folder and inside that create a new xml file for flow definition with the naming convention as 'project-flow.xml'. If '-flow.xml' is not provided then it wont be recognised as a flow definition and this path is given in the web flow configuration with some id.
-
Create the rest of the model classes required with cart implementation. Cart is implemented using restful web services. And order placing is implemented using web flow. This is the last part for project completion.