lundi 6 novembre 2017

Scala liftweb framework

I have two checkboxes and on submit I want the user to download two different files, how do I go about this? I need help as am not able to get any online material on this. I am new to this framework.

This is what I've tried so far

def render = {
 def onSubmit1() : LiftResponse = {
       val userInput1 = S.param("getit").openOr("")
      val userInput2 = S.param("getit2").openOr("")
      val checkbox1 = S.param("yes").openOr("")
      val checkbox2  = S.param("yes").openOr("")
val fileToDownload = funFile(as, art, top)
       val fileName = "My File" 
 if (fileToDownload.equals()) {
         return S.redirectTo("/Somewhere")
       } else {
         InMemoryResponse(
          fileToDownload.mkString("\n").getBytes("UTF-8"),
            "Content-Type" -> "text/plain; charset=utf8" ::
             "Content-Disposition" -> s"attachment; filename=$fileName" :: Nil,
           cookies = Nil, code = 200)
       }
"#submitButton" #> SHtml.onSubmitUnit(onSubmit1)




Aucun commentaire:

Enregistrer un commentaire