Apr
11
2006

DWR + Spring = Ajax Sudoku Puzzle

There is so much to love about DWR and Spring integration. Just configure up your dwr.xml and tell it which spring beans you want to expose for Ajax goodness, and which methods you want to expose on them.

In preparation for a talk I’m giving Wednesday night to the Canberra JUG, I’ve added Ajax goodness to my little
Spring-powered Sudoku solver
. And it was a total snack. You can double click on individual cells to solve just that square, or use the “Solve” button to solve the whole puzzle. You could probably write a better one entirely in Javascript (other people have), but it does serve as a great example of using Spring IoC, AOP, ORM, and Unit testing support.

Check it out (source available here soon). And if you’re in the Australian capital this Wednesday night, drop into the Sun offices on Northbourne from 6PM for Pizza, Beer and a fun introduction to Spring (and if you’re not into Spring, just come for the Sudoku solving :-) .

About the Author: Glen Smith

4 Comments + Add Comment

  • I too am writting an app with DWR and Spring I just love it. Thanks for your example. I’m also using your CSV parser, so thanks a bunch.

  • I’m not 100% convinced that sudoku solver is correct. Peek at the following solution I generated by hitting Get A Puzzle then Solve: http://www.srcf.ucam.org/~cjp39/sudoku-broken.gif

    Not convinced it’s adhering to the “digits must be unique in each row, cell and column” rule ‚Äî and if it’s not adhering to *that*, which is almost the only rule of Sudoku, how can one call it a Sudoku solver?

  • Chris, thanks for your feedback. I think this one is more of a browser render issue. If the solver can’t solve a puzzle (and it can’t solve the ones marked evil) – it will shortlist candidates down to the possible numbers for that cell. It seems on your browser is only displays the first “candidate” – some of those cells actually contain a few numbers.

    Anyways, here’s a grab of same puzzle on my Mac which makes the problem a little clearer. What the UI should probably do is colour the cells that it couldn’t solve to give better cues that the cell still needs work.

  • For those interested, the source to the webapp is now available in the downloads section. Look for the files marked spring-cjug-talk-*. There are versions with or without the supporting spring/velocity/sitemesh libs to make downloads a little snappier for those just interested in the sudoku stuff.

Leave a comment

Glen Smith

About Glen

Co-author Grails in Action