Skip to content

Instantly share code, notes, and snippets.

View jacobheric's full-sized avatar

Jacob Heric jacobheric

View GitHub Profile
@jacobheric
jacobheric / multiple-module-maven-pom.xml
Created March 13, 2011 00:19
A multiple module maven parent pom snippet
<artifactId>youbrew-parent</artifactId>
<packaging>pom</packaging>
<name>Youbrew-ExtJS Parent Application</name>
<modules>
<module>youbrew-domain</module>
<module>youbrew-service</module>
<module>youbrew-persist</module>
<module>youbrew-webapp</module>
@jacobheric
jacobheric / another-multiple-module-maven-dependency-example-pom.xml
Created March 13, 2011 00:24
Multiple module maven pom dependency example
<artifactId>youbrew-webapp</artifactId>
<packaging>war</packaging>
<name>Youbrew Web Application</name>
<dependencies>
<dependency>
<groupId>com.jacobheric.youbrew-extjs</groupId>
<artifactId>youbrew-service</artifactId>
<version>0.1-SNAPSHOT</version>
</dependency>
@jacobheric
jacobheric / vanilla-jpa-persistence-annotations-hibernate.java
Created March 13, 2011 00:31
Annotations based JPA entity persistence using Hibernate snippet
@Entity
public class Recipe implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.AUTO)
private Long id;
private String name;
@Column(name = "brew_notes")
private String brewNotes;
@jacobheric
jacobheric / consolidated-dao-generics.java
Created March 13, 2011 00:44
A dao implementation that consolidates CRUD operations using Java generics
@Repository("baseDAO")
public abstract class BaseDAOImpl<T, ID extends Serializable> implements IBaseDAO<T, ID> {
@Autowired
protected SessionFactory sessionFactory; //injected by Spring container
@SuppressWarnings("unchecked")
private Class<T> clazz;
@SuppressWarnings("unchecked")
public BaseDAOImpl() {
@jacobheric
jacobheric / spring-mvc-jackson-json-config.xml
Created March 13, 2011 01:51
Spring MVC Jackson Configuration snippet
<!-- Jackson ObjectMapper that can serialize and deserialize to and from JSON. -->
<bean id="jacksonObjectMapper" class="com.jacobheric.youbrew.utils.json.JsonObjectMapper" />
<bean class="org.springframework.web.servlet.mvc.annotation.DefaultAnnotationHandlerMapping"/>
<bean class="org.springframework.web.servlet.mvc.annotation.AnnotationMethodHandlerAdapter">
<property name="webBindingInitializer">
<bean class="com.jacobheric.youbrew.utils.json.GlobalBindingInitializer"/>
</property>
@jacobheric
jacobheric / jsp-view-bootstrapping-extjs.xhtml
Created March 13, 2011 01:59
A jsp view bootstrapping extjs
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/>
<title><fmt:message key="app.title"/></title>
<link rel="stylesheet" type="text/css" href="<c:url value="/ext-3.3.0/resources/css/ext-all.css" />" media="screen, projection"/>
<link rel="stylesheet" type="text/css" href="<c:url value="/styles/youbrew.css" />" media="screen, projection"/>
<script type="text/javascript" language="JavaScript" src="<c:url value="/ext-3.3.0/adapter/ext/ext-base-debug.js"/>"></script>
<script type="text/javascript" language="JavaScript" src="<c:url value="/ext-3.3.0/ext-all-debug.js"/>"></script>
<script type="text/javascript" src="<c:url value="/scripts/utils/App.js"/>"></script>
@jacobheric
jacobheric / sample-extjs-app.js
Created March 13, 2011 02:13
A sample extjs crud grid and form app (building on the extjs example offering)
Ext.ns("youbrew");
// Application instance for showing user-feedback messages.
var App = new Ext.App({});
// HttpProxy instance, utilizes parameter "api" object here constructing url manually.
var proxy = new Ext.data.HttpProxy({
api: {
read : {url: 'recipe', method: 'GET'},
create : {url: 'recipe', method: 'POST'},
@jacobheric
jacobheric / spring-mvc-annotations-controller.java
Created March 13, 2011 14:54
An annotated spring mvc controller snippet offering restful json services
@Controller
@RequestMapping(value="/recipe")
public class RecipeController extends BaseController implements Serializable {
private static final long serialVersionUID = 1L;
private static final Logger log = LoggerFactory.getLogger(RecipeController.class);
@Autowired
private IRecipeService recipeService;
@jacobheric
jacobheric / sample-extjs-app-cont.js
Created March 13, 2011 15:52
Sample extjs app continued, grid and form setup
var textField = new Ext.form.TextField();
// Grid-columns with meta-data from backend.
var recipeColumns = [
{header: "ID", width: 40, sortable: true, dataIndex: 'id'},
{header: "Name", width: 100, sortable: true, dataIndex: 'name', editor: textField},
{header: "Brew Notes", width: 180, sortable: true, dataIndex: 'brewNotes', editor: textField},
{header: "Taste Notes", width: 180, sortable: true, dataIndex: 'tasteNotes', editor: textField},
{
header: 'Yeast',
@jacobheric
jacobheric / extjs-example-grid-search-paging.js
Created March 13, 2011 16:02
An example Ext JS CRUD grid with search and paging
Ext.ns('youbrew', 'youbrew.recipe');
/**
* youbrew.recipe.Grid
* A recipe EditorGridPanel, clearly derived from the extjs examples.
*/
youbrew.recipe.Grid = Ext.extend(Ext.grid.EditorGridPanel, {
renderTo: 'recipe-grid',
iconCls: 'silk-grid',
frame: true,
title: 'YouBrew Recipe Grid',