Sorry, to clarify, the function () => processAdd(oVar.is) will not capture the current value of oVar. Rather, the oVar.is call is made when the submit function is called.
Derek On Mon, Jun 1, 2009 at 10:51 AM, Derek Chen-Becker <dchenbec...@gmail.com>wrote: > Actually, based on my experience the first one shouldn't work and the > second one should, because in the first one, oVar.is is called within the > context of of the submit request, not the bind request. > > Derek > > > On Sun, May 31, 2009 at 11:18 AM, feelgood <asseliva...@gmail.com> wrote: > >> >> Compare two cases. First: >> >> class SnippetName { >> object oVar extends RequestVar(O.create) >> >> def processAdd(o: O) { ... } >> >> def add(xml: NodeSeq): NodeSeq = { >> bind ("f", xml, >> "field" -> SHtml.text(oVar.is.field, oVar.is.field(_)), >> "submit" -> SHtml.submit("Submit", () => processAdd(oVar.is) >> ) >> } >> } >> >> And the second case: >> >> class SnippetName { >> object oVar extends RequestVar(O.create) >> >> def processAdd(o: O) { ... } >> >> def add(xml: NodeSeq): NodeSeq = { >> val o = oVar.is // CHANGES STARTS HERE >> >> bind ("f", xml, >> "field" -> SHtml.text(o.field, o.field(_)), >> "submit" -> SHtml.submit("Submit", () => processAdd(o) >> ) >> } >> } >> >> In firts case all works fine, but in second case data not retained >> across submit trying. Why? >> >> >> >> > --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---