Hi Joe,
I wish I could share some portion of this code, but I am afraid that my client would not accept it.
Yes, these two portions of code are my attempts to generate a link to a separate view, on which the snippet is displayed. A link, that will put the snippet into a desired state, by inserting some input data. The first one works, but sets the field again and again each refresh (F5) of destination site. That is sometimes acceptable, but sometimes it's not. For instance, if I want to create a new database object (to store exam immediate state), a refresh would cause the old being replaced with a fresh instance.
The latter call was my attempt to rewrite one of the snippets to StatefulSnippet, using some tutorials I found. It starts with a constructor (since stateful snippet is a class, not object) after which I try to set a field on link click. This does not work as expected - after going to /take_exam, the snippet displays information that the field has not been set. I don't know why.
So my question is quite open. I can either fix the original approach with SessionVars, but then I need a way to distinguish between a initial display and refreshes, to stop the object holding state from being overridden.
The other approach is to learn how to use stateful snippets (this is probably more advantageous), but there I am stuck with "how to set the state before user sees the snippet". Of course depending on which instance of link user clicks, I would like to be able to use different input data to snippet - otherwise I would just hardcode it.
I tried to google some samples on github, but I haven't found either a StatefulSnippet.link or StatefulSnippet.redirectTo example, just the code of the snippet itself.
Is that a better description of my question? I apologize for not being very specific - I am still learning liftweb, so I am not sure if I even look into right direction.
Kindest Regards
Andrzej Skalski