Several Grails applications, like the one I'm writing, require a /user view and /admin view that are 'dashboards', basically the user or admin lands on that page, possibly after a successful login and all the datatables and tabs are there, so they hardly ever need to navigate off that page, providing a more satisfying users experience, like users of Gmail or Mint have become accustomed.
In order to allow searches and form posts from the main /user dashboard, I've been using the modalbox plug-in v0.4 grails install modalbox
. Modalbox obviously is managing the GET/POST itself and unfortunately is losing 99% of the validations that the typical constraints block gives you.
Working around this for now by replacing g:submitButton, putting some basic JavaScript in the submit as shown. (This is a terrible workaround, of course.)
<input type="button" name="create" class="save" onclick="if (!(document.getElementById('name').value === '' || document.getElementById('summary').value === '')) { document.forms[0].submit(); }" value="Create" />
But there must be a better way! I've been told to use g:remoteForm, but have not seen a complete enough example to work w/ Modalbox. Maybe folks are using a new window which would automatically close a couple of seconds like Gmail's compose window?
This is likely a scenario so common as to be ripe for a SiteMesh template, or at the very least a 'render template:' or even a GSP tag like the modalBox:createLink.
Source available here in Gtown project space.