On Fri, Jun 19, 2009 at 3:25 AM, dflemstr <david.flemst...@gmail.com> wrote:

>
> Well, that probably is good advice, but doesn't really relate to the
> matter at hand if I understand you correctly.
> As you may notice, the code is a modified version of the embedded
> code, but it's completely independent from it (it doesn't override
> anything). It could have been code that had been written completely by
> me.
>
> And anyways, my goal is to make a snippet out of the edit form, and
> not to just be able to load a template from a file (I need to put the
> whole edit form in multiple, obscure places) so your solution, I must
> say, isn't any help to me. Maybe my original message title was
> misleading.


I am totally confused as to what your goal is?  Is it to put the form into a
template file (a .html) file?  Is it to control the rendering of the form
elements?  Is it something else?

In terms of ProtoUser, that class is meant as a quick bootstrap to getting
your project going.  It lends itself nicely to adding fields.  Any styling
needs to be done via CSS.  If you need something more complex (like ESME
does), you can pull the code into your User class and then work to achieve
the particular goal.  If we can cycle a bit on what your particular goal is,
I'm sure we can get you there.


>
> The issue is that the theUser object isn't preserved between requests.
> Apart from that, the snippet could've been any other snippet (because
> it's just being used as a generic mapper; I could've created this form
> for any structure).
>
> Thank you for your effort, anyhow!
>
> On Jun 19, 6:21 am, David Pollak <feeder.of.the.be...@gmail.com>
> wrote:
> > 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.  Seehttp://
> svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/sca...
> > 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>&nbsp;</td>
> > >                    <td><user:submit/></td>
> > >                </tr>
> > >            </tfoot>
> > >        </table>
> > >    </lift:User.edit>
> > > </lift:surround>
> >
> > --
> > Lift, the simply functional web frameworkhttp://liftweb.net
> > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > Follow me:http://twitter.com/dpp
> > Git some:http://github.com/dpp
>
> >
>


-- 
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to