background preloader


Facebook Twitter

Example of template and taglib with grails. In this example I will show how templates and taglibs can be used to create components.Imagine that you are creating application for managing projects.

Example of template and taglib with grails

When working with an application you are always working within a scope of project. So all the time you need to be able to change project you are working with. So excellent place for selection would be top of the each page within application. So lets go through steps creating such application. To create project in the command line type:grails create-app project_manager Then create Project domain class:grails create-domain-class Project Change the code of Project class so it looks this way: class Project { String title String description.

Enabling the AJAX Spinner in Grails. For standard page requests, browsers use an animated icon as an indicator to the user that the browser is waiting for the request to complete.

Enabling the AJAX Spinner in Grails

However, for AJAX calls that are initiated via JavaScript in a separate thread the browser icon does not animate. So, typically the application developers use an animated icon within the page to notify the user the page is waiting for a request to complete. Nine Lessons from building a Grails / Flex / Flash website. I just finished putting the finishing touches on phase one of our video and animation heavy Flash / Grails / Flex site.

Nine Lessons from building a Grails / Flex / Flash website

We spent about 2 months on this site, figuring out how to get Flex, Flash and Grails to work together nicely, and I thought I would share some of the lessons learned in this post. The application is a brochure-ware product that features rotating grills, and is back-ended by a Grails CMS. Grails was chosen over other toolkits like the Microsoft Community Server and Expression Engine because it provided the flexibility we needed to tackle a highly customized Flex RIA. Grails also allowed us to provide multiple views of our content for search engines and non-Flash customers. Architecturally, our app is. Flex File Upload using Grails Backend. This file upload application is based off the one by Nocturnal at Coding Cowboys, a Flex client with a PHP backend.

Flex File Upload using Grails Backend

The client has been stripped down to it's core functions and PHP replaced with a Grails backend. The Grails backend is a file controller with an action defined: def upload = { if(request.method == 'POST') { Iterator itr = request.getFileNames(); while(itr.hasNext()) { MultipartFile file = request.getFile(; File destination = new File(file.getOriginalFilename()) if (! // Trigger an Event.COMPLETE event, notifying the Flex client response.sendError(200,'Done'); }} This is capable of uploading multiple files at once and can be tested using a view gsp: The Flex client has been pared down to 3 main functions, adding files to the upload list, removing them from the list and finally uploading the files to the server. First the imports, global variables and initializer: Querying associations in Grails with HQL, Criteria and HibernateCriteriaBuilder.

A thing I was playing with today was many-to-many relationships in Grails to create a Tag Cloud.

Querying associations in Grails with HQL, Criteria and HibernateCriteriaBuilder

To create a Tag Cloud, I must have a set of key/value pairs, each with a label and a value of the label, which could look like this: ['Java': 5, 'Grails': 16, 'Groovy': 12] But to query this, I need to query a many to many relationship and produce the above result. This blog will describe how to do this with HQL, Criteria and the HibernateCriteriaBuilder. Domain My current domain looks like this: (This picture is unfortunately missing a Tag attribute in the Snippet class). As you can see, a Snippet can have multiple Tags, while a Tag can belong to multiple Snippets. Options We have three options in this case.

Executing External Processes From Groovy. Goal: execute a program via a command line from groovy code Option 1: executing a string Gotchas: Take care if you wish to pass a quoted argument that contains white space – it will be split into multiple arguments, e.g.: """executable "first with space" second""".execute()

Executing External Processes From Groovy

Directories. The Holy Grail 3 column Liquid Layout. Pixel widths. Cross-Browser. Equal Height Columns. Pixel dimensions of the holy grail layout In this layout the side column widths are in pixels and the centre page adjusts in size to fill the rest of the screen.

The Holy Grail 3 column Liquid Layout. Pixel widths. Cross-Browser. Equal Height Columns.

Vertical dimensions are left unset so they automatically stretch to the height of the content. Layouts that use pixel widths are great for images because you can make them fit perfectly within a column without gaps. The nested div structure I've colour coded each div so it's easy to see: The header, colmask and footer divs are 100% wide and stacked vertically one after the other. Try my Quirks-mode free and IE conditional comments free version of this layout. No CSS hacks The CSS used for this layout is 100% valid and hack free. SEO friendly 2-1-3 column ordering The higher up content is in your page code, the more important it is considered by search engine algorithms.

Equal height columns It doesn't matter which column has the longest content, the background colour of all columns will stretch down to meet the footer. No Images Safari. Framework Reference Documentation. Sandbox. Last updated by pledbrook 1 year ago Ideas Another test - please ignore.


汉语/漢語 This page is an ideas dump for proposed features. None of what is on here is likely to be implemented yet (or it may be but no documentation exists for it!). Potentially obsolete proposals: Graduates from the Sandbox Challenging problems and recipes. Grails - Reference. Cookbook Examples. Recent Entries (Last 7 Days)