Showing posts with label Grails. Show all posts
Showing posts with label Grails. Show all posts

Monday, August 3, 2009

ANN: Grails RefCode Plugin 0.2

Marcel Overdijk released RefCode plugin May 2008. The plugin provides an easy solution for 'code/description' reference/lookup data. Often in your business model you have simple reference/lookup tables with just code and description columns; e.g. Country (uk=United Kingdom, nl=Netherlands, ...), OrderStatus (C=Cancelled, N=New, P=Pending, S=Shipped), OrganizationType, ...

The latest release of the plugin include the refCode Custom Constraint to make validation against the domain valued even easier.

Assuming you a have a domain of "USStates", you can now setup a constraint like so:


class Person {
String name
String street
String city
String state
String zip

static constraints = {
name()
street()
city()
state(refCode:"USStates")
zip()
}
}


You can find out more about the RefCode Plugin at: http://www.grails.org/Ref+Code+Plugin

Friday, June 5, 2009

J1 Thirsty Head : Groovy, Grails Griffon Videos

Scott Davis of Thirsty Head was able to get some Gr8 interviews at Java One.

They include many of the leaders of the Groovy, Grails, & Griffon community.

Here they are all in one place.

Interview with Dierk Koenig
Interview with Danno Ferrin, James Williams of Griffon
Interview with Graeme Rocher
Interview with Dave Klein
Interview with Geertjan Wielenga
Interview with Andres Almiray
Interview with Sven Haiges and Glen Smith
Interview with Guillaume Laforge
Interview with Robert Fischer

Sunday, May 24, 2009

Gr8Conf (Denmark 2009) - Photos

The following photos contain pics from Gr8Conf, the Groovy Technologies Conference.

http://mypict.me/show.php?id=15rX
http://mypict.me/show.php?id=15IO
http://mypict.me/show.php?id=16Qh
http://mypict.me/show.php?id=16ab
http://mypict.me/show.php?id=19nn
http://mypict.me/show.php?id=19jW
http://mypict.me/show.php?id=19dl
http://mypict.me/show.php?id=15IO
http://mypict.me/show.php?id=15AS
http://twitpic.com/5jsa2
http://twitpic.com/5hqf2
http://www.flickr.com/photos/frankvilhelmsen/sets/72157618368303059/

Tweets from Gr8Conf:
http://www.twazzup.com/search?q=gr8conf
http://www.twazzup.com/search?q=gr8conf


Griffon Shirt:
http://www.cafepress.com/griffongroovy

Saturday, May 23, 2009

Gr8Cong - Griffon Code @GitHub

The Code for the Griffon Desktop Front-end application to Graeme's Twitter Clone is available at GitHub

Really Good Blog post covering Gr8Conf

Really Good Blog post covering Gr8Conf: http://gettinggroovy.wordpress.com/category/gr8/

Gr8 Conf - Outstanding Success



Well the Gr8Conf was an outstanding success. The organizers Soeren Glasius and Guillaume Laforge put on Gr8 Conference, it will be hard to top.

Guillaume Laforge, Graeme Rocher, Paul King, Dierk Koenig, Jochen Theodorou, and many other Groovy technology giants were there. It was an honor to be in the presence of all that Groovy brain power, . . .

The attendees were pretty sharp too, . . . there were some gr8 questions and ideas shared. I've already started following on the Griffon ideas.

And Copenhagen, . . . What a wonderful place. Everyone was very kind and helpful. And the sights, . . . Many wonderful things to see and do.

I would like to give a special Thank you to Soeren for being such a Gr8 Host. He really took Gr8 care of everyone and made everyone feel at home. I would especially like to thank him for helping me and my family have fun and seeing the sights of Copenhagen and Denmark.

Thursday, July 3, 2008

Phone Number Custom Constraint for Grails

Grails contains really great Validators that you can use in your constraints. But it is missing one that I need for a project I am working on, . . . There is no PhoneNumber constraint. Luckily, I ran across Geoff Lane's Post: Build a Custom Validator in Grails with a Plugin

In Chapter 2 Regular Expressions section of Beginning Groovy and Grails, we show using a regular expression to validate phone numbers. Well, now I had all of the parts required to make a PhoneNumber Custom Validator.

Usage:


