i have a table called system it has some columns mainly number / char types but there is one binary type for holding a document (word or excel etc)
ignore for now if we should hold the file inline or external i.e. bfile or blob... the question is more about how to handle it in the play framework
I have got the form working with the model view and controller... but i set it up without the file-field just to get it working:
I have a case class in the model
case class System(sys_id: Pk[Long] = NotAssigned
, sys_name: String
, sys_desc: String
, sys_owner1: Long
, sys_owner2: Long)
a form in the controller
val systemForm = Form(
mapping(
"sys_id" -> ignored(NotAssigned:Pk[Long]),
"sys_name" -> nonEmptyText,
"sys_desc" -> nonEmptyText,
"sys_owner1" -> longNumber,
"sys_owner2" -> longNumber
)(System.apply)(System.unapply)
)
and a form in the view
@form(routes.Systems.save(), 'class -> "form-horizontal") {
@inputText(systemForm("sys_name"), '_label -> "System Name")
@inputText(systemForm("sys_desc"), '_label -> "Description")
@select(
systemForm("sys_owner1"),
persons,
'_label -> "Primary Owner", '_default -> "-- Choose a person --",
'_showConstraints -> false
)
@select(
systemForm("sys_owner2"),
persons,
'_label -> "Secondary Owner", '_default -> "-- Choose a person --",
'_showConstraints -> false
)
<div class="control-group">
<div class="controls">
<input type="submit" value="Create System" class="btn btn-success"> or
<a href="@routes.Systems.list()" class="btn">Cancel</a>
</div>
</div>
}
This all works well... but now i want to add the file in, what should i do? I have seen this http://www.playframework.com/documentation/2.1.2/ScalaFileUpload but it confuses me it makes no mention of if or how i should change the case class - and what variable is the file stored in (if it is) so that I can access it in my code?
should I modify my case class (if so what type should i add)? should I modify the Form in the controller (again if so what type should I add?)
im not bothered whether I store it inline or as a bfile - but how can I handle it as asked above?
Thank you