Steve
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code
That might be what you want.
If you want to remove the Box, there's more work to do (because Box.flatMap expects a function that results in a Box, and req.params isn't in a Box). This looks plausible to me:
val b : Map[String,List[String]] = S.request.map(_.params).getOrElse(Map.empty)
Or, if you prefer, you can convert from Box to List:
val c : Map[String,List[String]] = S.request.toList.flatMap(_.params).toMap
S.request.toList gives you a (possibly zero length) List[Req] which is flatMapped to a List of pairs (String,List[String]) which you can turn back into a Map with toMap.
Hope that helps
Richard
Thanks Richard, Your solution seemed to work exactly how I was
looking for it to! I have another question about creating arrays in
the url query string and then retrieving them back. I was told Ruby
has a simple way to do this. But I'll write up a new post about that
question.
Thanks a lot man!
On Dec 22, 11:44 am, Richard Dallaway <rich...@dallaway.com> wrote:
> On Thursday, 22 December 2011 at 15:20, steve wrote:
> > Hey David, Thanks for the response. This seems to be along the lines
> > of what I'm looking for, but I'm getting an error when I use it that
> > I'm struggling to figure out.
>
> > [error] found : Map[String,List[String]]
> > [error] required: net.liftweb.common.Box (http://web.common.Box)[?]
> > [error] val a = S.request.flatMap(_.params) // Box[Map[String,
> > List[String]]
>
> S.request is Box[Req], so it might be empty. What we can do is map over it, which I think of as "opening the box", applying a function, and putting the result back in the box:
>
> val a : Box[Map[String,List[String]]] = S.request.map(_.params)
>
> That might be what you want.
>
> If you want to remove the Box, there's more work to do (because Box.flatMap expects a function that results in a Box, and req.params isn't in a Box). This looks plausible to me:
>
> val b : Map[String,List[String]] = S.request.map(_.params).getOrElse(Map.empty)
>
> Or, if you prefer, you can convert from Box to List:
>
> val c : Map[String,List[String]] = S.request.toList.flatMap(_.params).toMap
>
> S.request.toList gives you a (possibly zero length) List[Req] which is flatMapped to a List of pairs (String,List[String]) which you can turn back into a Map with toMap.
>
> Hope that helps
> Richard
--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code