My next todo: Form processing

0 views
Skip to first unread message

thebug...@gmail.com

unread,
Jul 9, 2008, 9:01:33 PM7/9/08
to SweetScala
These are on my mind. I want to let developer do the following when
processing a form:

class MyController extends FormController {

handle("/newUser"){ (req, form) =>
val user = new User(form("firstName"), form("lastName"),
form("email"))
//do ... something with user
View("/newUser", "user"-> user)
}

}

On our end, we need the handle action to be consistent with existing
Controller trait. This allow the abstraction to have a change to
extract the form object out of request before passing back into the
closure.

The definition of Form class will be something like this:

class Form(req: Req) {
def apply(name: String){
req.getRequiredParam(name)
}
}

Of course we need to pimp up the normal HttpServletRequest to have
following methods for general use

#getRequiredParam(name: String): String // throw exception if now
found.
#getOptionalParam(name: String) : Option[String]

What do you think?
Reply all
Reply to author
Forward
0 new messages