background preloader

Grails

Facebook Twitter

Spring IO '15 - Developing microservices, Spring Boot or Grails? An Example of Analysis Patterns: Observation. Querying by Association Redux. Groovy date: build list of all Fridays in 2011. JN0545-Dates. We use class Date for simple date processing: def today= new Date() println today def tomorrow= today + 1, dayAfter= today + 2, yesterday= today - 1, dayBefore= today - 2 println "\n$dayBefore\n$yesterday\n$today\n$tomorrow\n$dayAfter\n"assert today + 7 == today.plus(7) && today - 15 == today.minus(15) def d= today.clone() d++; assert d == tomorrow d= d.next(); assert d == dayAfter d--; assert d == tomorrow d= d.previous(); assert d == today assert tomorrow.after(today) assert yesterday.before(today) assert tomorrow.compareTo(today) > 0assert tomorrow.compareTo(dayAfter) < 0assert dayBefore.compareTo(dayBefore) == 0 def n= today.time println n today.time = 0 println today def sometimeAgo= new Date(0) assert sometimeAgo == today Other date and time processing can be done using the GregorianCalendar class: From Groovy 1.5.7 / 1.6.x, you may use Date.format() directly.

JN0545-Dates

The Grails Framework 2.1.0. // simple query Account.executeQuery("select distinct a.number from Account a") // using with list of parameters Account.executeQuery("select distinct a.number from Account a " + "where a.branch = ?

The Grails Framework 2.1.0

And a.created > ? ", ['London', lastMonth]) // using with a single parameter and pagination params Account.executeQuery("select distinct a.number from Account a " + "where a.branch = ? " Tablas Profesionales con JQGrid. Grails Tutorial - Part 3. In part one we created the domain layer and generated the controllers.

Grails Tutorial - Part 3

In part two we changed our layout, css, added jquery and jquery-ui, theme switcher and changed the homepage. In this post I'll cover changing the generated list page. We will add the jqgrid component and modify the Controllers to return json for our ajax requests. Grails with JqGrid inline edit with List() JQGrid. Grails, jQuery & the jQuery Grid - Part Four.

Grails one-to-many dynamic forms – train of thought. After searching around trying to find a good way to implement one-to-many dynamic forms in Grails, I have finally come across this post which does a very good job at explaining the details. What I was basically looking for is a clean way to implement saving my domain objects in the backend, rather than the hacked way I did by hand picking request parameters and manually setting up my domain objects (I’m still fairly new to Grails), and the official docs fail to shed the light on the subtle details I found in this post, which is why I decided to post my own version of the one-to-many dynamic forms but with a little bit more complex domain objects to illustrate the use of enums which also I found is a bit of a gray area in the docs (or at least maybe for me). Make sure you head over and read the original post, as I will not go through all the details already mentioned over there.

Blog Archive » one-to-many relationships in Grails forms. Here’s a scenario we see fairly often in our Grails applications. Parent object has a collection of Child objectsWe want the Parent’s create and edit GSPs to allow us to add/remove/update associated Child objectsThe controller should correctly persist changes to the collection of Child objects, including maintaining Child object ids so any other objects referencing them don’t get screwed up I found a really nice solution that avoids adding a lot of code to the controller to sift out added/changed/deleted collection members.

The original page seems to have disappeared, so here are copies from archive.org (easier to read) and Google cache (PDF). I was disappointed that the original page is gone, and I found some small errors in the sample code, so I thought it would be nice to document here. Mastering Grails: Authentication and authorization. In this article, I continue building a "tiny little blog" named Blogito.

Mastering Grails: Authentication and authorization

