« Return to Thread: Validation of a screen of multiple domain objects

Validation of a screen of multiple domain objects

by Martin Flower-2 :: Rate this Message:

Reply to Author | View in Thread

Complete Grails/Groovy newby here ...

My create screen has one Book per row (isbn, title).  I want to  
enforce unique isbn and unique name.  I can code this contraint in the  
Book class, but when I Book.findByIsbn(val), I am only searching on  
the persisted Books, not on those that have not yet been saved.  If I  
have the same Book multiple times on the create screen, but none of  
which are saved, then no error is detected by the contraints.  When I  
call save(), the first one is saved and the others are discarded.

The screen is defined as an array of Strings.  Should I be using a  
Command object - Books, or maybe Book[] ?

I have been playing around with passing the array of input parameters  
to the Book class for picking up by the contraints ....

I have been looking to put the validation in the BookController, but I  
can't work out how to attach the error condition to the Book so that  
it gets displayed on the screen.

I think I'm tying myself in knots ... time to ask for some help

Thanks

Martin


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


 « Return to Thread: Validation of a screen of multiple domain objects

LightInTheBox - Buy quality products at wholesale price