We are using the grails asynchronous mail plugin in our project and noticed that the sent mails never gets deleted from the database. This was an issue because we were sending out a lot of mails and all of them had PDF attachments of about 500 KB to 1 MB each. A sure recipe for […]
Recently while working on my new Project I have the requirement where each domains need to have dateCreated and lastUpdated fields. So rather than adding these fields to each of the domain class we added them to template. Now whenever we create a domain class these two fields are added to it automatically. Next thing […]
Again I am going to showcase few useful methods that GORM provides us to check whether the object is dirty or not (again from grails.org). First question could be what is a dirty object? An object is dirty if the current state of its properties does not match with its persistence values. It happens when […]
Sometimes our services are so tightly bound with the Controllers that we actually think that a new Service instance should be get created on every request or the member variables in the services can be defined only for the current user. But by default the Services are “singleton” scoped which means that clients of a […]
In one of our recent project, we made quite a good use of Grails Jasper plugin (v-0.9.7) to generate reports in the form of PDFs and Excel sheets. The reports contain sub-reports, which in many cases, contain sub-reports again. The way to pass parameters to sub-reports at the deeper level is to use the following […]
We can easily validate domain classes and command objects using static constraints. But how about validating DTOs or any groovy class in src/groovy folder. The answer is YES, they can be validated too. Follow two simple steps: 1. Add annotation ‘@Validateable’ above the class. 2. Declare the package to be validated in Config.groovy as: grails.validateable.packages […]
Hi all, In my recent grails project, i needed to paginate on an array list, so I wrote a function and thought would share it with you all. public List getFilteredList(int max, int offset) { max = Math.min(max ?: 25, 100) offset = (offset && offset>0) ?: 0 List names = getNames() //Loads the complete […]
Ajax (shorthand for Asynchronous JavaScript and XML) is used to retrieve data from the server asynchronously without interfering with the display and behavior of the existing page. Forgetting this asynchronous behavior will produce incorrect result if it depends on the response from Ajax call. Lets take an example(I am using JQuery to illustrate the example). […]
This blog might help you to speed up your bootstrap process, especially when you need to populate records in tables. Earlier we used populate our database table by reading line by line from a CSV file and creating Domain Class object ad Save. But this was taking a huge time. And in our case, this […]
A few days back I had chance to work on a googleApp using GORM-JPA plugin,version (0.7.1). I came across a few problems which are as given below. Consider the domain : Country -> has many States. At first it appeared that the one to many relationships are to be managed using annotations like : Country […]
It’s common requirement when we work on some portal – we need to provide support for various languages. messages.properties/ResourceBundle is out of the scope of this post. Here I am just mentioning – how to switch to a different language taking an advantage of GRAILS On your view (gsp) page add following – English French […]
Hi Friends, Recently in one of the project I was working on, had a long web page and updates used to happen only through ajax calls that means no page refresh. The status messages used to appear on the top of the page, the user had no way but to scroll up to see the […]