class party {
String name
String workPhone

static constraints = = {
workPhone(phoneNumber:true)
}



The Constraint:


import org.codehaus.groovy.grails.validation.AbstractConstraint
import org.springframework.validation.Errors

/**
* Phone Number Constraint
*
* The phone number constraint is used to validate phone number formats
*
* Registering the Constraint.
*
* App Registration Config.groovy
*
* org.codehaus.groovy.grails.validation.ConstrainedProperty.registerNewConstraint(
* PhoneNumberConstraint.NAME, PhoneNumberConstraint.class)
*

*
* Plugin Registration MyPlugin.groovy:
*
* def doWithSpring = {
* ConstrainedProperty.registerNewConstraint(PhoneNumberConstraint.NAME, PhoneNumberConstraint.class);
* }
*

*
* This plugin is based upon the following posts:
*
* http://www.zorched.net/2008/01/25/build-a-custom-validator-in-grails-with-a-plugin/
* http://www.zorched.net/2008/01/26/custom-validators-in-grails-in-a-single-app/
*
* @author Jim Shingler ShinglerJim at gmail.com
*/
class PhoneNumberConstraint extends AbstractConstraint {

private static final String DEFAULT_MESSAGE_CODE = "default.phoneNumber.invalid.message";
public static final String NAME = "phoneNumber";

private boolean validateConstraint

public void setParameter(Object constraintParameter) {
if (!(constraintParameter instanceof Boolean))
throw new IllegalArgumentException("Parameter for constraint ["
+ NAME + "] of property ["
+ constraintPropertyName + "] of class ["
+ constraintOwningClass + "] must be a boolean value");

this.validateConstraint = ((Boolean) constraintParameter).booleanValue()
super.setParameter(constraintParameter);
}

protected void processValidate(Object target, Object propertyValue, Errors errors) {
if (validateConstraint && !validate(target, propertyValue)) {
def args = (Object[]) [constraintPropertyName, constraintOwningClass,
propertyValue]
super.rejectValue(target, errors, DEFAULT_MESSAGE_CODE,
"not." + NAME, args);
}
}

boolean supports(Class type) {
return type != null && String.class.isAssignableFrom(type);
}

String getName() {
return NAME;
}

/**
* This is where the real work is. Use a regular expression to validate
* the phone number.
*
* The core logic of the constraint is implemented as its own method to make the
* constraint easier to test.
*/
boolean validate(target, propertyValue) {
propertyValue ==~ /^[01]?\s*[\(\.-]?(\d{3})[\)\.-]?\s*(\d{3})[\.-](\d{4})$/
}
}


The real work is in the validate function.

As you can see, creating a custom constraint is really pretty easy. Just make sure that you follow the directions in the constraint class comments to register the constraint.

Friday, June 13, 2008

BGG – Beginning Groovy and Grails – June 23

BGG is imminent. It is scheduled for release on June 23.

Here is a brief overview of the books structure.

Chapter 1 - Introduction to Groovy


This chapter defines Groovy, explains hot to install it, and then through example, demonstrates its power, flexibility, and readability compared to the Java language

Chapter 2 – Groovy Basics


This chapter explains the basic Groovy syntax, structures, and tools

Chapter 3 – More Advanced Groovy


This chapter goes beyond the Groovy basics to cover unit testing, XML processing, templating, and metaprograming. In includes a discussion on domain-specific languages (DSL).

Chapter 4 – Introduction to Grails

This chapter defines the Grails architecture and its features. It then explains how to install Grails and get started developing applications with scaffolding.

Chapter 5 – Building the User Interface

This chapter explains how to combine Groovy Server Pages (GSP), controllers, Grails tags, templates, and Cascading Style Sheets (CSS) to build a basic user interface.

Chapter 6 – Building Domains and Services


This chapter explains how Grails uses a domain-driven approach to developing applications and how domain objects can be persisted using the powerful Grails Object Relational Mapping (GORM) framework. The chapter concludes by showing how you organize application logic into reusable and injectable services.

Chapter 7 – Security in Grails

This chapter explains and demonstrates the alternative security options available in Grails.

Chapter 8 – Web 2.0 – Ajax and Friends


This chapter explains how to add usability to your application through adding Ajax functionality, searching, and RSS.

Chapter 9 – Web Services

This chapter shows how to expose parts of your application to other clients using representational state transfer (REST) web services.

Chapter 10 – Reporting


This chapter explains how to use JasperReports and iReports to expose reports in multiple formats, including PDF, HTML, XML, and XLS.

Chapter 11 – Batch Processing

This chapter showcases how to schedule jobs to run automatically and how to generate e-mail messages.

Chapter 12 – Deploying and Upgrading


This chapter describes how to configure, package, and deploy Grails applications to alternative database and application servers.

Chapter 13 – Alternative Clients


This chapter builds a Swing client using Groovy that interacts with the Grails application through the RESTful web services built in Chapter 9

You can order your copy from Amazon, Beginning Groovy and Grails

Wednesday, May 21, 2008

Beginning Groovy and Grails - New Book

You want to learn Groovy and Grails and don’t know where to start. The wait is almost over and your journey is about to begin. Beginning Groovy and Grails (BGG) is an ideal primer for learning Groovy and Grails.

BGG will take you from installation of Groovy and Grails all the way to developing a Collaborative Todo web application and a Groovy Swing user interface. Along the way, you will learn how to uses Web 2.0 and AJAX with Grails. You will explore 3 different security plugins. You will learn how use Jasper Reports and Quartz Plugin. You will develop RESTful web services. By the time you have completed your journey you will have a solid understanding of Groovy and Grails. You will be ready to start you’re your next assignment using Groovy and Grails.

Stay tuned to this Blog, . . . more information is coming. You can pre-order your copy of Beginning Groovy and Grails from Amazon.

Sunday, March 30, 2008

Holy Grail of 3 Column Layout

While Grails really makes the MVC portion of web development easier, Cascading Style Sheets (CSS) is still really tough. I wanted a 3 Column layout with a header and footer created using CSS. This sounds easy enough, but it was more difficult than you would think. Especially if you want it to work with multiple browsers.

I spent several hours working on it, more than I would like to admit. Then I ran across Matthew James Talyor's work on 3 column liquid layouts. Matthew did a really nice job and it works exactly as you would expect. So I tried to weave it into a site I was creating. I was using Firefox and everything was going great until I tried to bring it up in Explorer. Ooops!

To make a long store short, I went back to the beginning and scrapped all my pre-existing CSS and started from Matthews. That did the trick. It rendered correctly in Firefox and Explorer both.



I was so happy figured I would probably use this layout again. So, I created a generic Grails application preconfigured to use the 3 column layout. As you would expect, all of the real work is in main.gsp and a new css file I created css file holygrail.css.

So in the spirit of hoping to make someone else's life a little easier, here are the main.gsp and holygrail.css files.

main.gsp


<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html>
<head>
<title><g:layoutTitle default="www.Grails.org"/></title>
<link rel="stylesheet" href="${createLinkTo(dir: 'css',
file: 'holygrail.css')}"/>
<meta http-equiv="Content-Type" content="application/xhtml+xml; charset=utf-8"/>
<meta name="description" content="The Holy Grail 3 column Liquid Layout. Pixel widths. Cross-Browser. Equal Height Columns."/>
<meta name="keywords" content="The Holy Grail 3 column Liquid Layout. Pixel widths. Cross-Browser. Equal Height Columns."/>
<meta name="robots" content="index, follow"/>
<link rel="shortcut icon" href="${createLinkTo(dir: 'images', file: 'favicon.ico')}" type="image/x-icon"/>
<g:layoutHead/>
</head>
<body>
<!--
This is a Grails example of the Holy Grail 3 column Liquid Layout work by Mathew Taylor.
For more information, please see his original work at:

