Home » Tag Archives: Grails (page 3)

Tag Archives: Grails

Grails Goodness: Using Groovy SQL

grails-logo

In a previous post we learned how we can use Hibernate native SQL queries in our Grails application. We can also execute custom SQL with Groovy SQL. We must create a new instance of groovy.sql.Sql in our code to execute SQL code. The easiest way is to use a javax.sql.DataSource as a constructor argument for the groovy.sql.Sql class. In a ...

Read More »

Grails Goodness: Customize Root Element Name Collections for XML Marshalling

grails-logo

When we convert a List or Set to XML using the Grails XML marshalling support the name of the root element is either <list> or <set>. We can change this name by extending the org.codehaus.groovy.grails.web.converters.marshaller. xml.CollectionMarshaller. We must override the method supports() to denote the type of collection we want to customize the root element name for. And we must ...

Read More »

Grails Goodness: Cleaning Up

grails-logo

When we use for example the compile or war command Grails will create files and stores them by default in the project’s working directory. The location of the project working directory can be customized in our grails-app/conf/BuildConfig.groovy configuration file. We remove the generated files with the Grails clean command. This command will remove all compiled class files, the WAR file, ...

Read More »

Using database views in Grails

grails-logo

This post is a quick explanation on how to use database views in Grails. For an introduction I tried to summarize what database views are. However, I noticed I cannot describe it better than it is already done on Wikipedia. Therefore I will just quote the Wikipedia summary of View (SQL) here:           In database theory, ...

Read More »

Grails: Using Hibernate Filters

grails-logo

The Grails Hibernate Filters plugin makes it possible to use Hibernate Filters with GORM. Hibernate Filters provide additional restriction rules that can be applied to classes and collections. The Hibernate Filters plugin makes it possible to use this functionality with GORM inside Grails applications. Let’s look at an example to see how filters can help us. Assume we have the ...

Read More »

Automatically converting password hashes in Grails spring-security-core

grails-logo

I was looking at this Stack Overflow question about converting password hashes and realized that it’s possible and rather convenient when using the spring-security-core plugin to automate the process. To start, we’ll need a PasswordEncoder that can work with both algorithms. Here I’m assuming that you’ll be converting from SHA-256 (optionally with a salt) to bcrypt, but the general approach ...

Read More »

Grails Goodness: Generating Raw Output with Raw Codec

grails-logo

Since Grails 2.3 all ${} expression output is automatically escaped on GSPs. This is very useful, because user input is now escaped and any HTML or JavaScript in the input value is escaped and not interpreted by the browser as HTML or JavaScript. This is done so our Grails application is protected from Cross Site Scripting (XSS) attacks. But sometimes ...

Read More »

Grails Goodness: Namespace Support for Controllers

grails-logo

In a Grails application we can organize our controllers into packages, but if we use the same name for multiple controllers, placed in different packages, then Grails cannot resolve the correct controller name. Grails ignores the package name when finding a controller by name. But with namespace support since Grails 2.3 we can have controllers with the same name, but ...

Read More »

Getting Started with method security in Grails using Spring Security

grails-logo

This blog post will be about implementing method level security with security expressions in Grails using the Spring Security plugins. I assume you have some basic understanding of the Grails Spring Security Core plugin. Roles aren’t enough. When using the Spring Security Core plugin you typically start to configure which roles are required for accessing certain URLs. This configuration can ...

Read More »

Grails: Calling bean methods in Spring Security expressions

grails-logo

Some days ago while working on a Grails application I was in a situation where a wanted to call a bean method from a Spring security SPEL expression. I was using the @PreAuthorize annotation from the Spring Security ACL plugin and wanted to do something like this:               @PreAuthorize("myService.canAccessUserProfile(#profileId)") public Profile getUserProfile(long profileId) {   ... } @PreAuthorize takes ...

Read More »
Do you want to know how to develop your skillset and become a ...

Subscribe to our newsletter to start Rocking right now!

To get you started we give you our best selling eBooks for FREE!
Get ready to Rock!
To download the books, please verify your email address by following the instructions found on the email we just sent you.

THANK YOU!

Close