On Thu, Apr 23, 2009 at 8:38 AM, Geoffrey Wiseman <geoffrey.wise...@gmail.com> wrote: > I wasn't sure if Tapestry did any magic under the covers to work with > server-side validation and ajax form submits. I did a quick experiment and > it doesn't seem to: > > - Create a form, give it a zone to do ajax submit. > - Create an onValidateForm method, throw a ValidationException from it. > - Load up the application. Submit the form. > - The zone gets updated, no validation messages appear.
I use validation and ajax a lot and it works (quite) well for me. I just replicated what you described and it works. I assume you might not have the <t:errors/> component in the block that gets loaded in the zone, nor record the error to one of the Fields. This way, no visual feedback is given. If your setup doesn't work well with placing the <t:errors/> in the block that gets reloaded, you could consider placing it in a zone by itself and update multiple zones on the one form submit by returning a MultiZoneUpdate from your EventConstants.SUCCESS action. (haven't tried this btw) > > No big surprises so far -- this is Ajax form submits and the fact that > validation isn't meant to work with it, near as I can tell. The next part, > however, worries me a little: > > - Refresh the page, or go the same URL. > - The page renders as if you'd just submitted the form. The field is > populated an there's a visible error block. > - I don't have any Persist annotations here or anything, so I'm a little > disturbed that it's retaining a form value and validation state despite > that. > > Am I missing something, or is this some kind of ugly edge case around ajax > and form validation? > > Now you could argue that ajax form submits and validation don't belong > together, which I might agree with. I'd have to understand how Tapestry > handles graceful degradation in order to argue the point. > > On a side note, I'd love to be able to throw a t:errors outside of a form in > a block and point it /to/ the form to use that to display validation > errors. (e.g. <t:block t:id="errors"><t:errors t:form="save" /></t:block>) This does seem strange. My guess is that the ValidationTracker uses some sort of flash persist that works well on a page request but might not on an Ajax request because it does not use an redirect. Maybe one of the commiters can comment on this? > > - Geoffrey Cheers, Joost > -- > Geoffrey Wiseman > http://www.geoffreywiseman.ca/ > --------------------------------------------------------------------- To unsubscribe, e-mail: users-unsubscr...@tapestry.apache.org For additional commands, e-mail: users-h...@tapestry.apache.org