1 Sep 2011 01:27
Re: [Lift] Executing a function in "previous request"-context
On 09/01/2011 01:17 AM, Andreas Joseph Krogh wrote:
To be more precise: I only want to re-use the snippet backing the dialog (ProjectEditSnippet) when I perform operations "inside" the dialog. This works fine, but after saving, the snippet backing the dialog performs the callback (stored in projectUpdatedCallbackFuncVar, set by another snippet, ProjectSnippet), which re-renders the "Edit-link" and "modified" in the list, the "Edit"-link is rendered in a way that makes Lift reuse the previous snippet-instance, which I don't want.
-- Andreas Joseph Krogh <andreak-S8R3tkJnxyylHtIdYg32fQ@public.gmane.org> Senior Software Developer / CTO - OfficeNet AS http://www.officenet.no - mob: +47 909 56 963 Public key: http://home.officenet.no/~andreak/public_key.asc --
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to liftweb+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
On 09/01/2011 01:10 AM, David Pollak wrote:On Wed, Aug 31, 2011 at 4:05 PM, Andreas Joseph Krogh <andreak-S8R3tkJnxyylHtIdYg32fQ@public.gmane.org> wrote:On 09/01/2011 12:19 AM, David Pollak wrote:Note that it's not restoring any (of mine) RequestVars I'm after, but
> I can't run your code, so I'll give you the short answer:
>
> object SomeRequestVar extends RequestVar("Hello")
>
> val context snapshot = SomeRequestVar.generateSnapshotRestorer[JsCmd]()
>
> .... // some code that gets executed at some point in the future:
>
> val myJsCmd = snapshot(() => doFunctionThatCalculatesJsCmd)
>
> The doFunctionThatCalculatesJsCmd will be executed with the
> RequestVars snapshotted at the time the generateSnapshotRestorer()
> method is called.
>
> Hope this helps.
maybe Lift uses RequestVars internally to hold some internal state it
then uses to look-up snippet-invications?
Snippets are stored in an internal RequestVar so if you snapshot the RequestVars (the generateSnapshotRestorer() method snapshots *all* requestvars) then you'll get the snippets.
I updated github (in file ProjectSnippet) with code like the above, with
no luck. The snippet-instance is re-used once I try to re-edit an
already edited project (without reloading the page).
Right... aren't you trying to reuse the snippet?
The overall goal is to create new snippet-instances (backing the dialog) *only* when one clicks "New project" or "Edit" on the base page (the page showing the list). Once the dialog is shown I want to reuse the snippet backing it (for validation etc.), but I don't want that instance re-used after closing/saving.
To be more precise: I only want to re-use the snippet backing the dialog (ProjectEditSnippet) when I perform operations "inside" the dialog. This works fine, but after saving, the snippet backing the dialog performs the callback (stored in projectUpdatedCallbackFuncVar, set by another snippet, ProjectSnippet), which re-renders the "Edit-link" and "modified" in the list, the "Edit"-link is rendered in a way that makes Lift reuse the previous snippet-instance, which I don't want.
-- Andreas Joseph Krogh <andreak-S8R3tkJnxyylHtIdYg32fQ@public.gmane.org> Senior Software Developer / CTO - OfficeNet AS http://www.officenet.no - mob: +47 909 56 963 Public key: http://home.officenet.no/~andreak/public_key.asc --
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To unsubscribe from this group, send email to liftweb+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
RSS Feed