tag:blogger.com,1999:blog-7371895490737388670.post7459395874319104980..comments2023-05-04T00:35:27.914-05:00Comments on Scratching my programming itch: Ajax Examples upgraded to Grails 2.0.0Mike Millerhttp://www.blogger.com/profile/09697567698545249690noreply@blogger.comBlogger8125tag:blogger.com,1999:blog-7371895490737388670.post-72171083914624341202012-08-12T22:11:31.057-05:002012-08-12T22:11:31.057-05:00Yep - I finally caught that as well and am wonderi...Yep - I finally caught that as well and am wondering how I missed it. Thanks again!Unknownhttps://www.blogger.com/profile/09617293068040489538noreply@blogger.comtag:blogger.com,1999:blog-7371895490737388670.post-38869758219559175262012-08-11T14:15:52.721-05:002012-08-11T14:15:52.721-05:00Found it! Not sure how this worked previously but...Found it! Not sure how this worked previously but in the Boostrap.groovy Book constructor calls, I have 'Author' as a property instead of 'author'. Change them all to lowercase 'author' and that should correct the problems with books not getting created!<br /><br />Thanks for catching that. I will update Github this weekend (I hope!).Mike Millerhttps://www.blogger.com/profile/09697567698545249690noreply@blogger.comtag:blogger.com,1999:blog-7371895490737388670.post-78805188804843876892012-08-10T19:00:49.446-05:002012-08-10T19:00:49.446-05:00Did you change the bootstrap file at all? The mes...Did you change the bootstrap file at all? The message seems to indicate that the 'author' of a Book can not be null. At th<br /><br /><br />Below is a copy of my current bootstap file for comparison. At one point, someone logged a comment that I was missing the import statements at the top of the script. Also, I just tested setting the gsmith variable to null instead of creating the author and the app comes up but without that book.<br /><br />Hopefully it's the imports, but if not - sounds like the Author objects are not getting saved. You can edit the file to start with one property and progressively add more of the properties until you find what prevents the author from being save.<br /><br /><br />************ current version of Bootstrap.groovy ******************<br />import ajax.Author<br />import ajax.Book<br /><br /><br />class BootStrap {<br /><br /> def init = { servletContext -><br /> <br /> def gsmith = new Author(firstName:'Glen', lastName:'Smith')<br /> gsmith.save()<br /> def pledbrook = new Author(firstName:'Peter' , lastName:'Ledbrook')<br /> pledbrook.save()<br /> def rocher = new Author(firstName:'Graeme' , lastName:'Rocher')<br /> rocher.save()<br /> def dklein = new Author(firstName:'Dave', lastName:'Klein')<br /> dklein.save()<br /> def dierk = new Author(firstName:'Dierk', lastName:'Konig')<br /> dierk.save()<br /> def bashar = new Author(firstName:'Bashar', lastName:'Abdul-Jawad')<br /> bashar.save()<br /> def fischer = new Author(firstName:'Robert', lastName:'Fischer')<br /> fischer.save()<br /> def rudolph = new Author(firstName:'Jason', lastName:'Rudolph')<br /> rudolph.save()<br /> <br /> new Book(title:'Grails in Action', pages:469 , Author:gsmith , publisher:'Manning' ).save()<br /> new Book(title:'Groovy in Action', pages:532 , Author:dierk , publisher: 'Manning' ).save()<br /> new Book(title:'The Definitive Guide to Grails', pages:569 , Author:rocher , publisher:'Apress' ).save()<br /> new Book(title:'Grails A Quick-Start Guide', pages: 200, Author:dklein , publisher:'Pragmatic Bookshelf' ).save()<br /> new Book(title:'Groovy and Grails Recipes', pages: 214, Author:bashar , publisher:'Apress').save()<br /> new Book(title:'Grails Persistence with GORM and GSQL', pages: 214, Author:fischer , publisher:'Apress' ).save()<br /> new Book(title:'Getting Started with Grails', pages: 131, Author:rudolph , publisher:'InfoQ' ).save()<br /> <br /> }<br /> <br /> def destroy = {<br /> }<br />}Mike Millerhttps://www.blogger.com/profile/09697567698545249690noreply@blogger.comtag:blogger.com,1999:blog-7371895490737388670.post-29456500609568113412012-08-10T17:48:25.500-05:002012-08-10T17:48:25.500-05:00There is an issue with the bootstrap... the author...There is an issue with the bootstrap... the author objects seem to be created properly, but a validation exception is raised during the save of the first Book object:<br /><br /><br /> Error 2012-08-10 14:49:05,088 [pool-4-thread-1] ERROR context.GrailsContextLoader - Error executing bootstraps: Validation Error(s) occurred during save():<br />- Field error in object 'ajax.Book' on field 'author': rejected value [null]; codes [ajax.Book.author.nullable.error.ajax.Book.author,ajax.Book.author.nullable.error.author,ajax.Book.author.nullable.error.ajax.Author,ajax.Book.author.nullable.error,book.author.nullable.error.ajax.Book.author,book.author.nullable.error.author,book.author.nullable.error.ajax.Author,book.author.nullable.error,ajax.Book.author.nullable.ajax.Book.author,ajax.Book.author.nullable.author,ajax.Book.author.nullable.ajax.Author,ajax.Book.author.nullable,book.author.nullable.ajax.Book.author,book.author.nullable.author,book.author.nullable.ajax.Author,book.author.nullable,nullable.ajax.Book.author,nullable.author,nullable.ajax.Author,nullable]; arguments [author,class ajax.Book]; default message [Property [{0}] of class [{1}] cannot be null]<br /><br />I've used the bootstraps quite a bit and have never seen this error before, so I'm still digging into it.Unknownhttps://www.blogger.com/profile/09617293068040489538noreply@blogger.comtag:blogger.com,1999:blog-7371895490737388670.post-89050966664605458692012-08-09T20:23:19.841-05:002012-08-09T20:23:19.841-05:00I am glad it helps but doesn't sound like you ...I am glad it helps but doesn't sound like you are 'there' yet. I would do each of the following to get a better idea of what's going on.<br /><br />1)from the grails ajax project root folder enter "grails list-plugins --installed" in order to get Grails to tell you which plugins are actually installed. The important two are a) prototype and b) resources. If these don't appear in the list, then install them.<br /><br />The plugins are actually installed in a different place and not under the project folder. For example, on my XP box, they reside at<br />C:\Documents and Settings\mike\.grails\\projects\ajax\plugins.<br /><br /><br />2) Assuming the plugins are installed, the next thing I generally do is to add some println statements in the controller that I am expecting to hit/execute.<br /><br />3) The "Book not found with id 1" issue sounds like the Bootstap.groovy script is not running successfully at startup. <br /><br />Hope this helps. Let me know if I can help further.Mike Millerhttps://www.blogger.com/profile/09697567698545249690noreply@blogger.comtag:blogger.com,1999:blog-7371895490737388670.post-48286496093459793442012-08-09T16:53:55.768-05:002012-08-09T16:53:55.768-05:00Thanks for the example - its a tremendous help in ...Thanks for the example - its a tremendous help in addition to the documentation.<br /><br />But, for some reason, I'm not getting it. When I run your upgraded application (as well as when I apply the upgrades to the original version), the AJAX behavior is not functional. <br /><br />When I click on the ajax/book/list, the table is empty with a message "Book not found with id 1"<br /><br />When I click on the "Ajax examples 0.2" link, I get a 404, resource not available error.Unknownhttps://www.blogger.com/profile/09617293068040489538noreply@blogger.comtag:blogger.com,1999:blog-7371895490737388670.post-47963459367686377682012-06-05T13:16:57.030-05:002012-06-05T13:16:57.030-05:00It is on my todo list, just not at the top. I am ...It is on my todo list, just not at the top. I am looking at MongoDB right now and then maybe have some time to learn jQuery.Mike Millerhttps://www.blogger.com/profile/09697567698545249690noreply@blogger.comtag:blogger.com,1999:blog-7371895490737388670.post-8039050410742214512012-06-05T08:35:12.444-05:002012-06-05T08:35:12.444-05:00Any chance your going to convert your example to j...Any chance your going to convert your example to jquery?Anonymousnoreply@blogger.com