ModelView save return type

2 views
Skip to first unread message

Naftoli Gugenheim

unread,
Nov 23, 2009, 7:17:19 PM11/23/09
to liftweb
Some time ago I discovered a small bug in my webapp.
I use ModelSnippet / ModelView. A submit button called the ModelView's save method and then invoked another method. I realized that other method wasn't getting invoked because save was ultimately leading to a redirect (back to the list page).
So I have a few questions.
  1. Should ModelView.save be declared to return Nothing instead of Unit? It either calls onSave of S.error depending on whether saving was successful. This would indicate that it doesn't return. However, you can change the value of onSave on the ModelSnippet which is what does the actual redirect, so it may return.
    • Similarly should onSave have an explicit type annotation? What should it be?
  2. When a method is declared to return Nothing, why does the compiler allow you to put statements after it if they can't be reached? (Not really a Lift question.)
  3. Is there or should there be a way in Lift to trigger a redirect but allow code to execute to completion?

Reply all
Reply to author
Forward
0 new messages