I stubbed out Users in the previous article ("Rewiring Grails with custom URIs and codecs") because the name field was a integral part of the URI. Now it's time to implement the User subsystem fully. You'll learn how to enable logins, limit activity based on whether or not the User is logged in, and even add in some authorization based on the User's role. Grails Example. An Army of Solipsists » Blog Archive » Accessing the GrailsApplication and ApplicationContext from domain classes without holders. The various holder classes in Grails (ApplicationHolder, ConfigurationHolder, etc.) are now deprecated and the plan was to remove them at some point since static variables cause problems. One example is deploying multiple Grails applications with the --nojars option, using jar files in the server’s shared classpath. If a class with a static field is loaded by the shared classloader, its value is shared by all callers.

Kaboom. We’re working on a fix but it doesn’t look like it’ll be ready for 2.0 final, so it’s still best to avoid their use. Grails Standalone Plugin @ GitHub. Generating PDFs for Fun and Profit with Flying Saucer and iText. PDFs are one of the most common and most significant document formats on the internet.

Generating PDFs for Fun and Profit with Flying Saucer and iText

Typically, developers must use expensive tools from Adobe or cumbersome APIs to generate PDFs. In this article, you will learn how to programmatically generate PDFs easily with plain XHTML and CSS using two open source Java libraries: Flying Saucer and iText. Craig Burke Blog : Creating Google Calendar in Grails – Part 1: The Model. Over this series of posts I’m going to look at recreating some of the basic functionality of Google Calendar including the capability of adding recurring events within Grails.

We’ll start by looking at the model. For a basic event, our model is very simple. We just need a title, a start and end time, a location and a description. Here’s what we’re starting with: class Event { String title String location String description Date startTime Date endTime Things get a lot more complicated when we start talking about repeating events though. Now think about the case where we want this event to happen every Monday without a specific end date. So lets take a look at the Google Calendar options for a repeating event to figure out what additional properties we might need: Ok, so we’re going to need to allow for different recurrence types (weekly, daily, monthly, or yearly).

Boolean isRecurring = false EventRecurType recurType Integer recurInterval = 1 Date recurUntil Integer recurCount DAILY( 'Daily' ), save() 2 Getting Started 2.1.0. (Quick Reference) Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith.

2 Getting Started 2.1.0

Introduction to Griffon. The Grails Framework 2.1.0. (Quick Reference) Authors: Graeme Rocher, Peter Ledbrook, Marc Palmer, Jeff Brown, Luke Daley, Burt Beckwith, Lari Hotari Version: 2.3.8 Java web development as it stands today is dramatically more complicated than it needs to be. Most modern web frameworks in the Java space are over complicated and don't embrace the Don't Repeat Yourself (DRY) principles. Dynamic frameworks like Rails, Django and TurboGears helped pave the way to a more modern way of thinking about web applications. Grails is a full stack framework and attempts to solve as many pieces of the web development puzzle through the core technology and its associated plugins.

All of these are made easy to use through the power of the Groovy language and the extensive use of Domain Specific Languages (DSLs) Grails in Production. Thursday, February 9th, 2012 There are a few gotcha’s when deploying a Grails war in a container like Tomcat.

Grails in Production

Most commonly are issues with stacktrace.log. Contribute a Tag. This page contains user submissions of custom tags that may or may not be included in the Grails core.

Contribute a Tag

For general information on using and creating custom tags see Add your tag below and please update this list, too: dateFormat Tag. Mastering Grails: Grails services and Google Maps. I've been building a trip-planner application since the first article in this series.

Mastering Grails: Grails services and Google Maps

Now that the basic Model-View-Controller (MVC) framework is in place, I'm ready to mix in some external technologies. Specifically, I'm going to add a map. I can say, "I'm taking a trip from Denver to Raleigh, with stops in San Jose and Seattle along the way," but a map would help describe the trip better. You probably know that Seattle and Raleigh are on opposite sides of the United States, but a map helps you visualize the distance between the two cities. To give you a rough idea of what the application will do by the end of this article, go to and type the IATA code DEN in the search box.

IntelliGrape/Grails-Google-Map-Plugin. Domain Patterns in Enterprise Projects. New Grails Spring Security Core Plugin - Eric on JavaEric on Java. Simplified Spring Security with Grails.