On Sun, May 10, 2009 at 1:35 PM, [email protected] <
[email protected]> wrote:
>
> Hi,
>
> I'm asking some questions again :) This time it is about form
> handling. I tried to get the idea from source code but I think it
> would be easier if some one wiser could open it a bit.
>
> Here is my understanding, please correct me if it is incorrect:
>
> 1. I have snippet (TeamSnippet) with "add" function that creates new
> teams. Inside "add" there is following bind statement:
>
> bind(...
> "name" -> SHtml.text(name, name = _),
> ...,
> "submit" -> SHtml.submit("Add", processTeamAdd))
>
> 2. When the snippet is requested the functions name.= and
> processTeamAdd are stored into session with generated name.
>
> 3. Snippet returns a node sequence where the input elements are listed
> with the name values generated for them. These generated names are the
> same that are used to identify the functions in session
>
> Now comes the big question for me. When user has inputed the name of
> the team and hits the submit button: By whom are the functions (name.=
> and processTeamAdd) called.
>
Scala supports true closures which means that variables in scope (including
"this") are bound to the function.
Lift associates the function passed to SHtml.text(defaultValue,
passedFunction) with a GUID and returns places that GUID in the name
attribute of the generated <input/> HTML element. When the form is
submitted, Lift looks up the GUID in the function table and calls the
function with the passed parameter.
So, the "by whom" answer is the "runParams" method in LiftSession. This is
done early in the request cycle.
Does this help?
Thanks,
David
> I would like to understand this so that I could create tests for it.
>
> br,
> - Erik
>
> >
>
--
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
-~----------~----~----~----~------~----~------~--~---