What can I learn from Grails? - ruby-on-rails

If I know Rails, what new ideas/patterns would I learn if I looked at Grails?
I have no intention to move to Grails and no need for a Java stack, but if there are neat ideas I could learn from Grails I'd like to learn them.

Grails has taken totally different direction. It is very hard to compare Grails and Rails.
Grails is not framework. It is stack of frameworks. You can find all the features you find in plain Spring, Hibernate, Quartz, Compass, Sitemesh frameworks. So at the end you get all the best from all these frameworks with convention-over-configuration.
However, I really want to mention about very interesting idea introduced in Grails about modulizing the application into plugins. Plugin in Grails is minimized independent project. Separating application logics into plugins allows to share your code to community and keep application in separate modules which results in easier testing and easier development.

Grails has at least two patterns I'm aware of that I believe do not exist in Rails:
Command objects (and auto binding request params to them)
Conversation based request handling using web flows

Related

Implementation of CRUD with Grails framework

I've been searching all day for an answer to my problem, and don't seem to be able to find an answer.
I'm trying to implement a CRUD web application using Grails, with the IntelliIDEA IDE. Whereas with JSF i could use primefaces which allowed me to do this with general ease, i am disappointed to see, or at least seems to be that way, that the framework is a step backwards when it comes to development of html pages.
All i want is to have a table that is populated from data that is coming from a controller, and whenever i add a record it is also displayed in this table. I want to be able to edit any record on this table and also remove records. It would be awesome if there could be a component like primefaces datatables that allows me to do this easily, without having to use JavaScript. I've taken a look to the Dojo plugin, but it's so outdated and incomprehensible to me that i have discarded this option, mainly because there is no documentation on the site on how to use it with Grails, specifically.
Also, i do not want to use scaffolding. I am trying to learn how to do this from scratch, and it is of my understanding that it doesn't work too well with domains with many to many relationship, for example.
In a nutshell, what I am looking for is the best way to make a CRUD application on Grails that doesn't involve the use of scaffolding.
I would suggest you to go through "Grails in Action" book and follow the creation of web application "Quote of the Day" and "Hubbub", don't use scaffolding instead create your own views and controller using documentation provided.
This will help you to understand basic CRUD operations in Grails.
And also looking into documentation http://grails.github.io/grails-doc/latest/guide/theWebLayer.html
See if this can help you.
You are aware that the scaffolding also can generate code for you to learn from and continue your work from there (i.e. it doesn't have to happen magically behind the curtains). I would say that is the typical means of starting out with Grails and CRUD.
Otherwise, no Dojo probably won't help you out a lot. Maybe have a look at some other plugin, for instance the Easygrid plugin? It is based on Javascript though, which most solutions do.
The "Grails in Action" recommendation is probably your best bet for the long-term, learning it from the pro's rather than learning-by-doing/top-to-bottom CRUD-style.

Grails UI in 2.3.4

I am coming from the Spring + Hibernate + JSF/primefaces site. What I like in Grails is its scaffolding site, so that basic CRUD apps can be created rather quickly.
However, which libaries do you recommend for a beginner in Grails for creating a UI? It should be created quickly and straightforward and also be feature rich (have a look at the primefaces libary)!
The very basic GSP pages are really powerful, especially when combined with any modern JS library. With them you can assemble a complex rich GUIs in instant (well, almost :) )
There are also numerous grails plugins to include almost any view technology of your choice into your web-app, e.g. http://grails.org/plugin/kickstart-with-bootstrap
I would suggest http://grails.org/plugin/twitter-bootstrap once installed you can use the documentation at http://getbootstrap.com/ as your guide.

Web front-end tools for Grails project

I previously developed only Java SE applications, and now I am trying to do some small project in Grails. My front-end developing skills are really bad. Ok, I got the main ideas behind GSP in Grails, but there are many tools which alow to simplify front-end development, like Twitter Bootstrap.
My question is, what tools for front end are best suited for Grails project and can be naturally combined with GSP?
Another option I am looking into is doing whole front-end on something like Flex, how hard is it to do such thing in Grails?
Grails is best suited for HTML+CSS+JS front-end. You still can use Flex, Vaadin, GWT, etc., if you prefer. But standard HTML + modern framework is really easier to use.
For standard web app, based on html/css/js, I can recommend Twitter Bootstrap plugin (but you aren't limited to it). It's very useful framework, but you should know all basics (html and css)

Grails AOP with aspectj and/or Groovy AOP preferably using annotations

In our enterprise app, we would like to put cross cutting concerns like logging, metricing as aspects. We already have the aspectj advices ready(from our existing java app) but I am not finding a way to integrate aspectj with Grails.
I am already aware of beforeInterceptor and afterInterceptor, but these need to be done in all Controllers and Services, is there an easier way to do this.
My preferred approach would be to create annotations for e.g #Metrics on any method in my grails application and it should get adviced. Has anyone done this, any links/resources/examples would be great to have.
Maybe you can take a look at Grails Filters which can be used for cross cutting concerns such as logging etc:
http://grails.org/doc/2.1.0/ref/Plug-ins/filters.html
Regarding using of annotations, maybe this article could be helpful, but I haven't checked it:
http://manbuildswebsite.com/2010/03/15/simple-aspects-using-annotations-in-grails/
Best of luck.

How to get started with GRAILS on an existing Java EE app?

I'm new to grails. I'd like to give it a whirl by implementing a new feature or two into an existing Java EE application. The current Java EE app is a fairly standard Spring MVC/Hibernate app running on Tomcat. Looking through the documentation, it looks like I should be able to leverage all of the current business logic that's written in Java.
I've only been able to find tutorials on creating new grails applications. Does anyone know of a tutorial for integrating with an existing Java EE app? If not a tutorial, any recommendations or suggestions on where to start?
Whether or not those features go live would depend on my experience with Grails and if I think it's worthwhile using it going forward. The goal would to either:
Decide Grails isn't for me (and not deploy grails).
Decide it is for me, and all future development on this app would be in Grails with a full eventual port over.
I'm afraid I don't know of any such tutorials, but my immediate thought would be that porting an application while also combined with learning Grails could be a big uphill.
I haven't done this sort of thing before, so these are just musings on how I might approach doing this..
Since GSPs are not analogous to JSPs and since Controllers in Java are statically typed, whereas Grails controllers have magic methods wired onto them, I would probably want to re-write those again in Grails from scratch since their transferability isn't obvious - the logic should transfer but the boilerplate of the old code isn't altogether necessary for the most part.
Maybe take a simple story/feature, keep the existing Services it uses and get them wired in via Spring in Grails. Then try making one for one copies of what you have in Java with corresponding Controller/GSP and Domains. That should give you some feel of what stuff you need to get off the ground for the port.
Your biggest struggle, from people who I have heard of doing this, might well be trying to re-use your existing hibernate stuff in Grails.
Just my tuppence, not so much a whole answer...
Insert Grails into an Spring app is not easily achievable, you can try to insert the old Spring app into a Grails app, and continue from that point.
Here you've some info 'bout using the hibernate mappings and java classes.
You also have to have to add the beans of the Sprint app to the Grails app. You can insert them into the ApplicationContext directly or use the resources.xml or resources.groovy.
It depends on how you've written the Java EE app. You cannot drop it into the Grails runtime and expect it to work with no tweaking, especially the 'controller' part of your app (since grails uses its own conventions for that). The UI, if its jsp, may be a bit better, since you can probably rename them to gsp, and have it work. tag libs works straight away, and normal java classes work straight away obviously. Hibernate objects may need tweaking - though i suppose it may just be easier to redo those using grails.
-my 2cents

Resources