I have a multiselect drop-down in my GSP page like this:
<g:select id="subwidget" name="subwidget.id"
from="${com.foo.model.Widget.findAllByInactive(false,[cache:true])}"
optionKey="id" optionValue="name" required=""
noSelection="['':'---Select---']"
class="many-to-one" multiple="true"
value="${ widget.subwidget}" style="width:137px;"/>
When I go to edit the Widget record, my subwidgets are populated properly. But if there is a validation error on the page, unrelated to subwidgets, then then page reloads, and all my data is where -- except the subwidget. The Subwidgets that were selected (if I changed them or not) are now gone.
Ideas?
I figured out what happened -- the update for this object is rather long, and updating the subwidgets was one of the last things it did. Moving the subwidget part to the beginning of the update did the trick. Grails must leave quickly and not finish the update service method in there.