Posts

Showing posts from 2013

Creating Spring Boot MVC application with AWS DynamoDB in 10 mins

Image
AWS DynamoDB DB is a serverless NOSQL database. You can understand how to build a spring boot Java web MVC application (Game Leaderboard) reading a AWS DynamoDB in 10 mins. Source of the demo code: https://github.com/babysteps-topro/spring-mvc-dynamodb Command to run the project: mvn spring-boot:run Video explain the table design: https://youtu.be/V0GtrBfY7XM Prerequisite: Install the AWS CLI: https://youtu.be/pE-Q_4YXlR0 Video explain the how to create the table: https://youtu.be/sBZIVLlmpxY

Sample Apps: Spring data MongoDB and JSF Integration tutorial (PART 5)

Create, Edit and Delete data with Spring data repository In the last part of this tutorial, we will add create, edit and delete function to the MongoShop Product Catalog application. Table of Contents: 1. Introduction to sample application (MongoShop Product Catalog) 2. MongoDB schema design and data preparation 3. JSF (PrimeFaces) and Spring data MongoDB Integration 4. Enquriy data with spring data repository and mongotemplate 5. Create, Edit and delete data The search page is modified. A modal confirm dialogue box is added before the product is physically deleted updated search.xhtml <html xmlns="http://www.w3.org/1999/xhtml" xmlns:ui="http://java.sun.com/jsf/facelets" xmlns:h="http://java.sun.com/jsf/html" xmlns:f="http://java.sun.com/jsf/core" xmlns:p="http://primefaces.org/ui"> <ui:composition template="/template/common.xhtml"> <ui:define name="pageTitle"&g

Sample Apps: Spring data MongoDB and JSF Integration tutorial (PART 4)

Table of Contents: 1. Introduction to sample application (MongoShop Product Catalog) 2. MongoDB schema design and data preparation 3. JSF (PrimeFaces) and Spring data MongoDB Integration 4. Enquriy data with spring data repository and mongotemplate 5. Create, Edit and delete data Enquriy data with spring data repository and mongotemplate Spring Data Repository: Spring Data repository abstraction reduces the boilerplate code to write the data access layer of the application. Automatic implementation of Repository interfaces provides simple operation on mongoDB. It helps our product save and delete function make MongoTemplate: MongoTemplate offers convenience operations to create, update, delete and query for MongoDB documents and provides a mapping between your domain objects and MongoDB documents. In our application, since the spring data repository cannot fulfill the requirement of searching function, we use MongoTemplate to archive the searching capability. Custom

Sample Apps: Spring data MongoDB and JSF Integration tutorial (PART 3)

Table of Contents: 1. Introduction to sample application (MongoShop Product Catalog) 2. MongoDB schema design and data preparation 3. JSF (PrimeFaces) and Spring data MongoDB Integration 4. Enquriy data with spring data repository and mongotemplate 5. Create, Edit and delete data JSF (PrimeFaces) and Spring data MongoDB Integration pom.xml of the project <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> <modelversion>4.0.0</modelVersion> <groupid>com.borislam</groupId> <artifactid>mongoShop</artifactId> <packaging>war</packaging> <version>1.0-SNAPSHOT</version> <name>MongoShop Webapp</name> <url>http://maven.apache.org</url> <dependencies> <dependency> <groupid>

Sample Apps: Spring data MongoDB and JSF Integration Tutorial (PART 2)

Image
Table of Contents: 1. Introduction to sample application (MongoShop Product Catalog) 2. MongoDB schema design and data preparation 3. JSF (PrimeFaces) and Spring data MongoDB Integration 4. Enquriy data with spring data repository and mongotemplate 5. Create, Edit and delete data MongoDB schema design and data preparation MongoDB Introduction MongoDB is a open-source scalable, high-performance NoSQL database. It is a document-oriented Storage. It can store JSON-style documents with dynamic schemas. In this application, each product is stored as JSON-style document in MongoDB. Schema Design in MongoDB Each product in the catalog contains general product information (e.g. sku, title, and product type), price details (e.g. retail and list price) and product sub-details (e.g. tracks of audio CDs / chapters of books). In this application, MongoDB is used. The schema design will be focus more on the data usage. It is different from traditional RDBMS schema design. The

Sample Apps: Spring data MongoDB and JSF Integration tutorial (PART 1)

Image
In this year, I will start a new series of “Sample application Tutorials”. In this series of tutorial, a sample case study application will be built with different technologies. In this tutorial, sample JSF application with Spring Data MongoDB will be covered. Table of Contents: 1. Introduction to sample application (MongoShop Product Catalog) 2. MongoDB schema design and data preparation 3. JSF (PrimeFaces) and Spring data MongoDB Integration 4. Enquriy data with spring data repository and mongotemplate 5. Create, Edit and delete data Introduction to sample application (MongoShop Product Catalog) After this tutorial, a sample application (MongoShop Product Catalog) with the following functional requirement will be built: 1. Searching product with different criteria (e.g. sku, product type, title, stc) 2. Create a new product with different category. 3. Edit selected product details 4. Delete selected product from the enquiry screen. Presentation Layer:

Injecting Guice managed object into JSF View Scoped bean

In previous post, I demonstrate how to integrate JSF with Guice and MyBatis. However, my friend experiences some problem when he is using view scoped backing bean. He found that he cannot re-inject the service class after serialization. I have done some tricks to solve this problem.This is simply done by overriding the readObject() and writeObject() method. The BasePageBean in the previous post is changed as follow: BasePageBean.java package org.borislam.view; import java.io.IOException; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.io.Serializable; import javax.annotation.PostConstruct; import javax.faces.context.FacesContext; import javax.faces.context.Flash; import javax.servlet.ServletContext; import com.google.inject.Inject; import com.google.inject.Injector; import com.ppstation.PpContext; public abstract class BasePageBean implements Serializable{ private transient Injector injector; public BasePageBean() {} pu

Lightweight Web Application Framework: PrimeFaces (JSF) + Guice + MyBatis (PART 2)

In this part, I will continue to demonstrate the integration of JSF, Guice and MyBatis. DBCP connection pool and MYSQL database is used in persistence layer Integrate Google Guice with MyBatis In the previous post, we have created a ServletContextListener. Now, we just bind the BasicDataSourceProvider and JdbcTransactionFactory in the contextInitialized method. GuiceContextListener.java package org.borislam; import java.util.Properties; import javax.servlet.ServletContext; import javax.servlet.ServletContextEvent; import javax.servlet.ServletContextListener; import org.apache.ibatis.transaction.jdbc.JdbcTransactionFactory; import org.apache.log4j.xml.DOMConfigurator; import org.borislam.mapper.StaffMapper; import org.borislam.service.SimpleService; import org.borislam.service.impl.SimpleServiceImpl; import org.mybatis.guice.MyBatisModule; import org.mybatis.guice.datasource.dbcp.BasicDataSourceProvider; import org.mybatis.guice.datasource.helper.JdbcHelper; import com.google.