Also, this just in... The Chicago Groovy Users Group is having their first meeting on Tuesday, January 13th. See their site www.cgug.org for more details.
Wednesday, December 10, 2008
Gateway Groovy Users Recap
We had the first meeting of the Gateway Groovy Users tonight. We didn't get quite the turnout that Alex Miller got with the Lambda Lounge, but what we lacked in numbers we made up for in left over food! But seriously, the six of us had a great time. We had a good discussion followed by a Groovy hacking session. We also set the date for our next meeting. Mark your calendars, Thursday, January 15th, we will be have an overview of Grails 1.1 ( which should be released by then) by an as yet undisclosed presenter. Join the Google Group for updates.
Monday, December 8, 2008
GSP Page Without a Controller
Grails uses convention to serve up .gsp views using the name of an action in a controller. For example, if you have a list action in a BookController Grails will try to load grails-app/views/book/list.gsp when this action is called. But what if you want to use a .gsp but do not need or want a controller? How can you call that page in Grails? Like most things in Grails, there is more than one way to do this and they are all easy.
You can create the .gsp file in /grails-app/views or directly in the web-app directory. I'd prefer the former since that's where all your other .gsp pages are going to be. If you do either of these, then you can call the page like this: myapp/mypage.gsp. Or, if you nested the .gsp in a sub-directory, like this: myapp/mysubdir/mypage.gsp. In any case you will have to include the .gsp extension and that's a bit ugly. You can fix this with URL mapping by adding something like "/mypage"(view:"mypage") to the mappings block of your URLMapping class. Now you can just call myapp/mypage and all is well.
With any of these approaches you have most of the power of GSP. You can use the standard Grails GSP tags as well as any custom tags added to your project, you can include Groovy code in your pages (but please keep it to a minimum) and you have access to the objects that Grails makes available to all GSP pages, such as request, session and params. What you don't have is a way to pass model data to your page or to perform other operations before your page is rendered.
With any of these approaches you have most of the power of GSP. You can use the standard Grails GSP tags as well as any custom tags added to your project, you can include Groovy code in your pages (but please keep it to a minimum) and you have access to the objects that Grails makes available to all GSP pages, such as request, session and params. What you don't have is a way to pass model data to your page or to perform other operations before your page is rendered.
Keep in mind that a controller action does not need to have any code in it. So, you can always just create a controller with actions named the same as your .gsp file and then Grails will render it by convention. If your app includes other pages that are called from controllers then this will keep you app more consistent as well as making it easier to later add more functionality. Maybe it's 6 of one and a half dozen of the other but at least it's nice to know that whichever way you go, Grails makes it easy.
Groovy User Groups
If you read the Community News in the December issue of GroovyMag, then you already know about the two new US Groovy User Groups. The Chicago Groovy User Group is holding their first meeting in January and the Gateway Groovy Users will be holding our first meeting this week!
December 10th at 6:30 pm in downtown St. Louis Contegix will be hosting the first meeting of the Gateway Groovy Users. If you are in, or can get to, the St. Louis area and are interested in Groovy, Grails, Griffon, etc, please plan on joining us. You can join the Google group to keep up to date - http://groups.google.com/group/gateway-groovy The website should be live soon, and that will be announced on the mailing list.
This is an exciting time to be working in this fast growing and just plain fun technology. I think we will be seeing many more Groovy/ Grails user groups in the near future. If you know of one that is starting up in your area, drop me a line and I'll be happy to help get the word out.
Subscribe to:
Posts (Atom)