Andreas Joseph Krogh | 1 Sep 2011 01:05
Picon
Favicon

Re: [Lift] Executing a function in "previous request"-context

On 09/01/2011 12:19 AM, David Pollak wrote:
> 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.

Note that it's not restoring any (of mine) RequestVars I'm after, but
maybe Lift uses RequestVars internally to hold some internal state it
then uses to look-up snippet-invications?

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).

Thanks for looking into this.

--

-- 
Andreas Joseph Krogh <andreak@...>
Senior Software Developer / CTO - OfficeNet AS
(Continue reading)

David Pollak | 1 Sep 2011 01:10
Picon
Gravatar

Re: [Lift] Executing a function in "previous request"-context



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:
> 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.

Note that it's not restoring any (of mine) RequestVars I'm after, but
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?
 

Thanks for looking into this.

--
Andreas Joseph Krogh <andreak <at> officenet.no>
Senior Software Developer / CTO - OfficeNet AS
http://www.officenet.no - mob: +47 909 56 963
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to liftweb-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
To unsubscribe from this group, send email to liftweb+unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
Lift, the simply functional web framework http://liftweb.net

--
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 <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Andreas Joseph Krogh | 1 Sep 2011 01:17
Picon
Favicon

Re: [Lift] Executing a function in "previous request"-context

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:
> 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.

Note that it's not restoring any (of mine) RequestVars I'm after, but
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.
-- 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.
Andreas Joseph Krogh | 1 Sep 2011 01:27
Picon
Favicon

Re: [Lift] Executing a function in "previous request"-context

On 09/01/2011 01:17 AM, Andreas Joseph Krogh wrote:
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:
> 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.

Note that it's not restoring any (of mine) RequestVars I'm after, but
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.
Andreas Joseph Krogh | 1 Sep 2011 08:58
Picon
Favicon

Sv: Re: [Lift] Executing a function in "previous request"-context

På torsdag 01. september 2011 kl 01:27:25 skrev du:

On 09/01/2011 01:17 AM, Andreas Joseph Krogh wrote:
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:
> 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.
Note that it's not restoring any (of mine) RequestVars I'm after, but
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.

 

I've updated the project on github (just now) with what I thought was the correct use of snapshot(), which is a bit simpler than what I tried yesterday. But it's still failing to execute in the context the generateSnapshotRestorer was called.

The problem manifests it self in the following way:

- When the dialog (PopupEditSnippet)  calls the function stored in the projectUpdatedCallbackFuncVar it returns JsCmd which replaces some elements on the page (the elements replaced are the last column in the list displaying "modified" and ""Edit"-link). 
- The elements on the DOM are updated (one can see the, but the JsCmd is generated in the context of the snippet backing the dialog. This is OK if the JsCmd was to update the DOM inside the dialog, to keep state of the popup, but the HTML generated (which is updated by the JsCmd) is placed on the page in the background so it must be generated in a way that renders links etc. to point to correct context.

Is it clear what I'm trying to achieve?

Thanks.

--
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 <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Andreas Joseph Krogh | 5 Sep 2011 11:59
Picon
Favicon

Sv: Sv: Re: [Lift] Executing a function in "previous request"-context

David; Have you had a chance to test this any further?

Pleas let me know if you still have problems bootstrapping the app and I'll make it use Derby instead of PG.

Thanks.

--
Andreas
 

På torsdag 01. september 2011 kl 08:58:02 skrev Andreas Joseph Krogh <andreak <at> officenet.no>:

På torsdag 01. september 2011 kl 01:27:25 skrev du:

On 09/01/2011 01:17 AM, Andreas Joseph Krogh wrote:
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:
> 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.
Note that it's not restoring any (of mine) RequestVars I'm after, but
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.

 

I've updated the project on github (just now) with what I thought was the correct use of snapshot(), which is a bit simpler than what I tried yesterday. But it's still failing to execute in the context the generateSnapshotRestorer was called.

The problem manifests it self in the following way:

- When the dialog (PopupEditSnippet)  calls the function stored in the projectUpdatedCallbackFuncVar it returns JsCmd which replaces some elements on the page (the elements replaced are the last column in the list displaying "modified" and ""Edit"-link). 
- The elements on the DOM are updated (one can see the, but the JsCmd is generated in the context of the snippet backing the dialog. This is OK if the JsCmd was to update the DOM inside the dialog, to keep state of the popup, but the HTML generated (which is updated by the JsCmd) is placed on the page in the background so it must be generated in a way that renders links etc. to point to correct context.

Is it clear what I'm trying to achieve?

Thanks.

--
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 <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.




--
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 <at> googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.

Gmane