开发者

Lift redirect to a new page after form submission with parameters

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

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