Skip to content

Instantly share code, notes, and snippets.

@asicfr
asicfr / pom.xml
Created October 8, 2012 14:56
struts2RestJpaBootstrap - pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>tutorial</groupId>
<artifactId>struts2RestJpaBootstrap</artifactId>
<version>1.0-SNAPSHOT</version>
<packaging>war</packaging>
<name>struts2RestJpaBootstrap</name>
@asicfr
asicfr / tree2
Created October 8, 2012 15:17
struts2RestJpaBootstrap - structure du projet avec boostrap twitter
+---src
+---main
+---java
+---resources
¦ +---META-INF
¦ +---template
¦ +---html5bootstrap
+---webapp
+---css
+---bootstrap-responsive.min.css
@asicfr
asicfr / web.xml
Created October 8, 2012 15:24
struts2RestJpaBootstrap - web.xml
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
<display-name>test1-struts2</display-name>
<welcome-file-list>
<welcome-file>index.html</welcome-file>
<welcome-file>index.htm</welcome-file>
<welcome-file>index.jsp</welcome-file>
<welcome-file>default.html</welcome-file>
<welcome-file>default.htm</welcome-file>
@asicfr
asicfr / Book.java
Created October 15, 2012 08:47
struts2RestJpaBootstrap - vo
package org.demo.vo.bean;
import java.io.Serializable;
import javax.persistence.*;
import javax.validation.constraints.* ;
import org.hibernate.validator.constraints.* ;
@asicfr
asicfr / EntityManagerHelper.java
Created October 15, 2012 08:53
struts2RestJpaBootstrap - persistence manager
package org.demo.util;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;
import javax.persistence.Persistence;
public class EntityManagerHelper {
private static final String JPA_TEST = "jpaderby";
private static final EntityManagerFactory emf = Persistence.createEntityManagerFactory(JPA_TEST);
@asicfr
asicfr / IServices.java
Created October 15, 2012 09:02
struts2RestJpaBootstrap - interface service
package org.demo.business.service;
import java.util.List;
public interface IServices<T, PK> {
public T load(PK id) ;
public void save(T entity);
@asicfr
asicfr / BookServices.java
Created October 15, 2012 09:02
struts2RestJpaBootstrap - book service
package org.demo.business.service;
import java.util.List;
import org.demo.util.EntityManagerHelper;
import org.demo.vo.bean.Book;
import org.demo.vo.dao.JpaBookDAO;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
@asicfr
asicfr / gist:3891593
Created October 15, 2012 09:10
struts2RestJpaBootstrap - url
- http://<host>:<port>/<root>/<domaine>/load/id (get)<br />
- http://<host>:<port>/<root>/<domaine>/delete/id (get ... oui le pur REST impose un delete http ...)<br />
- http://<host>:<port>/<root>/<domaine>/save (post)<br />
- http://<host>:<port>/<root>/<domaine>/search (post)<br />
@asicfr
asicfr / JpaBookDAO.java
Created October 15, 2012 08:49
struts2RestJpaBootstrap - dao
package org.demo.vo.dao;
import java.util.ArrayList;
import java.util.List;
import javax.persistence.EntityManager;
import javax.persistence.TypedQuery;
import javax.persistence.criteria.CriteriaBuilder;
import javax.persistence.criteria.CriteriaQuery;
import javax.persistence.criteria.Predicate;
@asicfr
asicfr / bookList.jsp
Created October 15, 2012 09:27
struts2RestJpaBootstrap - page liste
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
<!DOCTYPE html>
<%@ taglib prefix="s" uri="/struts-tags" %>
<html lang="en">
<head>
<meta charset="utf-8">
<title>BookStore</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="Book">
<meta name="author" content="asic">