Thanks ! :)
Your solution is much DRY then my :) : {img.contentType.toString.isEmpty match { case true => "application/ octet-stream" case false => img.contentType.is.toString}} Best regards, On 26 Lis, 15:10, Jeppe Nejsum Madsen <je...@ingolfs.dk> wrote: > Marcin Jurczuk <mjurc...@gmail.com> writes: > > Thanks .. read that ...and look and dmap implementation however it > > doesn't work like I expected: > > > scala> r.dmap("application/octet-stream")(_.contentType.is) > > res49: java.lang.String = null > > This is (probably) because contentType is null. The dmap only opens the > Box returned from the query. This will be empty if the query fails. > > Now you have the result of the query, but the result can still contain a > null value for the field contentType, so you need something like this: > > r.dmap("application/octet-stream")(b => if (b.contentType.is == null) > "application/octet-stream" else b.contentType.is) > > or, to be more DRY > > r.flatMap(b => Box !! b.contentType.is) openOr "application/octet-stream" > > Basically, unpack the query result and put the contenType in a new box, > unpack everything or return the default :-) > > /Jeppe -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.