Archive for the ‘Tutorials’ Category

Dirt Simple EXTJS Grid on Grails

Monday, August 25th, 2008

At my current contract, I've been using the popular EXTJS javascript library. In order to get up to speed faster, I've started a small project to assist my learning. I thought about using a number of back ends to support my project, but decided on Grails after reading about the built-in ...

Custom taglibs with facelets

Wednesday, August 20th, 2008

Creating tag libraries using facelets might be cool but needs more redundant infrastructure than the new JSP tag libs (which doesn't need tld declaration or web.xml context params). However once your done, building reusable tags on the fly (with no java code) can be pretty slick. Here are the steps for ...

Maven Jetty Plugin

Wednesday, August 20th, 2008

It's a common occurrence in the Java consulting world, as ridiculous as it is, I see it all the time. I do into a new development shop to help build a large webapp. Since it's a large webapp, someone has decided they needed to buy licenses for ...

Automated Unit Testing with DBUnit, Hsqldb in Spring & Hibernate projects

Saturday, June 7th, 2008

If your project has a lot of unit testing in Java and you use continuous builds (CruiseControl) to automate, it is often difficult to automate tests which connect to Database (Dao and integration tests). For most companies, having a dedicated Oracle schema for testing is expensive. Also, sometimes, developers ...

Grails Extended ManyToMany GORM Example

Friday, June 6th, 2008

This is a variation on this article. Having never been a big fan of writing XML, I'll gladly opt for the XML-less version. The first example online I found has some formatting issues and just seems a little hard to follow. My step by step example follows after the jump. Call ...

Configuring Tomcat 5.5 JNDI Datasources with Spring

Wednesday, June 4th, 2008

First of all, make sure you're looking at the Tomcat 5.5 JNDI HowTo, not the Tomcat 5, and definitely not Tomcat 4. Yes, I know this sounds obvious, but once you start googling you'll find it's hard to distinguish the versions. Place a context definition in /META-INF/context.xml - this is the ...

Understanding Composite-id with JPA Identifiers @Id Vs @EmbeddedId Vs @IdClass

Sunday, May 11th, 2008

Note - If you're looking for Hibernate Composite-Id example using xml configuration, read our earlier post here. Entities must define an id field. Typically a generated id is fine for most cases, but sometimes we need to add multiple fields corresponding to the database primary key. (legacy database?). The id can ...

Spring Security -> Replacing Acegi

Thursday, May 1st, 2008

Astute readers of my last Acegi article will note that Acegi has been assimilated into the Spring project, and is now called Spring Security. This next example is how I was able to get Spring Security running on my webapp. I decided early on that I did not want to mess ...

Acegi 1.0.8 Example (Life Without the SecurityEnforcementFilter)

Monday, April 28th, 2008

Note; This was my first day of adding Acegi to an existing webapp. You can find a lot of Acegi security framework examples on the web these days. Unfortunately, nearly all of the examples use Acegi use the pre 1.0 version, which is before someone removed the SecurityEnforcementFilter.. The official description ...

Step by Step Tutorials - DWR with Spring, Ajax - Dynamic drop down lists

Wednesday, November 7th, 2007

Scenario: A simple jsp page with a standard drop down box. A Selection criteria (could be another drop down box and a couple of check boxes) to change the values in these drop down box dynamically, without submitting the page. What you will learn: Configure dwr.xml with spring beans Configure application contexts for ...

Example code, sending emails using Spring SimpleMailMessage, MimeMessagePreparator and Velocity Templates

Monday, November 5th, 2007

When I first wrote my custom Email utlity 4 years back using JavaMail, it spread well over hundred lines of code. Looking at Spring's out of the box functionality for sending Emails with attachements & velocity templates makes you wanna feel sorry for your old code. The reference doc by ...

Marshalling and Unmarshalling Xml - Step by Step tutorial with Castor in 10 mins

Saturday, July 14th, 2007

If you want a simple way to marshall / unmarshall your pojo -> Xml files, Castor could be very handy. Before reading the docs on the setup and overview and breaking your nerves on it's rich feature set, lets get going in less than 10 minutes. Castor is extremely powerful ...