Created
March 26, 2012 14:51
-
-
Save dph01/2205642 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class StatelessTestRV extends Logger { | |
object searchResults extends RequestVar[List[String]](Nil) | |
def doSearch(param: String) = { | |
// dummy results .... | |
"one" :: "two" :: "three" :: Nil | |
} | |
def processSubmit(param: String) = { | |
searchResults(doSearch(param)) | |
var res = searchResults.is | |
S.seeOther("/stateless/results",() => searchResults(res)) | |
} | |
def search = { | |
"*" #> S.request.map( r => { | |
if ( r.post_? ) | |
// for post's, do search and redirect to results | |
r.param("queryparam").map( processSubmit(_) ) | |
// if request is a post and r.param is set, processing will not get past here | |
// due to processSubmit calling a S.seeOther | |
// otherwise, just return the contents of the input nodeseq | |
(n: NodeSeq ) => n | |
}).openOr( (n: NodeSeq ) => n ) | |
} | |
def results = { | |
".row *" #> searchResults.is.map( r => { | |
".value *" #> Text(r) | |
})} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment