Mapping nested case class

8 views
Skip to first unread message

Mrityunjay Kant

unread,
Jan 22, 2012, 2:42:48 AM1/22/12
to Bowler Users
Consider the following model:

case class Compensation( code : String, desc : String}
case class Employee( empNum : String, fullName : String, comp :
Option[Compensation])

Controller method:

def `POST /employee` (emp : Employee) = { /* do something here */ }

I'm trying to get bowler to do automatic case class conversion to an
Employee object, but the comp var doesn't seem to get inited. I've
tried couple of variations with parameter names but it doesn't seem to
work.

Does Bowler not support nested case classes when mapping request
params?

regards,
Mrityunjay

Wille Faler

unread,
Jan 22, 2012, 7:37:06 AM1/22/12
to bowler...@googlegroups.com
For JSON requests nested classes are supported, as they are quite easily expressed through JSON.
When it comes to nested object in regular POST's, it is only supported through id lookups (for instance creating a custom StringValueTransformer: http://bowlerframework.org/manual.html#valuetransformers).

Bowler does not currently support nested models otherwise for regular POST's/PUT's, as the normal parameter model of HTTP requests is a "flat" data structure in nature..

If you do have ideas on how to solve the impedance mismatch between HTTP and nested case classes, I'm very open to suggestions though, as it would definitely be a nice to have!
Reply all
Reply to author
Forward
0 new messages