Example for using Crudify with Squeryl-Record?

294 views
Skip to first unread message

Trond Marius Øvstetun

unread,
Apr 7, 2011, 3:15:34 AM4/7/11
to lif...@googlegroups.com
Hi.

I have opted to use Squery-Record for a new project in Lift, and for a part of the application I need a simple administration interface. My initial thought was to use Crudify for this, but I can't find any examples for how to implement Crudify on a SquerylRecord class.

Any pointers?

Thanks,
Trond Marius

David Whittaker

unread,
Apr 7, 2011, 10:03:29 AM4/7/11
to lif...@googlegroups.com
Hi Trond,

I haven't actually tried this myself, but since Crudify seems to support Record and Squery/Record uses the same field types as other Record implementations the process shouldn't be much different than using Crudify with Mapper.  I'd suggest you go based on the blog posts referenced from the Wiki: http://www.assembla.com/wiki/show/liftweb/Creating_the_UI_for_Mapper_entities.  If you run into anything that doesn't make sense in terms of Record let me know and I'll do what I can to help you out.

2011/4/7 Trond Marius Øvstetun <tr...@ovstetun.no>
--
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.

Tim Nelson

unread,
Apr 7, 2011, 10:16:34 AM4/7/11
to lif...@googlegroups.com
Hi,

Your other option is to use LiftScreen.

Tim

Trond Marius Øvstetun

unread,
Apr 8, 2011, 4:36:44 AM4/8/11
to lif...@googlegroups.com
Hi, and Yeah, I know I could use LiftScreen. But LiftScreen would give me the functionality I need for editing a single Record-instance. The reason I wanted to use Crudify is to get the full shebang - listing, create, edit..

I tried to mix in Crudify, but got a lot of compiler errors for functions I hadn't implemented, and wanted to hear if anyone else have a working solution that could work as an example - or even better be a reusable component (something like a new squeryl-related trait including general functions and such that I could mix, like mapper.CRUDify).

The case I have tried:
package no.ovstetun
package model

import net.liftweb.record.{MetaRecord, Record}
import net.liftweb.squerylrecord.KeyedRecord
import net.liftweb.record.field.{StringField, LongField}
import net.liftweb.proto.Crudify
class User private ()
        extends Record[User]
        with KeyedRecord[Long] {

  val idField = new LongField(this, 0)
  val name = new StringField(this, "")

  def meta = User
}

object User extends User with MetaRecord[User] with Crudify {
  
}

And I get the following compiler errors:

[error] method computeFieldFromPointer in trait Crudify of type (instance: no. ovstetun.model.User.TheCrudType,pointer: no.ovstetun.model.User.FieldPointerType)net.liftweb.common.Box[net.liftweb.util.BaseField] is not defined
[error] method findForParam in trait Crudify of type (in: String)net.liftweb.common.Box[no. ovstetun.model.User.TheCrudType] is not defined
[error] method findForList in trait Crudify of type (start: Long,count: Int)List[no. ovstetun.model.User.TheCrudType] is not defined
[error] method fieldsForDisplay in trait Crudify of type => List[no. ovstetun.model.User.FieldPointerType] is not defined
[error] method create in trait Crudify of type => no. ovstetun.model.User.TheCrudType is not defined
[error] method calcPrefix in trait Crudify of type => List[String] is not defined
[error] method buildFieldBridge in trait Crudify of type (from: no. ovstetun.model.User.FieldPointerType)no. ovstetun.model.User.FieldPointerBridge is not defined
[error] method buildBridge in trait Crudify of type (from: no. ovstetun.model.User.TheCrudType)no. ovstetun.model.User.CrudBridge is not defined
[error] object User extends User with MetaRecord[User] with Crudify {


I have looked at mapper.CRUDify, but I cannot grasp how to implement the CrudBridge or understand what a FieldPointer and FieldPointerBridge is..
Any help would be much appreciated :)

Thanks,
Trond Marius


--
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.



--
TronD

David Whittaker

unread,
Apr 8, 2011, 10:55:27 AM4/8/11
to lif...@googlegroups.com
I see what you mean.  Let me dig a little further and I'll get back to you.

2011/4/8 Trond Marius Øvstetun <tr...@ovstetun.no>

Trond Marius Øvstetun

unread,
Apr 11, 2011, 4:17:13 AM4/11/11
to lif...@googlegroups.com
Thanks :)

David Whittaker

unread,
Apr 11, 2011, 10:42:42 AM4/11/11
to lif...@googlegroups.com
No problem.  So it seems that we need an adapter between the Crudify trait and Squeryl type persistence.  I'll get that committed for 2.4 but in the time being you can use this as a guide: https://github.com/iradix/crudify/blob/master/src/main/scala/code/model/TestRecord.scala.  You can just copy/paste the SquerylCrudify trait into your project then implement the table and idFromString methods in your MetaRecord.

I created a ticket for addition of this feature to Lift.  https://www.assembla.com/spaces/liftweb/tickets/967-squeryl-record-support-for-crudify

2011/4/11 Trond Marius Øvstetun <tr...@ovstetun.no>

Trond Marius Øvstetun

unread,
Apr 12, 2011, 3:38:13 AM4/12/11
to lif...@googlegroups.com
Great! Thank you so much, that worked with just a couple of modifications needed for compiling in my case:

override def calcPrefix = List("users") // in User object
// override def calcPrefix = table.name :: Nil // this didn't compile when I added User.menus to sitemap. A _very_ long output, seems some type inference failed somewhere on the way.

Thank you again, and for putting this in 2.4 :)

/trondmarius

David Whittaker

unread,
Apr 13, 2011, 12:57:22 PM4/13/11
to lif...@googlegroups.com
Could you possibly send me the error you were getting?

2011/4/12 Trond Marius Øvstetun <tr...@ovstetun.no>

David Whittaker

unread,
May 31, 2011, 12:48:16 PM5/31/11
to lif...@googlegroups.com
Trond,

Just so you know for future use, there is now a net.liftweb.squerylrecord.CRUDify trait.  It's available in the latest 2.4-SNAPSHOT(s) and shortly in 2.4-M1.

2011/4/12 Trond Marius Øvstetun <tr...@ovstetun.no>
Great! Thank you so much, that worked with just a couple of modifications needed for compiling in my case:
Reply all
Reply to author
Forward
0 new messages