My code looks like this:
trait IViewable extends BaseLongKeyedMapper {
object image extends MappedBinary(this.asInstanceOf[MapperType]) {
override def dbDisplay_? = false
}
object imagePath extends MappedBinary(this.asInstanceOf[MapperType]) {
def notEmpty(input: String) = {
println("input=" + input)
if (input.isEmpty) {
List(FieldError(this, "Choose a file!"))
}
else Nil
}
override def _toForm = {
Full(SHtml.fileUpload(saveFile _))
}
override def displayName = "BILD"
//override def validations = notEmpty _ :: Nil
}
private def saveFile(fp: FileParamHolder): Unit = {
println("*** saveFile ***")
fp.file match {
case null => {
println("saveFile: null")
}
case x if x.length == 0 => {
println("saveFile: empty file")
}
case _ => {
println("saveFile: default")
}
}
}
}
On my Mapper object I use CRUDify and mixin the above trait.
The overridden _toForm renders fine, but when I select a file and
"create" my CRUDified instance I see that the method saveFile is not
invoked. Why?
thanks.
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
You can't use CRUDify with multi-part MIME uploads and multi-part MIME is required for file upload.ᅵ Sorry.
On Mon, Dec 6, 2010 at 7:08 AM, Hannes <hannes...@gmx.li> wrote:
I have a problem with SHtml.fileUpload.
My code looks like this:
trait IViewable extends BaseLongKeyedMapper {
ï¿œobject image extends MappedBinary(this.asInstanceOf[MapperType]) {
ᅵ override def dbDisplay_? = false
ᅵ}
ï¿œobject imagePath extends MappedBinary(this.asInstanceOf[MapperType]) {
ᅵ def notEmpty(input: String) = {
ᅵ ᅵ println("input=" + input)
ᅵ ᅵ if (input.isEmpty) {
ᅵ ᅵ ᅵ List(FieldError(this, "Choose a file!"))
ᅵ ᅵ }
ᅵ ᅵ else Nil
ᅵ }
ᅵ override def _toForm = {
ᅵ ᅵ Full(SHtml.fileUpload(saveFile _))
ᅵ }
ᅵ override def displayName = "BILD"
ᅵ //override def validations = notEmpty _ :: Nil
ᅵ}
ï¿œprivate def saveFile(fp: FileParamHolder): Unit = {
ᅵ println("*** saveFile ***")
ᅵ fp.file match {
ᅵ ᅵ case null => {
ᅵ ᅵ ᅵ println("saveFile: null")
ᅵ ᅵ }
ᅵ ᅵ case x if x.length == 0 => {
ᅵ ᅵ ᅵ println("saveFile: empty file")
ᅵ ᅵ }
ᅵ ᅵ case _ => {
ᅵ ᅵ ᅵ println("saveFile: default")
ᅵ ᅵ }
ᅵ }
ᅵ}
}
On my Mapper object I use CRUDify and mixin the above trait.
The overridden _toForm renders fine, but when I select a file and "create" my CRUDified instance I see that the method saveFile is not invoked. Why?
thanks.
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.
Okay, thanks.
So this means this is a limitation of CRUDify and in case I wanna have uploads I need to make my own Snippet?
You can't use CRUDify with multi-part MIME uploads and multi-part MIME is required for file upload. Sorry.
On Mon, Dec 6, 2010 at 7:08 AM, Hannes <hannes...@gmx.li> wrote:
I have a problem with SHtml.fileUpload.
My code looks like this:
trait IViewable extends BaseLongKeyedMapper {
object image extends MappedBinary(this.asInstanceOf[MapperType]) {
override def dbDisplay_? = false
}
object imagePath extends MappedBinary(this.asInstanceOf[MapperType]) {
def notEmpty(input: String) = {
println("input=" + input)
if (input.isEmpty) {
List(FieldError(this, "Choose a file!"))
}
else Nil
}
override def _toForm = {
Full(SHtml.fileUpload(saveFile _))
}
override def displayName = "BILD"
//override def validations = notEmpty _ :: Nil
}
private def saveFile(fp: FileParamHolder): Unit = {
println("*** saveFile ***")
fp.file match {
case null => {
println("saveFile: null")
}
case x if x.length == 0 => {
println("saveFile: empty file")
}
case _ => {
println("saveFile: default")
}
}
}
}
override def _createTemplate = super._createTemplate % new
UnprefixedAttribute("multipart", Text("yes"), Null)
It will add the required multipart="yes" to the snippet tag in the create-
template.
While looking through the code, I found the property uploadField_? of the
class BaseField (BaseField.scala:103). Unfortunately this property is not used
by Crudify (It's only used in the Screen library). I will try to write a patch
for this (and add a ticket).
Regards,
Michael
> By the way, I saw that there's a LongCRUDify trait which should be used
> with LongKeyedMetaMappers. I use a LongKeyedMetaMappers but with the
> "old" CRUDify, is that a problem?
LongCRUDify is the same as CRUDify[Long], so I don't think there is a problem
in using either one
I just added the ticket:
https://www.assembla.com/spaces/liftweb/tickets/761-allow-file-uploads-with-crudify
--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/liftweb?hl=en.