Refresh page on detection of unmapped lift-like parameter

46 views
Skip to first unread message

Colin Bester

unread,
Sep 15, 2020, 4:46:13 PM9/15/20
to Lift
I am using liftweb 3.1 and occasionally I am seeing warning `Unmapped Lift-like parameter seen in Unmapped Lift-like parameter ...`. My understanding is that this is due to GC, I am seeing this warning on what I'd call pure liftweb pages where binding is only via csssel and am also seeing in snippet where I am using lift-ng for angular.

I am wondering what is best way to handle refreshing the current page so that user is not stuck in no-response hell and has to manually refresh the screen which often results in a call to support desk.

I have two different methods working:

LiftRules.handleUnmappedParameter.default.set((req: Req, parameterName: String) => {
  if (parameterName.startsWith("F")) {
    logger.warn("my Unmapped Lift-like parameter seen in request [%s]: %s".format(req.uri, parameterName))
    S.appendJs(Reload)
  }
})

and 

val whence = S.referer openOr "/"
LiftRules.handleUnmappedParameter.default.set((req: Req, parameterName: String) => {
  if (parameterName.startsWith("F")) {
    logger.warn("my Unmapped Lift-like parameter seen in request [%s]: %s".format(req.uri, parameterName))
    throw ResponseShortcutException.redirect(S.referer openOr "/")
  }
})

Appreciate suggestions...

Antonio Salazar Cardozo

unread,
Sep 16, 2020, 2:32:32 PM9/16/20
to Lift
Hey Colin,
Both of these approaches Work™. Of the two, the second is probably more flexible, as I believe (it's been a while) that Lift automatically resolves the `ResponseShortcutException.redirect` to a JS redirect when needed, and an HTTP redirect when that makes more sense. There's also been some work here and there to approach this in a way that doesn't require a full-page reload, with the deepest effort there I believe being from Joe Barnes for Angular as part of https://github.com/joescii/lift-ng . I'm not sure if that work made it into a lift-ng release or not.

In general, it's not a trivial problem, and I had a really rough attempt a while back that reloaded the page in an iframe and reassigned function identifiers manually. It was incomplete and felt pretty hacky though, so not suitable for inclusion in mainline---I imagine there's probably something about it on the list :)

Was there something in particular you were trying to achieve that the above code doesn't do?
Thanks,
Antonio

Colin Bester

unread,
Sep 18, 2020, 10:50:25 PM9/18/20
to Lift
Thanks Antonio, both code snippets worked. The second seemed to me to be better option as with first on I’d notice several log entries whereas for second snippet it only logged once. Not sure why this was. 
Reply all
Reply to author
Forward
0 new messages