aspose file tools*
The moose likes Groovy and the fly likes Grails Tutorials Available. Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Languages » Groovy
Bookmark "Grails Tutorials Available." Watch "Grails Tutorials Available." New topic
Author

Grails Tutorials Available.

Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Just wanted to let you guys know I have made and still in progress of making available a set of Grails & jQuery tutorials.

The first set of tutorials available now cover the basics of replacing standard grails lists(tables) with a jQuery Grid alternative, I then proceed to show you how to implement sorting/pagination and rapid filtering.

I'm sure they will be of use to people wanting to really get the best of ajax featured grids and grails working together.

Please find them at http://www.grailsforum.co.uk/forumdisplay.php/26-Tutorials

Regards, Dave Brown
SCJP 6 - [url]http://www.dbws.net/[/url] - Check out Grails Forum
Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Thanks Dave,
I'm really looking to employ jQuery grids in our application.
Grails forum is really needed as the mailing list is really pain in the butt (at lest mine).
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Thanks John,

Hopefully I'll see you sign up on the forum then

I created the forum as although the mailing list is great at getting your questions out there, I really don't think people tend to visit the front end for the list unless they have to which is a shame as then there is no sense of community (IMO) which is where I want to get to with the forum.

Hopefully if I get time this evening I'll be adding the next section tutorial which will cover adding/modifying and deleting data in the grid.

Once you've used them a couple of times, you'll be surprised how little code you really need to give the user a much better experience.

Hussein Baghdadi
clojure forum advocate
Bartender

Joined: Nov 08, 2003
Posts: 3476

Yes you are right.
Grails doesn't have an active community (at the level of users of course) which it is a shame.
I will be hanging out there
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Yeah, I agree, I always get all these emails after posting about how it is still waiting to send it to the mailing list. I think I will send an email to them to add it to the Spring Forums so that it is much better.

But in the meantime, I am looking forward to see the tutorials that you create.

One question, why don't you like the list view in Grails, I understand that it doesn't generate delete, etc links, but you still have a link on a row that can take you to the show view, which is very easy to change to take you to say the edit view. And also very easy to add a link in each row to call the delete controller method.

I would be interested in seeing a tutorial that you can do a one to many page, where when you want to add something to the many side, it just has a Web 2.0 popup window for the create view of the many domain.

Good Luck

Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

Mark Spritzler wrote:Yeah, I agree, I always get all these emails after posting about how it is still waiting to send it to the mailing list. I think I will send an email to them to add it to the Spring Forums so that it is much better.

But in the meantime, I am looking forward to see the tutorials that you create.

One question, why don't you like the list view in Grails, I understand that it doesn't generate delete, etc links, but you still have a link on a row that can take you to the show view, which is very easy to change to take you to say the edit view. And also very easy to add a link in each row to call the delete controller method.

I would be interested in seeing a tutorial that you can do a one to many page, where when you want to add something to the many side, it just has a Web 2.0 popup window for the create view of the many domain.

Good Luck

Mark


The nice thing about using something like jqGrid instead of the default is that it is all Ajaxy and stuff. So you can sort/page/etc without refreshing the page. The scaffolding doesn't provide that. I love jqGrid. As far as adding the many side, you could just use jQueryUI's Dialog for the form display, then post it to the server using either a simple $.post or the jquery form plugin. Pretty simple really. But I'm sure a nice tutorial would make that easier to understand.


GenRocket - Experts at Building Test Data
Dave Brown
Ranch Hand

Joined: Mar 08, 2005
Posts: 301
Additionally the in place filtering is extremely useful, and very quick to accomplish.

When setup up the grid will render itself with textboxes above each column, allowing you to type into them and hit return to instantly perform a filter. I think that's a great feature.
as it's very unobtrusive on the page so no need for a seperate or even pop up search form. You're not just limited to textboxes either as obviously that won't always suit every column.

Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

Mark Spritzler wrote:I would be interested in seeing a tutorial that you can do a one to many page, where when you want to add something to the many side, it just has a Web 2.0 popup window for the create view of the many domain.
Mark


I submitted an article to DZone covering this very topic. I'll post a link here when it is approved.
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

It's live

http://groovy.dzone.com/articles/better-scaffolding-jquery-part
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6



Sweet. Thanks Gregg, I will try it out next week. I am teaching a Core Spring class this week.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

Here's Part II.

http://groovy.dzone.com/articles/better-scaffolding-jquery-part-0
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I liked both parts Gregg.

I do wish it wasn't that much more work for the error handling, and having to create a wrapper object to return for the domain/errors. Then having to do the JavaScript work to correctly display what comes back, etc.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

Mark Spritzler wrote:I liked both parts Gregg.

I do wish it wasn't that much more work for the error handling, and having to create a wrapper object to return for the domain/errors. Then having to do the JavaScript work to correctly display what comes back, etc.

Mark


Well, the thing about the javascript and server side wrapper is that it is 100% reusable for any such process. Anytime you want to return json data and are expecting validation errors you can use the code. It's not like the example in the tutorial is the only place for it. I utilize these techniques throughout my entire applications. So you copy and paste it once, then just use it. Tweak it now and again for special cases.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

