How can I pass results of a form submission to a page that I redirect to?
For example, lets say i have the following logic:
Search Page -> validate
if errors - show Search Page again with errors <--- this part works
else - redirect to New Page(passing search params) <-- no params passed
My form processing looks something like this:
def process() = {
if (nameame== "Joe") {
S.error("Joe not allowed!")
}
val dateRegex="(\\d\\d/\\d\\d/\\d\\d\\d\\d|\\w*)";
if (!birthdate.matches(dateRegex)) {
S.error("birthdate", "Invalid date. Please enter date in the form dd/mm/yyyy.")
}
S.errors match {
case Nil =>S.notice("Name: " + name); S.redirectTo("search-results")
case _ =>S.redirectTo(S.uri)
}
}
As you can see - my search results is not getting a "name" or "birthdate" params. How can I pass the parameters from the form when I do a S.redirectTo call?
Let me know if I can clarify the question somehow.
You can store the parameters in SessionVar's and access them from your search_results snippet or wherever you need them. See http://stable.simply.liftweb.net/#toc-Section-4.4.
Otherwise you could always do:
S.redirectTo("search-results?param1=value1") //Not very clean though
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With