Note that there are some explanatory texts on larger screens.

plurals
  1. POhow to handle fileupload into a table in play framework?
    primarykey
    data
    text
    <p>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)</p> <p>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</p> <p>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:</p> <p>I have a case class in the model</p> <pre><code>case class System(sys_id: Pk[Long] = NotAssigned , sys_name: String , sys_desc: String , sys_owner1: Long , sys_owner2: Long) </code></pre> <p>a form in the controller </p> <pre><code>val systemForm = Form( mapping( "sys_id" -&gt; ignored(NotAssigned:Pk[Long]), "sys_name" -&gt; nonEmptyText, "sys_desc" -&gt; nonEmptyText, "sys_owner1" -&gt; longNumber, "sys_owner2" -&gt; longNumber )(System.apply)(System.unapply) ) </code></pre> <p>and a form in the view</p> <pre><code>@form(routes.Systems.save(), 'class -&gt; "form-horizontal") { @inputText(systemForm("sys_name"), '_label -&gt; "System Name") @inputText(systemForm("sys_desc"), '_label -&gt; "Description") @select( systemForm("sys_owner1"), persons, '_label -&gt; "Primary Owner", '_default -&gt; "-- Choose a person --", '_showConstraints -&gt; false ) @select( systemForm("sys_owner2"), persons, '_label -&gt; "Secondary Owner", '_default -&gt; "-- Choose a person --", '_showConstraints -&gt; false ) &lt;div class="control-group"&gt; &lt;div class="controls"&gt; &lt;input type="submit" value="Create System" class="btn btn-success"&gt; or &lt;a href="@routes.Systems.list()" class="btn"&gt;Cancel&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; } </code></pre> <p>This all works well... but now i want to add the file in, what should i do? I have seen this <a href="http://www.playframework.com/documentation/2.1.2/ScalaFileUpload" rel="nofollow">http://www.playframework.com/documentation/2.1.2/ScalaFileUpload</a> 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?</p> <p>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?)</p> <p>im not bothered whether I store it inline or as a bfile - but how can I handle it as asked above?</p> <p>Thank you</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload