Skip to content

Instantly share code, notes, and snippets.

@asicfr
asicfr / IServices.java
Created Oct 15, 2012
struts2RestJpaBootstrap - interface service
View IServices.java
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 Oct 15, 2012
struts2RestJpaBootstrap - book service
View BookServices.java
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 Oct 15, 2012
struts2RestJpaBootstrap - url
View gist:3891593
- 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 / bookList.jsp
Created Oct 15, 2012
struts2RestJpaBootstrap - page liste
View bookList.jsp
<%@ 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">
@asicfr
asicfr / book.jsp
Created Oct 15, 2012
struts2RestJpaBootstrap - page detail
View book.jsp
<%@ 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">
@asicfr
asicfr / GenericAction.java
Created Oct 15, 2012
struts2RestJpaBootstrap - generic action
View GenericAction.java
package org.demo.action;
import java.util.List;
import org.demo.business.service.IServices;
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.util.logging.Logger;
import com.opensymphony.xwork2.util.logging.LoggerFactory;
@asicfr
asicfr / Actions.java
Created Oct 15, 2012
struts2RestJpaBootstrap - action book
View Actions.java
package org.demo.action.book;
import java.util.List;
import org.demo.action.GenericAction;
import org.demo.business.service.BookServices;
import org.demo.business.service.IServices;
import org.demo.vo.bean.Book;
public class Actions extends GenericAction<Book, Integer>
@asicfr
asicfr / Actions-book-delete-validation.xml
Created Oct 15, 2012
struts2RestJpaBootstrap - Actions-book-delete-validation.xml
View Actions-book-delete-validation.xml
<?xml version="1.0"?>
<!DOCTYPE validators PUBLIC
"-//Apache Struts//XWork Validator 1.0.2//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
<validators>
<field name="current.id">
<field-validator type="required">
<message key="requiredfield"/>
</field-validator>
</field>
@asicfr
asicfr / Actions-book-save-validation.xml
Created Oct 15, 2012
struts2RestJpaBootstrap - Actions-book-save-validation.xml
View Actions-book-save-validation.xml
<?xml version="1.0"?>
<!DOCTYPE validators PUBLIC
"-//Apache Struts//XWork Validator 1.0.2//EN"
"http://struts.apache.org/dtds/xwork-validator-1.0.2.dtd">
<validators>
<field name="current.isbn" >
<field-validator type="requiredstring" >
<message key="requiredfield" />
</field-validator>
@asicfr
asicfr / CustomActionValidatorManager.java
Created Oct 15, 2012
struts2RestJpaBootstrap - CustomActionValidatorManager
View CustomActionValidatorManager.java
package org.demo.util;
import java.io.IOException;
import java.io.InputStream;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
You can’t perform that action at this time.