On Tue, Aug 25, 2009 at 12:52 PM, harryh <[email protected]> wrote: > > > I'm not sure I understand what you're suggesting. Can you be a little > more > > explicit about your suggestion? > > OK, so I'm editing an existing Thing with name currently = > "Harry" (which is valid as it has >= 5 chars) > > I do a GET /editThing?id=12 > > in return I get a form which contains (among other things): > > <input type="text" name="AGUID" value="Harry" /> > > I change the value of the field to "Bob" and press submit which does a > POST /editThing and down in the HTTP body is > > AGUID=Bob > > Up on the server this doesn't validate, so it doesn't save the Thing > with this new value, so it sends back the form again. While rending > the form, inside one of my snippets I call someThing.name.toForm. The > implementation of this function, when it is creating the <input> > element and setting it's value. Rather than blindly setting the value > to to theThing.name ("Harry") could check S.attr("AGUID") and, if it > exists, set the value of the field to that instead. > > So a POST that resulted in errors would, by default, render the form > with the user entered values (some of which could be invalid) still > there making it easy for the user to make corrections and resubmit.
There are a bunch of reasons why that can't work. First, when you bind to the value "thing" in a snippet (not a StatefulSnippet), it's not possible to reach into the stack and replace the stack frame that represents "thing" with another reference. Second, even if you could replace the value of "thing", the function that's bound to the form element doesn't know anything about stack frames. Thus, we've got stateful snippets that deal with the problem. > > > -harryh > > > -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---
