TO THE NEW Blog PAGES

Grails

Ordering using Grails CreateCriteria

Recently, in my project I had to implement search functionality. I used grails createCriteria to implement it.Now I needed to apply the sorting on the result returned. My domain was something like this : class MyEntity { OrganizationName orgName PersonName personName static constraints = { orgName(‘nullable’, true) personName(‘nullable’, true) } } class OrganizationName { String […]

Grails

Handy g:uploadForm

It is very easy and handy to use Grails <g:uploadForm> tag insteed of using HTML <form> tag or grails <g:form> tag, as you don’t need to set the enctype attritbute to multipart/form-data (as in case of HTML <form> tag or grails <g:form> tag) to work with file upload. for example insteed of using: … ,We […]

niraj
niraj
Read

Grails

Serializing objects to XML

XStream is a simple Java library to serialize objects to XML and back again. Suppose we have a Person class as follows: public class Person { private String name private int age private Address address } public class Address { private String street private String city private String state private String country } The following […]

Grails

Grails : Difference b/w two dates with fine-grained details

Hi Friends, To retrieve difference between two dates with finer details which would display their difference as 2 years 7 weeks 3 days 2 hours 5 mins ago is given below. /** * Returns differnce b/w new Date and old date as Map holding difference in years, weeks, days, hrs, mins & secs */ public […]

Technology

Vi Editor

I will try my best to give you some tips to make Vi look more interesting and easy to use for all you guys. I have read few articles and tutorials about Vi and will try to summarize some key points here. First things, first : WHAT IS Vi? Vi is NOT just an editor. […]

Grails

Create JSON object Using Grails converter (Only selective fields from lists of objects)

This post might help you if you want to get JSON (JavaScript Object Notation) Object on browser. Grails framework provides you very efficient way to achieve this. For this you need to import grails JSON convertor in your code. import grails.converters.JSON Below is the code snapshot which converts java based lists of Objects to JSON […]

Salil
Salil
Read

Technology

How to allow non-root user to start/stop Apache process on a *nix server

Recently, I had to write a script to deploy a Grails application on a cluster of 7 servers without prompting for any kind of passwords. The load balancer was configured so as NOT to direct any request to the node, if the Apache process is not running on the server. So, my script to do […]

Grails

Grails : Save time while writing Integration tests

Hi Friends, I always used to spend lot of time writing integration tests as running even a single test involves loading the complete application, which includes loading complete database every time. Then I realized that data which I use for testing is always the same, why can’t we restore the database once created, before we […]

Technology

Jasper report – Pattern for Negative Numbers

Recently had a requirement to print Currency values with a condition that negative numbers must be inside brackets. It can be done by using pattern property in tag. the part before semicolon is for positive numbers and part following semicolon is for negative number. ____________________ Hitesh hitesh@intelligrape.com Intelligrape Software ____________________

Grails

Injecting Method to trim string length on gsp pages

Restricting the length of a string on gsps is a common scenario in most of our projects. Groovy’s metaprogramming magic made it too simple for me. I added the following lines of code to Bootstrap.groovy: Object.metaClass.trimLength = {Integer stringLength -> String trimString = delegate?.toString() String concatenateString = “…” List separators = [“.”, ” “] if […]

Technology

iReport 3.7

Shamsuddin has described iReport 3.7 inside out in his latest book ,this book is perfect for new learners. Best thing about this one is , that it has explained each option available in best manner possible making it a delight to read. What I liked about this one is one is in chapter named “iReport […]

Grails

List of fields in error of a domain instance

I have been working with domain and command object validation. I needed to get all the fields in error as a list so that I can display a single line error message like : please enter valid values in the following fields- filed1, field2. Another use case was to check the list of fields for […]