Add helpers to snapshot and pass objects in request parameters
Accordingly to discussion Passing objects with RequestVar via GET request
dpp:
Personally, I'd do this with RequestVars rather than with SessionVars because that gives you scope over the variables (they're good for the scope of a single request rather than for the entire session).
So, if you've got a couple of RequestVars, you can do the following:
The snapshot method creates a function that will restore the RequestVars to the state that they had when it was called. The buildCallbackURL method takes a base URL (built using whatever mechanism you choose) and appends the restore function to it. When that URL is hit on the server, the RequestVars will be restored and away you go.
nafg:
Neat code! Maybe it would be useful to have a generalization in the library?
1. def snapshot(rvs: RequestVar*): ()=>Unit
2. def urlWithState(baseUrl: String, state: ()=>Unit)
dpp:
Personally, I'd do this with RequestVars rather than with SessionVars because that gives you scope over the variables (they're good for the scope of a single request rather than for the entire session).
So, if you've got a couple of RequestVars, you can do the following:
object rv1 extends RequestVar...
object rv2 extends RequestVar...
def snapshot(): () => Unit = {
val v1 = rv1.get
val v2 = rv2.get
() => {rv1.set(v1); rv2.set(v2)}
}
def buildCallbackURL(baseURL: String): String = S.fmapFunc(snapshot())(key => Helpers.appendFuncToURL(baseURL, key +"=_"))
The snapshot method creates a function that will restore the RequestVars to the state that they had when it was called. The buildCallbackURL method takes a base URL (built using whatever mechanism you choose) and appends the restore function to it. When that URL is hit on the server, the RequestVars will be restored and away you go.
nafg:
Neat code! Maybe it would be useful to have a generalization in the library?
1. def snapshot(rvs: RequestVar*): ()=>Unit
2. def urlWithState(baseUrl: String, state: ()=>Unit)
Leave a comment
(In revision:614098d4098bd6ce89e529f8638e877b440be92c) Closes #978. Added snapshot capability to RequestVar and allow RequestVar to be put in groups and snapshotted as a group
Branch: master
Branch: master