I'd suggest copying/pasting the code from ProtoUser and MegaProtoUser and munging the code so that you don't have to work around the embedded MegaProtoUser code. See http://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/scala/org/apache/esme/model/User.scala?r1=779789&r2=784317&diff_format=h I recently made this change to the
On Thu, Jun 18, 2009 at 1:51 PM, dflemstr <david.flemst...@gmail.com> wrote: > > Hello everyone, > I'm having some problems with making the MetaMegaProtoUser "edit" > method templateable (because I believe in the concept of separating > content and design) and am succeeding quite well, except for with one > little detail: I can't make my changes in the edit form persistent; it > seems that the "User" instance gets lost somewhere in the process and > that all the client-side changes therefore also get lost. > > The code is at the end of the message. The edit method is called with > a template which also is at the very end of the message. > > I would really appreciate if anyone with more Lift experience than me > could spot the mistake, because I simply cannot find it. > > > ------------------------------------------------------------------------------------------------- > The "snippet" (inside a subclass of MetaMegaProtoUser): > > /** Create an edit form with the specified template */ > def edit(xhtml: NodeSeq) = { > val theUser: User = currentUser.open_! // we know we're logged in > > def testEdit() { > theUser.validate match { > case Nil => > theUser.save > S.notice("Profile updated") //The Lift Core has a spelling > mistake in its translation, so I don't use S.?? > S.redirectTo(homePage) > > case xs => > S.error(xs) > S.mapSnippet(S.currentSnippet.open_!, innerEdit) > } > } > > def innerEdit(t: NodeSeq) = bind("user", t, > "field" -> ((h: NodeSeq) => localForm > (h, theUser, true)), > "submit" -> SHtml.submit(S.??("edit"), > testEdit _)) > innerEdit(xhtml) > } > > /** Make a form with all the editable fields of an user, from a > template */ > protected def localForm(xhtml: NodeSeq, user: User, ignorePassword: > Boolean): NodeSeq = { > signupFields > .map(fi => getSingleton.getActualBaseField(user, fi)) //get > actual fields > .filter(f => !ignorePassword || (f match { //remove the password > field > case f: MappedPassword[_] => false > case _ => true > })) > .flatMap(f => > bind("field", xhtml, > "name" -> Text(f.displayName), > "form" -> f.toForm) > ) > } > > > ------------------------------------------------------------------------------------------------- > The template: > > <lift:surround with="default" at="content"> > <lift:User.edit form="POST"> > <table> > <tbody> > <user:field> > <tr> > <td><field:name/></td> > <td><field:form/></td> > </tr> > </user:field> > </tbody> > <tfoot> > <tr> > <td> </td> > <td><user:submit/></td> > </tr> > </tfoot> > </table> > </lift:User.edit> > </lift:surround> > > > > -- 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 liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~----------~----~----~----~------~----~------~--~---