I noticed the code nested in a few times with functions. My Java developer in me wants to so split it out as window class functions and use the name instead to clean it up, but know that that actually is the bad way of doing it in JavaScript. I just find it easier to read.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

If you have recommendations for improvements, do tell. I'm always looking to make my code better.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Gregg Bolinger wrote:If you have recommendations for improvements, do tell. I'm always looking to make my code better.


I am too new in this space to say that any recommendations I have are accepted by the JQuery/Javascript gurus.

Yes, we are hijacking this thread. ;)



OK, so we select the dialog-form tag call the dialog function. Setting values including the buttons, in which each button has a function inside it, the event of clicking the button. The Create a Reminder button calls the post function, which has a callback function passed to it via the parameter, in which the implementation of the callback is in there.

So the call chain for actual creation is

1) dialog
2) click event
3) post
4) callback

for cancel it is

1) dialog
2) click event

In the create I guess the click event, and call back functions could be named functions that you just use the name so if I had createClick and createCallback as names for example, not necessarily good names, but then the code would look like this



Just an idea. I am pretty sure the this.dialog() call at the end of createClick would correctly have "this" pointing to the right object we mean.

What do you think?

Am I off my rocker and just being JavaScript newbie?

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

Am I off my rocker and just being JavaScript newbie?


No, not at all. This is all perfectly valid. And if these callbacks were reusable in any way, then I might do that. In the case of the tutorial it just would have created more jumping around to see things, in my opinion. jQuery callbacks can get really nested and ugly at times.

Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Gregg Bolinger wrote:
Am I off my rocker and just being JavaScript newbie?


No, not at all. This is all perfectly valid. And if these callbacks were reusable in any way, then I might do that. In the case of the tutorial it just would have created more jumping around to see things, in my opinion. jQuery callbacks can get really nested and ugly at times.



That is where I have a different opinion coming from Java.

Because it seems to get nested and ugly a lot in JavaScript and even though the callback wasn't reusable, I would still do it to look clean, in my opinion. Even in a tutorial. I just found it easier to read how I wrote it, than it being nested, I have to almost shift my brain to read it when it is all nested, so that I can make sure my brain has the context of the next function in my head and understood.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

Mark Spritzler wrote:
Gregg Bolinger wrote:
Am I off my rocker and just being JavaScript newbie?


No, not at all. This is all perfectly valid. And if these callbacks were reusable in any way, then I might do that. In the case of the tutorial it just would have created more jumping around to see things, in my opinion. jQuery callbacks can get really nested and ugly at times.



That is where I have a different opinion coming from Java.

Because it seems to get nested and ugly a lot in JavaScript and even though the callback wasn't reusable, I would still do it to look clean, in my opinion. Even in a tutorial. I just found it easier to read how I wrote it, than it being nested, I have to almost shift my brain to read it when it is all nested, so that I can make sure my brain has the context of the next function in my head and understood.

Mark


Even in Java, I find it simpler to keep things together, when it makes sense. For you, it may never make sense. But if there are very few lines of functionality outside of the inner function, I don't see the point in externalizing it for the sake of externalizing it. Encapsulating it in a single location is a lot easier, for me. Then I don't have to jump around between methods so much.
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17249
    
    6

Gregg Bolinger wrote:
Mark Spritzler wrote:
Gregg Bolinger wrote:
Am I off my rocker and just being JavaScript newbie?


No, not at all. This is all perfectly valid. And if these callbacks were reusable in any way, then I might do that. In the case of the tutorial it just would have created more jumping around to see things, in my opinion. jQuery callbacks can get really nested and ugly at times.



That is where I have a different opinion coming from Java.

Because it seems to get nested and ugly a lot in JavaScript and even though the callback wasn't reusable, I would still do it to look clean, in my opinion. Even in a tutorial. I just found it easier to read how I wrote it, than it being nested, I have to almost shift my brain to read it when it is all nested, so that I can make sure my brain has the context of the next function in my head and understood.

Mark


Even in Java, I find it simpler to keep things together, when it makes sense. For you, it may never make sense. But if there are very few lines of functionality outside of the inner function, I don't see the point in externalizing it for the sake of externalizing it. Encapsulating it in a single location is a lot easier, for me. Then I don't have to jump around between methods so much.


That is true. I would move it out because the tendency is that that would be the "slippery" slope because it is much easier for lower cohesive methods and tighter coupling if you don't separate them. But it is a habit of mine I have taken because if someone else looks at the code, they end up adding more to the method and leading it to be longer and soon tougher to maintain and then spaghetti code.

Mark
Gregg Bolinger
GenRocket Founder
Ranch Hand

Joined: Jul 11, 2001
Posts: 15292
    
    6

...and tighter coupling


But most of the time, the code is tightly coupled, even if you move it out into a function. Most of the time, not all, the code in the callback only pertains to that particular situation. Note in my tutorial though that I did pull out some code into functions. For example, cleanup, show Errors, and clearForm were all externalized. The only code really left inside the callback was specific to the data coming back. The returned data is tightly coupled to the callback, therefor, I see no reason to externalize it.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Grails Tutorials Available.
 
Similar Threads
jQuery: I am new to this please help
Display calender in Date of Birth field.
Don't mistake this for a troll post. Elegant Javascript
Grails and jQuery: how to get image to show that the user just typed in the URL to
status history