Reputation: 105
Using Lift, I would like to display a notice to a user after they sign up with something like:
S.notice("Thank you for signing up")
Where would I put this code, or is there another way I should I go about this?
Upvotes: 2
Views: 189
Reputation: 7848
You should be able to put it anywhere in your code to be output on the current page. However, if your code handles the form submission and then redirects to a separate page - you would probably need something like this:
S.redirectTo("/confirm", () => S.notice("Thank you for signing up"))
This will issue the redirect with state. The above executes the function after the redirect - causing the message to be displayed.
In the case of ProtoUser, there are a few places in the API (http://scala-tools.org/mvnsites/liftweb-2.4/#net.liftweb.mapper.MegaProtoUser) that seem like they would work:
user.toForm("Create User",
(u:UserType) => S.notice("Thank you for signing up"))
or you could try calling (or overriding if you want it permanently) this method:
doPostCommit(() => S.notice("Thank you for signing up")
Upvotes: 1