Anyone can help me on this one? Still stuck..

regards,
David

On Jun 14, 1:56 am, David Persons <dhwpers...@gmail.com> wrote:
> Hello heavy lifters,
>
> After a couple of late night Lift play-around sessions I thought this
> time I might as well ask the questions to you guys and get some
> sleep :-) I use a model which consists of storyboards and scenes. I
> use the Mapper Framework (for the first time). Underneath I have
> pasted some example code, I want to add content to a scene by
> uploading a file and selecting a type.
>
> 1. I want to write the uploaded file to disk. My approach underneath
> is not working, maybe I am just completely misunderstanding something.
> How to change the example so I can save to disk?
>
> 2. A scene maps to a storyboard (object storyboard extends
> MappedLongForeignKey(this, StoryBoard)). What is the the prettiest way
> of storing this storyboard in the currentStoryBoardVar?? I cannot
> simply say scene.storyboard because that results in a Long value.
> Furthermore, I now use the Box open_! method while that might not be
> necessary. So, there must be a very easy way to do this but I have not
> found it yet..
>
> 3. content.contenttype is a mapped enum (object contenttype extends
> MappedEnum(this, ContentType)):
>
> object ContentType extends Enumeration {
>   val Text = Value("text")
>   val Image = Value("image")
>   val Video = Value("video")
>
> }
>
> I use mysql for storage, how to map to a mysql enum
> ('text','image','video') field instead of the bigint(20) field it maps
> to right now?
>
> Thanks a lot!
>
> David Persons
>
> *********** C O D E ***********
>
> object currentStoryBoardVar extends RequestVar[Box[StoryBoard]](Empty)
> object currentSceneVar extends RequestVar[Box[Scene]](Empty)
>
> // the request-local variable that holds the file parameter
> private object theUpload extends RequestVar[Box[FileParamHolder]]
> (Empty)
>
> def addContent(form: NodeSeq) = {
>   val scene = currentSceneVar.is
>   val content = Content.create.scene(scene)
>
>   def checkAndSave(): Unit =
>     content.validate match {
>       case Nil => {
>         content.save
>         writeToFile
>         S.redirectTo("/editSB", () => currentStoryBoardVar(Full
> (scene.open_!.storyboard)))
>       }
>       case xs => S.error(xs); S.mapSnippet("SB.addContent", doBind)
>     }
>
>   def writeToFile(): Unit = {
>     theUpload.is match {
>       case Full(FileParamHolder(_, _, _, data)) => {
>         val stream = new FileOutputStream(new File("test.file"))
>         stream.write(data)
>         stream.close()
>       }
>       case _ =>
>     }
>   }
>
>   def doBind(form: NodeSeq) =
>     bind("content", form,
>       "contentType" -> content.contenttype.toForm,
>       "fileUpload" -> fileUpload(ul => theUpload(Full(ul))),
>       "submit" -> submit("Add", checkAndSave))
>     doBind(form)
>
> }

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@googlegroups.com
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to