Fully functional Ratpack CRUD Script/App

classic Classic list List threaded Threaded
15 messages Options
Reply | Threaded
Open this post in threaded view
|

Fully functional Ratpack CRUD Script/App

dbirtwell
All:

I have created and committed to GitHub a fully functional simple Ratpack CRUD script/application.

The code can be found at:

https://github.com/dbirtwell/trackmystuff_ratpack_with_db

look at the readme.md for more details.

There is, however, one BUG ... the icons/images don't reload when I do an edit or deletes as the route is not updated to the default.

I'm most likely not handling the routes correctly, or am missing a reload command. I don't recall having to do this with Sinatra.

Any ideas on what I am doing wrong?

Thanks,

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

dbirtwell
Should I actually do a redirect, such as:

response.redirect("/")

instead of

get(TemplateRenderer).render "index.html", title: "Groovy Track My Stuff"

Is this the correct thing to do?
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

dbirtwell
I decided that the response.redirect is the correct thing to do. I added it to the create, update and delete routes and committed it to my GitHub repo.

I think the CRUD application is now fully working.

Let me know if you have any corrections or suggestions.

RatPack is definitely a fun way to do light web development in Groovy/Java

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

Luke Daley
Administrator
I'd go with the redirect too.

It's looking good to me.

I don't quite follow you regarding the reloading of the icons. Can you give a bit more explanation?
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

dbirtwell
On the main page, there are icons/images for editing and deleting existing "items".

With the code in place before I added the redirects and use a render in the POST route:

get(TemplateRenderer).render "index.html", title: "Groovy Track My Stuff"

If you select edit and then the "save" action, or select "delete" and then choose to delete the item, the new list (with either modified data, or minus the deleted one) will render, but the icons/images, including the magnifying glass in the header are missing from the view in the browser (I tried with both FireFox and IE ... I'm in a windows environment right now).

When I add the redirect in the POST route:

response.redirect("/")

the images/icons render.

Nothing is different in the browser source, but I'm guessing the page is either only partially cached, or maybe it's something with the pathing to the \images folder and the URL for the edits deletes.

I'm not worried about "what" is causing this, as I feel that the URL redirect  is the proper thing to do anyway.

Hope this clears up what I reported.

Thanks,


Dave
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

dbirtwell
In reply to this post by dbirtwell
Just a heads-up, I replaced the GitHub example I created with a revised version which is much better (Thanks Rus). It even now has a simple HtmlUnit test ... but needs to be ported to geb.

The GitHub location is:

https://github.com/dbirtwell/trackmystuff_ratpack_with_db

I hope someone can use this is a leaning tool.

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

Luke Daley
Administrator
Thanks for sharing Dave. 
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

uris77
In reply to this post by dbirtwell
BTW, how does 'parse()' work? I'm also learning Ratpack and that function caught my eye.
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

Luke Daley
Administrator
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

uris77
Sweet. Thank you.
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

dbirtwell
Roberto:

I'm now learning Selenium Web Driver Functional Testing and Geb Functional Testing. Keep an eye on my GitHub account (dbirtwell) for some samples ... uh, I mean, attempts at samples ;-) of Functional Testing my CRUD app.

Dave
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

uris77
Oh, sweet. Will do. Thank you for sharing.
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

dbirtwell
I finished a small Gradle-based Geb Funtional test suite for my TrackMyStuff application and pushed something up to GitHub at:

https://github.com/dbirtwell/trackmystuff_ratpack_tests

NOTE: I placed the application to test as a sub-folder and do not yet have gradle start the application as part of the testing process ... that will come later.

Please let me know if there is ANY THING I should/could do better. This is my FIRST try at using Geb Functional Tests (with the Selenium 2.0 WebDriver).

Hope someone finds this of use.
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

uris77
Nice. For what it's worth, I don't think it is necessary to automatically start the app under test when running the Functional test. My ideal scenario is to be able to run the tests against a staging server or a production server, or a development instance. All three might be in different stages of development.
Reply | Threaded
Open this post in threaded view
|

Re: Fully functional Ratpack CRUD Script/App

Luke Daley
Administrator
That’s relatively easy to do, you just supply different base URLs.