http://matthewjamestaylor.com/blog/ultimate-3-column-holy-grail-pixels.htm
-->

<div id="header">
<!-- Header start -->
<g:render template="/common/header"/>
<!-- Header end -->
</div>
<div class="colmask holygrail">
<div class="colmid">
<div class="colleft">
<div class="col1wrap">
<div class="col1">
<!-- Column 1 start -->
<g:layoutBody/>
<!-- Column 1 end -->
</div>
</div>
<div class="col2">
<!-- Column 2 start -->
<g:render template="/common/leftbar"/>
<!-- Column 2 end -->
</div>
<div class="col3">
<!-- Column 3 start -->
<g:render template="/common/rightbar"/>
<!-- Column 3 end -->
</div>
</div>
</div>
</div>
<div id="footer">
<!-- Footer start -->
<g:render template="/common/footer"/>
<!-- Footer end -->
</div>

</body>
</html>



holygrail.css



/* General styles */
body {
margin:0;
padding:0;
border:0; /* This removes the border around the viewport in old versions of IE */
width:100%;
background:#fff;
min-width:600px; /* Minimum width of layout - remove line if not required */
/* The min-width property does not work in old versions of Internet Explorer */
font-size:90%;
}
a {
color:#369;
}
a:hover {
color:#fff;
background:#369;
text-decoration:none;
}
h1, h2, h3 {
margin:.8em 0 .2em 0;
padding:0;
}
p {
margin:.4em 0 .8em 0;
padding:0;
}
img {
margin:10px 0 5px;
}
/* Header styles */
#header {
clear:both;
float:left;
width:100%;
}
#header {
border-bottom:1px solid #000;
}
#header p,
#header h1,
#header h2 {
padding:.4em 15px 0 15px;
margin:0;
}
#header ul {
clear:left;
float:left;
width:100%;
list-style:none;
margin:10px 0 0 0;
padding:0;
}
#header ul li {
display:inline;
list-style:none;
margin:0;
padding:0;
}
#header ul li a {
display:block;
float:left;
margin:0 0 0 1px;
padding:3px 10px;
text-align:center;
background:#eee;
color:#000;
text-decoration:none;
position:relative;
left:15px;
line-height:1.3em;
}
#header ul li a:hover {
background:#369;
color:#fff;
}
#header ul li a.active,
#header ul li a.active:hover {
color:#fff;
background:#000;
font-weight:bold;
}
#header ul li a span {
display:block;
}
/* 'widths' sub menu */
#layoutdims {
clear:both;
background:#eee;
border-top:4px solid #000;
margin:0;
padding:6px 15px !important;
text-align:right;
}
/* column container */
.colmask {
position:relative; /* This fixes the IE7 overflow hidden bug and stops the layout jumping out of place */
clear:both;
float:left;
width:100%; /* width of whole page */
overflow:hidden; /* This chops off any overhanging divs */
}
/* holy grail 3 column settings */
.holygrail {
background:#ff9; /* Right column background colour */
}
.holygrail .colmid {
float:left;
width:200%;
margin-left:-200px; /* Width of right column */
position:relative;
right:100%;
background:#fff; /* Centre column background colour */
}
.holygrail .colleft {
float:left;
width:100%;
margin-left:-50%;
position:relative;
left:400px; /* Left column width + right column width */
background:#FFD8B7; /* Left column background colour */
}
.holygrail .col1wrap {
float:left;
width:50%;
position:relative;
right:200px; /* Width of left column */
padding-bottom:1em; /* Centre column bottom padding. Leave it out if it's zero */
}
.holygrail .col1 {
margin:0 215px; /* Centre column side padding:
Left padding = left column width + centre column left padding width
Right padding = right column width + centre column right padding width */
position:relative;
left:200%;
overflow:hidden;
}
.holygrail .col2 {
float:left;
float:right; /* This overrides the float:left above */
width:170px; /* Width of left column content (left column width minus left and right padding) */
position:relative;
right:15px; /* Width of the left-had side padding on the left column */
}
.holygrail .col3 {
float:left;
float:right; /* This overrides the float:left above */
width:170px; /* Width of right column content (right column width minus left and right padding) */
margin-right:45px; /* Width of right column right-hand padding + left column left and right padding */
position:relative;
left:50%;
}
/* Footer styles */
#footer {
clear:both;
float:left;
width:100%;
text-align: center;
border-top:1px solid #000;
}
#footer p {
padding:10px;
margin:0;
}




Tuesday, December 11, 2007

Grails 1.1 RC3 - Released

Grails 1.1 RC-3 has been released and it includes Groovy 1.5.

Wow, This is really getting exciting.

You can download it at http://www.grails.org/Download

Sunday, December 2, 2007

Grails Exchange 2007 - Presentations posted

The Grails Exchange 2007 Presentations are Podcasts have been posted.

You can find it on the Grails Exchange site: http://grails-exchange.com/. (Just click on the sessions, you will find a PDF of the slides and google video.)

I have listed to many of the Podcasts, It looks like it was a really good conference. I wish I could have been there.

Check it out.