[Lift] Error reporting and early failure in lift ?
Hello guys, I'm really new to lift application development, even if I try to follow the framework evolution almost since it's start. I'm coming from Tapestry 5 world, and so, I'm just discovering basic Lift features. For now, I can say that there is really cool things here, things that Scala make so simple, things in the AJAX land... But one of the things I really liked in T5 and miss a lot with in first days of Lift is T5 awesome error reporting and early failure behaviour. You know, for now I'm playing with little examples, trying to modify the Pocket Change App of Lift book, this kind of things. And I have to say that a lot of my try are not successful. In T5, when something goes wrong, T5 takes me by the hand, show me the piece of template where the error happens, the faulty code, and give me advices on how to correct the problem. Moreover, T5 default behaviour is to fail early, so that less bad code is waiting for users to discover it - developers get big exceptions that they can't honestly ignore. There is (an really old) example of T5 error reporting here: http://tapestryjava.blogspot.com/2007/09/itch-scratching-even-better-feedback.html Now, the report is even better than that, especially when compond components are involved. There is an other example of enhanced error reporting, this time in the console: http://tapestryjava.blogspot.com/2008/12/exception-reporting-why.html So, what the goal of the mail ? Well, just to bring the attention of core team on how it's important and great to have good feedback from the framework (error reporting, early failure) and I do believe that T5 is state of the art in that domain... So if you look for inspiration, it might be the good place to look at. When I will be (if I become) more versatile in Lift, perhaps I would be able to help improve in this domain, but for now, it's clearly out of my reach :) -- Francois Armand http://fanf42.blogspot.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Error reporting and early failure in lift ?
Francois, That is a very valid point and there is significant attention in lift development to improve error reporting. In fact David made some really significant steps in this area in 1.1-SNAPSHOT so that if an unexpected error occurs in development mode there is a helpful message rendered on the page. But sure lots of things can and will be done to improve this. Just wanted to say that we're fully aware of the situation. Br's, Marius On Jun 19, 1:15 pm, fan...@gmail.com fan...@gmail.com wrote: Hello guys, I'm really new to lift application development, even if I try to follow the framework evolution almost since it's start. I'm coming from Tapestry 5 world, and so, I'm just discovering basic Lift features. For now, I can say that there is really cool things here, things that Scala make so simple, things in the AJAX land... But one of the things I really liked in T5 and miss a lot with in first days of Lift is T5 awesome error reporting and early failure behaviour. You know, for now I'm playing with little examples, trying to modify the Pocket Change App of Lift book, this kind of things. And I have to say that a lot of my try are not successful. In T5, when something goes wrong, T5 takes me by the hand, show me the piece of template where the error happens, the faulty code, and give me advices on how to correct the problem. Moreover, T5 default behaviour is to fail early, so that less bad code is waiting for users to discover it - developers get big exceptions that they can't honestly ignore. There is (an really old) example of T5 error reporting here:http://tapestryjava.blogspot.com/2007/09/itch-scratching-even-better-... Now, the report is even better than that, especially when compond components are involved. There is an other example of enhanced error reporting, this time in the console:http://tapestryjava.blogspot.com/2008/12/exception-reporting-why.html So, what the goal of the mail ? Well, just to bring the attention of core team on how it's important and great to have good feedback from the framework (error reporting, early failure) and I do believe that T5 is state of the art in that domain... So if you look for inspiration, it might be the good place to look at. When I will be (if I become) more versatile in Lift, perhaps I would be able to help improve in this domain, but for now, it's clearly out of my reach :) -- Francois Armandhttp://fanf42.blogspot.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Error reporting and early failure in lift ?
marius d. a écrit : Francois, That is a very valid point and there is significant attention in lift development to improve error reporting. In fact David made some really significant steps in this area in 1.1-SNAPSHOT so that if an unexpected error occurs in development mode there is a helpful message rendered on the page. But sure lots of things can and will be done to improve this. Just wanted to say that we're fully aware of the situation. Cool, so I'm going to switch to 1.1-SNAPSHOT for my testing ;) -- Francois Armand http://fanf42.blogspot.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Best way to create enum-like custom field mapping
Hi, Using mapper I have this: object FuelTypes extends Enumeration { val Diesel = new Val(1, Diesel) val Petrol = new Val(2, Benzin) } object fuelType extends MappedEnum(this, FuelTypes) This works, but the database value then becomes a meaningless number What is the best way to have some kind of enumeration-like values in the Scala code (ie Diesel Petrol) and store something sensible in the DB (ie 'D' and 'P')? /Jeppe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] On OSGi bundle mavens
Looking at the OSGi-enabled Lift poms, I find it curious that the M.O. for building bundles looks like a two-step: 1) Build a bundle with maven-bundle-plugin 2) Dig out the manifest and use it in the jar This works ok, but given my experience with Maven, it seems to be a case of challenging destiny (Norwegian idiom, sorry); I can vividly picture future Mavenisms shuffling the order of plugins somehow, wreaking silent havoc. My preferred approach would be to change the packaging of the pom from jar to bundle. From what I can tell, the plugin simply binds to this packaging type (or something), and does the same job. I tried this to bundle-wrap the Mapper and the Widgets (trying to deploy my app in Felix + Jetty), and it works fine. Should be faster, too. Unless, of course, I'm missing something here? --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Making MetaMegaProtoUser templateable
Well, that probably is good advice, but doesn't really relate to the matter at hand if I understand you correctly. As you may notice, the code is a modified version of the embedded code, but it's completely independent from it (it doesn't override anything). It could have been code that had been written completely by me. And anyways, my goal is to make a snippet out of the edit form, and not to just be able to load a template from a file (I need to put the whole edit form in multiple, obscure places) so your solution, I must say, isn't any help to me. Maybe my original message title was misleading. The issue is that the theUser object isn't preserved between requests. Apart from that, the snippet could've been any other snippet (because it's just being used as a generic mapper; I could've created this form for any structure). Thank you for your effort, anyhow! On Jun 19, 6:21 am, David Pollak feeder.of.the.be...@gmail.com wrote: I'd suggest copying/pasting the code from ProtoUser and MegaProtoUser and munging the code so that you don't have to work around the embedded MegaProtoUser code. Seehttp://svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/sca... I recently made this change to the On Thu, Jun 18, 2009 at 1:51 PM, dflemstr david.flemst...@gmail.com wrote: Hello everyone, I'm having some problems with making the MetaMegaProtoUser edit method templateable (because I believe in the concept of separating content and design) and am succeeding quite well, except for with one little detail: I can't make my changes in the edit form persistent; it seems that the User instance gets lost somewhere in the process and that all the client-side changes therefore also get lost. The code is at the end of the message. The edit method is called with a template which also is at the very end of the message. I would really appreciate if anyone with more Lift experience than me could spot the mistake, because I simply cannot find it. - The snippet (inside a subclass of MetaMegaProtoUser): /** Create an edit form with the specified template */ def edit(xhtml: NodeSeq) = { val theUser: User = currentUser.open_! // we know we're logged in def testEdit() { theUser.validate match { case Nil = theUser.save S.notice(Profile updated) //The Lift Core has a spelling mistake in its translation, so I don't use S.?? S.redirectTo(homePage) case xs = S.error(xs) S.mapSnippet(S.currentSnippet.open_!, innerEdit) } } def innerEdit(t: NodeSeq) = bind(user, t, field - ((h: NodeSeq) = localForm (h, theUser, true)), submit - SHtml.submit(S.??(edit), testEdit _)) innerEdit(xhtml) } /** Make a form with all the editable fields of an user, from a template */ protected def localForm(xhtml: NodeSeq, user: User, ignorePassword: Boolean): NodeSeq = { signupFields .map(fi = getSingleton.getActualBaseField(user, fi)) //get actual fields .filter(f = !ignorePassword || (f match { //remove the password field case f: MappedPassword[_] = false case _ = true })) .flatMap(f = bind(field, xhtml, name - Text(f.displayName), form - f.toForm) ) } - The template: lift:surround with=default at=content lift:User.edit form=POST table tbody user:field tr tdfield:name//td tdfield:form//td /tr /user:field /tbody tfoot tr tdnbsp;/td tduser:submit//td /tr /tfoot /table /lift:User.edit /lift:surround -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: selectObj again
Hi Dave, thanks again! But I can't find any documentation about the selectType method. I looked at the API docs on the website, but in SHtml the selectType method didn't exist!? Even inside the sources from SHtml on github selectType wasn't there Can you tell me how to use and maybe a short code snippet? thanks and sorry for wasting your time... Try: SHtml.selectType[TradeType]() On Thu, Jun 18, 2009 at 6:30 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi There, I'm still having problems with the selectObj method. Here's the code: */* The basic trade types are: BUY and SELL */ object tradeType extends MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){ override def _toForm = Full(SHtml.selectObj (List( (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY)), kaufen), (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, SELL)),verkaufen)), Full(TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))), (t: TradeType) = set(t)) ) }* and here's the compiler error: [INFO] Compiling 1 source files to /home/wacky/workspace_VirtuelleBoerse/virtualMarket/target/classes [WARNING] /home/wacky/workspace_VirtuelleBoerse/virtualMarket/src/main/scala/org/tobster/model/Order.scala:50: error: value set is not a member of Long [WARNING](t: TradeType) = set(t)) [WARNING] ^ [WARNING] one error found What do I've to do, to store the selected object in the corresponding table. thanks -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Help with writing generic functions for lift mapper
I am trying to write a generic function to do a on-to-one join between mapper objects in memory using a map. The function is as follows: def oneToOneJoin[PType : LongKeyedMapper[PType] with IdPK, CType : LongKeyedMapper[CType] with IdPK, CMetaType : CType with LongKeyedMetaMapper [CType], FKType : MappedLongForeignKey[PType, CType]] (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) = FKType ): Map[Long, CType] = { (Map.empty[Long, CType] /: metaMapper.findAll( ByList(metaMapper.id, parents.map {p = keyGetter (p).is.longValue } )) ) {(accum, v) = accum + (v.id.longValue - v) } This function compiles fine, but I can't use it! Here is the call site: Util.oneToOneJoin(runs, TestSubject, (tr: TestRun) = tr.testSubject where runs is of type List[TestRun] Here are the relevant class and object definitions. All the definitions are by the book, meaning the exploring Lift book :). Each test run has one test subject. class TestSubject extends LongKeyedMapper[TestSubject] with IdPK { object TestSubject extends TestSubject with LongKeyedMetaMapper [TestSubject] { class TestRun extends LongKeyedMapper[TestRun] with IdPK { object testSubject extends MappedLongForeignKey(this, TestSubject) } object TestRun extends TestRun with LongKeyedMetaMapper[TestRun] with CRUDify[Long, TestRun] { I get an error that makes me think I'm coding in C++ with the boost library. Scala is inferring CType as Nothing, which is definitely not what I want. error: inferred type arguments [com.test_results.model.TestRun,Nothing,object com.test_results.model.TestSubject,object com.test_results.model.TestRun#testSubject] do not conform to method oneToOneJoin's type parameter bounds [PType : net.liftweb.mapper.LongKeyedMapper[PType] with net.liftweb.mapper.IdPK,CType : net.liftweb.mapper.LongKeyedMapper [CType] with net.liftweb.mapper.IdPK,CMetaType : CType with net.liftweb.mapper.LongKeyedMetaMapper[CType],FKType : net.liftweb.mapper.MappedLongForeignKey[PType,CType]] Util.oneToOneJoin(runs, TestSubject, (tr: TestRun) = tr.testSubject) I cannot find any way to get the class of the TestSubject companion object, So I changed things slightly to create a MetaTestSubject and then tried to explicitly specify the type parameters to the oneToOneJoin function as shown below. MetaTestSubject is the supertype for the TestSubject companion object so that I can reference it's type explicitly. Util.oneToOneJoin[TestRun, TestSubject, MetaTestSubject, (TestRun) = MappedLongForeignKey[TestRun, TestSubject] ](runs, TestSubject, (tr: TestRun) = tr.testSubject) where MetaTestSubject and TestSubject are now defined as class MetaTestSubject extends TestSubject with LongKeyedMetaMapper [TestSubject] object TestSubject extends MetaTestSubject { When I specify the types to the oneToOneJoin function explicitly, Scala then just plain tells me that the types don't match with this error. error: type arguments [com.test_results.model.TestRun,com.test_results.model.TestSubject,com.test_results.model.MetaTestSubject, (com.test_results.model.TestRun) = net.liftweb.mapper.MappedLongForeignKey [com.test_results.model.TestRun,com.test_results.model.TestSubject]] do not conform to method oneToOneJoin's type parameter bounds [PType : net.liftweb.mapper.LongKeyedMapper[PType] with net.liftweb.mapper.IdPK,CType : net.liftweb.mapper.LongKeyedMapper [CType] with net.liftweb.mapper.IdPK,CMetaType : CType with net.liftweb.mapper.LongKeyedMetaMapper[CType],FKType : net.liftweb.mapper.MappedLongForeignKey[PType,CType]] Util.oneToOneJoin[TestRun, After a couple of hours of trying I am stuck at this point and all of the types look like they line up to me. TestRun is a LongKeyedMapper of the right type with IdPK, and so is TestSubject. MetaTestSubject inherits from TestSubject with LongKeyedMetaMapper[TestSubject]. The third value parameter is a function takes a type TestRun and returns a MappedLongForeignKey[TestRun, TestSubject]. What am I doing wrong? Is this a scala bug? - Sean Reque --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: is there a name for this pattern?
Eric, I believe that something like that, in C++ at least, is referred to as the curiously recurring template pattern. Jeremy On Fri, Jun 19, 2009 at 1:18 AM, Eric Bowman ebow...@boboco.ie wrote: The basic trick where a superclass has its subclass as a type parameter, e.g. class User extends MegaProtoUser[User] I've run into this before, I remember struggling to get it, then getting it, but I can't recall the epiphany. But obviously this is a relatively common technique, so something to google is much appreciated. Thanks, Eric -- Eric Bowman Boboco Ltd ebow...@boboco.ie http://www.boboco.ie/ebowman/pubkey.pgp +35318394189/+353872801532http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: is there a name for this pattern?
On Thu, Jun 18, 2009 at 11:18 PM, Eric Bowman ebow...@boboco.ie wrote: The basic trick where a superclass has its subclass as a type parameter, e.g. class User extends MegaProtoUser[User] The circular dependent type that gives Martin and the compiler fits? :-) I've run into this before, I remember struggling to get it, then getting it, but I can't recall the epiphany. But obviously this is a relatively common technique, so something to google is much appreciated. Thanks, Eric -- Eric Bowman Boboco Ltd ebow...@boboco.ie http://www.boboco.ie/ebowman/pubkey.pgp +35318394189/+353872801532http://www.boboco.ie/ebowman/pubkey.pgp%0A+35318394189/+353872801532 -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: is there a name for this pattern?
I've always called this recursive type parameterization. It's useful when the base class needs to know the type that it's eventually instantiated as, usually so that it can provide implementations of methods where dispatch is based upon the instantiated type. I've found myself using the pattern mostly in cases where I wanted to have parallel class hierarchies, say of model objects and rendering strategies for those models. In this case, the model base class would have a recursive type parameter, and the rendering strategy would be parameterized with respect to the model type. ex: class Model[T : Model[T]] { self: T = def render(r: Renderer[T]) { r.render(this) } } class ConcreteModel extends Model[ConcreteModel] class Renderer[T : Model[T]] { abstract def render(model: T) } class ConcreteModelRenderer extends Renderer[ConcreteModel] { def render(model: ConcreteModel) { ... } } In Java, you have a little more boilerplate because you don't have an explicit self-type, so you have to define an abstract method self: T which you implement trivially in each subclass. Recursive self-types can be really useful but they're definitely a double-edged sword because they're sort of viral; you have to add a bunch of boilerplate type information everywhere that you refer to the base type, and if you ever discard the more specific type information (in the example above, say by putting a bunch of different subclasses of Model into a List[Model[_]]) then you can never get it back without reflection, and any use of the members of that list in a contravariant position (say as an argument to another method call) becomes impossible. Kris On Fri, Jun 19, 2009 at 12:18 AM, Eric Bowmanebow...@boboco.ie wrote: The basic trick where a superclass has its subclass as a type parameter, e.g. class User extends MegaProtoUser[User] I've run into this before, I remember struggling to get it, then getting it, but I can't recall the epiphany. But obviously this is a relatively common technique, so something to google is much appreciated. Thanks, Eric -- Eric Bowman Boboco Ltd ebow...@boboco.ie http://www.boboco.ie/ebowman/pubkey.pgp +35318394189/+353872801532 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Error reporting and early failure in lift ?
On Fri, Jun 19, 2009 at 3:26 AM, marius d. marius.dan...@gmail.com wrote: Francois, That is a very valid point and there is significant attention in lift development to improve error reporting. In fact David made some really significant steps in this area in 1.1-SNAPSHOT so that if an unexpected error occurs in development mode there is a helpful message rendered on the page. But sure lots of things can and will be done to improve this. ++1!! As you find places where better error reporting would help you as a developer, please open a ticket at http://github.com/dpp/liftweb/issues Just wanted to say that we're fully aware of the situation. Br's, Marius On Jun 19, 1:15 pm, fan...@gmail.com fan...@gmail.com wrote: Hello guys, I'm really new to lift application development, even if I try to follow the framework evolution almost since it's start. I'm coming from Tapestry 5 world, and so, I'm just discovering basic Lift features. For now, I can say that there is really cool things here, things that Scala make so simple, things in the AJAX land... But one of the things I really liked in T5 and miss a lot with in first days of Lift is T5 awesome error reporting and early failure behaviour. You know, for now I'm playing with little examples, trying to modify the Pocket Change App of Lift book, this kind of things. And I have to say that a lot of my try are not successful. In T5, when something goes wrong, T5 takes me by the hand, show me the piece of template where the error happens, the faulty code, and give me advices on how to correct the problem. Moreover, T5 default behaviour is to fail early, so that less bad code is waiting for users to discover it - developers get big exceptions that they can't honestly ignore. There is (an really old) example of T5 error reporting here: http://tapestryjava.blogspot.com/2007/09/itch-scratching-even-better-... Now, the report is even better than that, especially when compond components are involved. There is an other example of enhanced error reporting, this time in the console: http://tapestryjava.blogspot.com/2008/12/exception-reporting-why.html So, what the goal of the mail ? Well, just to bring the attention of core team on how it's important and great to have good feedback from the framework (error reporting, early failure) and I do believe that T5 is state of the art in that domain... So if you look for inspiration, it might be the good place to look at. When I will be (if I become) more versatile in Lift, perhaps I would be able to help improve in this domain, but for now, it's clearly out of my reach :) -- Francois Armandhttp://fanf42.blogspot.com -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: is there a name for this pattern?
This is also a common technique in C# too. Unfortunately, I'm not sure of the pattern's name either. I usually just google for non-generic inheritance from generic class On Fri, Jun 19, 2009 at 10:31 AM, Jeremy Dayjeremy@gmail.com wrote: Eric, I believe that something like that, in C++ at least, is referred to as the curiously recurring template pattern. Jeremy On Fri, Jun 19, 2009 at 1:18 AM, Eric Bowman ebow...@boboco.ie wrote: The basic trick where a superclass has its subclass as a type parameter, e.g. class User extends MegaProtoUser[User] I've run into this before, I remember struggling to get it, then getting it, but I can't recall the epiphany. But obviously this is a relatively common technique, so something to google is much appreciated. Thanks, Eric -- Eric Bowman Boboco Ltd ebow...@boboco.ie http://www.boboco.ie/ebowman/pubkey.pgp +35318394189/+353872801532 --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: YA menu question: separate menus
OK, I've committed some new support for groups in the MenuWidget class. Also, the existing MenuWidget had facilities set up to take a SiteMap instance as part of the setup params, but those params were never used. In the interest of simplicity, I've removed those extra params unless someone has a use case that's not covered by groups or the other new functionality. If no one has any issues with the new code I'll merge to master later today. Derek On Fri, Jun 12, 2009 at 1:02 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: Tied up with work this afternoon, but I'll look at reworking MenuWidget with the added functionality. On Fri, Jun 12, 2009 at 6:40 AM, glenn gl...@exmbly.com wrote: Derek, Your new Menu snippet works great. I created a superfish-style menu using a list of groups, like so: object MenuWidgetEx { def apply(groups:List[String]) = new MenuWidgetEx(groups, MenuStyle.HORIZONTAL, JsObj()) render def apply(groups:List[String], style: MenuStyle.Value) = new MenuWidgetEx(groups, style, JsObj()) render def apply(groups:List[String], jsObj: JsObj) = new MenuWidgetEx (groups, MenuStyle.HORIZONTAL, jsObj) render def apply(groups:List[String], style: MenuStyle.Value, jsObj: JsObj) = new MenuWidgetEx(groups, style, jsObj) render } class MenuWidgetEx(groups:List[String], style: MenuStyle.Value, jsObj: JsObj) extends MenuWidget(LiftRules.siteMap open_!, style: MenuStyle.Value, jsObj: JsObj){ override def render :NodeSeq = { def buildMenu(group:String) = lift:Menu.builder group={group} expandAll=true top:class={style.toString} / head ++ div {for(group - groups) yield {buildMenu(group)}} /div } Someone should redo the MenuWidget snippet to handle your new Menu.builder construct, so it doesn't have to be subclassed. Glenn... On Jun 12, 4:59 am, glenn gl...@exmbly.com wrote: My error. Ignore this. I did a mvn clean then mvn install outside of Eclipse on the parent pom and everything worked fine. Glenn... On Jun 12, 4:45 am, glenn gl...@exmbly.com wrote: Derek, I'd love to test the changes you made to Menu, but my build fails when I run mvn install on the pom in the lift directory of the download from http://github.com/dpp/liftweb/tree/wip-dcb-menu-addons Here's what maven reports: [WARNING] Warning in manifest for net.liftweb:lift-webkit:jar:1.1- SNAPSHOT : Did not find matching r eferal for org.slf4j.* [ERROR] Error in manifest for net.liftweb:lift-webkit:jar:1.1- SNAPSHOT : The default package '.' is not permitted by the Import-Package syntax. This can be caused by compile errors in Eclipse because Eclipse creates valid class files regardless of compile errors. The following package(s) import from the default package [net.liftweb.http, net.liftweb.http.auth, n et.liftweb.http.js, net.liftweb.http.js.jquery, net.liftweb.sitemap] [ERROR] Error(s) found in manifest configuration [INFO] [ERROR] BUILD ERROR [INFO] [INFO] Error(s) found in manifest configuration It seems like a problem with the construction of the following plugin in the pom. plugin groupIdorg.apache.felix/groupId artifactIdmaven-bundle-plugin/artifactId configuration instructions Export-Package! net.liftweb.util.*,net.liftweb.*;version=${pom.version}/Export- Package Import-Packageorg.slf4j.*;resolution:=optional,*/ Import-Package DynamicImport-Package*/DynamicImport-Package /instructions /configuration /plugin Either that, or there's something else going on. Any ideas? Glenn... On Jun 11, 11:54 am, Derek Chen-Becker dchenbec...@gmail.com wrote: I'm building some code right now that I think should handle all of your cases. Since Menu.builder is already concerned with building a menu tree, I decided that it would be better to allow you to specify a specific item or group to Menu.builder instead of conflating tree building with the current Menu.item and Menu.group snippets. Given a SiteMap like: val menus = Menu(Loc(Home, List(index), Home Page)) :: Menu(Loc(Viewtest, List(ViewTest, test), View test)) :: Menu(Loc(InsecureViewtest, List(Insecure, test), Insecure View test)) :: Menu(Loc(SelectTest, List(select), asm select test)) :: Menu(Loc(Help, List(help, index), Help, LocGroup(help)), Menu(Loc(About, List(help, about), About, LocGroup(help))), Menu(Loc(Version, List(help, version), Version, LocGroup(help :: Nil You can render just the Help tree with: lift:Menu.builder item=Help expandAll=true /
[Lift] Re: Error reporting and early failure in lift ?
I second that. Please, please open tickets if you think that there's something that could use improvement, if documentation is unclear, etc. Worst case we close them as wontfix, although I think that that will be quite rare. Currently I'm using a lot of tags in gmail to try and track issues that people have brought up but then that's only visible to me. Derek On Fri, Jun 19, 2009 at 9:16 AM, David Pollak feeder.of.the.be...@gmail.com wrote: On Fri, Jun 19, 2009 at 3:26 AM, marius d. marius.dan...@gmail.comwrote: Francois, That is a very valid point and there is significant attention in lift development to improve error reporting. In fact David made some really significant steps in this area in 1.1-SNAPSHOT so that if an unexpected error occurs in development mode there is a helpful message rendered on the page. But sure lots of things can and will be done to improve this. ++1!! As you find places where better error reporting would help you as a developer, please open a ticket at http://github.com/dpp/liftweb/issues Just wanted to say that we're fully aware of the situation. Br's, Marius On Jun 19, 1:15 pm, fan...@gmail.com fan...@gmail.com wrote: Hello guys, I'm really new to lift application development, even if I try to follow the framework evolution almost since it's start. I'm coming from Tapestry 5 world, and so, I'm just discovering basic Lift features. For now, I can say that there is really cool things here, things that Scala make so simple, things in the AJAX land... But one of the things I really liked in T5 and miss a lot with in first days of Lift is T5 awesome error reporting and early failure behaviour. You know, for now I'm playing with little examples, trying to modify the Pocket Change App of Lift book, this kind of things. And I have to say that a lot of my try are not successful. In T5, when something goes wrong, T5 takes me by the hand, show me the piece of template where the error happens, the faulty code, and give me advices on how to correct the problem. Moreover, T5 default behaviour is to fail early, so that less bad code is waiting for users to discover it - developers get big exceptions that they can't honestly ignore. There is (an really old) example of T5 error reporting here: http://tapestryjava.blogspot.com/2007/09/itch-scratching-even-better-... Now, the report is even better than that, especially when compond components are involved. There is an other example of enhanced error reporting, this time in the console: http://tapestryjava.blogspot.com/2008/12/exception-reporting-why.html So, what the goal of the mail ? Well, just to bring the attention of core team on how it's important and great to have good feedback from the framework (error reporting, early failure) and I do believe that T5 is state of the art in that domain... So if you look for inspiration, it might be the good place to look at. When I will be (if I become) more versatile in Lift, perhaps I would be able to help improve in this domain, but for now, it's clearly out of my reach :) -- Francois Armandhttp://fanf42.blogspot.com -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Help with writing generic functions for lift mapper
On Fri, Jun 19, 2009 at 6:35 AM, Sean Reque seanre...@gmail.com wrote: I am trying to write a generic function to do a on-to-one join between mapper objects in memory using a map. The function is as follows: def oneToOneJoin[PType : LongKeyedMapper[PType] with IdPK, CType : LongKeyedMapper[CType] with IdPK, CMetaType : CType with LongKeyedMetaMapper [CType], FKType : MappedLongForeignKey[PType, CType]] (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) = FKType ): Map[Long, CType] = { (Map.empty[Long, CType] /: metaMapper.findAll( ByList(metaMapper.id, parents.map {p = keyGetter (p).is.longValue } )) ) {(accum, v) = accum + (v.id.longValue - v) } This function compiles fine, but I can't use it! Here is the call site: Util.oneToOneJoin(runs, TestSubject, (tr: TestRun) = tr.testSubject where runs is of type List[TestRun] Here are the relevant class and object definitions. All the definitions are by the book, meaning the exploring Lift book :). Each test run has one test subject. class TestSubject extends LongKeyedMapper[TestSubject] with IdPK { object TestSubject extends TestSubject with LongKeyedMetaMapper [TestSubject] { class TestRun extends LongKeyedMapper[TestRun] with IdPK { object testSubject extends MappedLongForeignKey(this, TestSubject) } object TestRun extends TestRun with LongKeyedMetaMapper[TestRun] with CRUDify[Long, TestRun] { I get an error that makes me think I'm coding in C++ with the boost library. Scala is inferring CType as Nothing, which is definitely not what I want. error: inferred type arguments [com.test_results.model.TestRun,Nothing,object com.test_results.model.TestSubject,object com.test_results.model.TestRun#testSubject] do not conform to method oneToOneJoin's type parameter bounds [PType : net.liftweb.mapper.LongKeyedMapper[PType] with net.liftweb.mapper.IdPK,CType : net.liftweb.mapper.LongKeyedMapper [CType] with net.liftweb.mapper.IdPK,CMetaType : CType with net.liftweb.mapper.LongKeyedMetaMapper[CType],FKType : net.liftweb.mapper.MappedLongForeignKey[PType,CType]] Util.oneToOneJoin(runs, TestSubject, (tr: TestRun) = tr.testSubject) I cannot find any way to get the class of the TestSubject companion object, So I changed things slightly to create a MetaTestSubject and then tried to explicitly specify the type parameters to the oneToOneJoin function as shown below. MetaTestSubject is the supertype for the TestSubject companion object so that I can reference it's type explicitly. Util.oneToOneJoin[TestRun, TestSubject, MetaTestSubject, (TestRun) = MappedLongForeignKey[TestRun, TestSubject] ](runs, TestSubject, (tr: TestRun) = tr.testSubject) where MetaTestSubject and TestSubject are now defined as class MetaTestSubject extends TestSubject with LongKeyedMetaMapper [TestSubject] object TestSubject extends MetaTestSubject { When I specify the types to the oneToOneJoin function explicitly, Scala then just plain tells me that the types don't match with this error. error: type arguments [com.test_results.model.TestRun,com.test_results.model.TestSubject,com.test_results.model.MetaTestSubject, (com.test_results.model.TestRun) = net.liftweb.mapper.MappedLongForeignKey [com.test_results.model.TestRun,com.test_results.model.TestSubject]] do not conform to method oneToOneJoin's type parameter bounds [PType : net.liftweb.mapper.LongKeyedMapper[PType] with net.liftweb.mapper.IdPK,CType : net.liftweb.mapper.LongKeyedMapper [CType] with net.liftweb.mapper.IdPK,CMetaType : CType with net.liftweb.mapper.LongKeyedMetaMapper[CType],FKType : net.liftweb.mapper.MappedLongForeignKey[PType,CType]] Util.oneToOneJoin[TestRun, After a couple of hours of trying I am stuck at this point and all of the types look like they line up to me. TestRun is a LongKeyedMapper of the right type with IdPK, and so is TestSubject. MetaTestSubject inherits from TestSubject with LongKeyedMetaMapper[TestSubject]. The third value parameter is a function takes a type TestRun and returns a MappedLongForeignKey[TestRun, TestSubject]. What am I doing wrong? In the second one where you explicitly specified the types, you are doing nothing wrong. In the first case, because there were no parameters with the type CType, the type inferencer couldn't figure out what CType was. The type inferencer only looks a certain number of levels for a type in order to avoid cyclical type references and in order to save compilation speed. Is this a scala bug? Yes. I would suggest reporting it. - Sean Reque -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~
[Lift] Re: Best way to create enum-like custom field mapping
MappedEnum is based on an Int value for the enum (MappedEnum.targetSQLType is Int), so there's no way to do it with MappedEnum. It should be possible to write a MappedStringEnum that would map to a String, but I think it would be better if there were some way to make MappedEnum more generic. Derek On Fri, Jun 19, 2009 at 7:33 AM, Jeppe Nejsum Madsen je...@ingolfs.dkwrote: Hi, Using mapper I have this: object FuelTypes extends Enumeration { val Diesel = new Val(1, Diesel) val Petrol = new Val(2, Benzin) } object fuelType extends MappedEnum(this, FuelTypes) This works, but the database value then becomes a meaningless number What is the best way to have some kind of enumeration-like values in the Scala code (ie Diesel Petrol) and store something sensible in the DB (ie 'D' and 'P')? /Jeppe --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Making MetaMegaProtoUser templateable
On Fri, Jun 19, 2009 at 3:25 AM, dflemstr david.flemst...@gmail.com wrote: Well, that probably is good advice, but doesn't really relate to the matter at hand if I understand you correctly. As you may notice, the code is a modified version of the embedded code, but it's completely independent from it (it doesn't override anything). It could have been code that had been written completely by me. And anyways, my goal is to make a snippet out of the edit form, and not to just be able to load a template from a file (I need to put the whole edit form in multiple, obscure places) so your solution, I must say, isn't any help to me. Maybe my original message title was misleading. I am totally confused as to what your goal is? Is it to put the form into a template file (a .html) file? Is it to control the rendering of the form elements? Is it something else? In terms of ProtoUser, that class is meant as a quick bootstrap to getting your project going. It lends itself nicely to adding fields. Any styling needs to be done via CSS. If you need something more complex (like ESME does), you can pull the code into your User class and then work to achieve the particular goal. If we can cycle a bit on what your particular goal is, I'm sure we can get you there. The issue is that the theUser object isn't preserved between requests. Apart from that, the snippet could've been any other snippet (because it's just being used as a generic mapper; I could've created this form for any structure). Thank you for your effort, anyhow! On Jun 19, 6:21 am, David Pollak feeder.of.the.be...@gmail.com wrote: I'd suggest copying/pasting the code from ProtoUser and MegaProtoUser and munging the code so that you don't have to work around the embedded MegaProtoUser code. Seehttp:// svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/sca... I recently made this change to the On Thu, Jun 18, 2009 at 1:51 PM, dflemstr david.flemst...@gmail.com wrote: Hello everyone, I'm having some problems with making the MetaMegaProtoUser edit method templateable (because I believe in the concept of separating content and design) and am succeeding quite well, except for with one little detail: I can't make my changes in the edit form persistent; it seems that the User instance gets lost somewhere in the process and that all the client-side changes therefore also get lost. The code is at the end of the message. The edit method is called with a template which also is at the very end of the message. I would really appreciate if anyone with more Lift experience than me could spot the mistake, because I simply cannot find it. - The snippet (inside a subclass of MetaMegaProtoUser): /** Create an edit form with the specified template */ def edit(xhtml: NodeSeq) = { val theUser: User = currentUser.open_! // we know we're logged in def testEdit() { theUser.validate match { case Nil = theUser.save S.notice(Profile updated) //The Lift Core has a spelling mistake in its translation, so I don't use S.?? S.redirectTo(homePage) case xs = S.error(xs) S.mapSnippet(S.currentSnippet.open_!, innerEdit) } } def innerEdit(t: NodeSeq) = bind(user, t, field - ((h: NodeSeq) = localForm (h, theUser, true)), submit - SHtml.submit(S.??(edit), testEdit _)) innerEdit(xhtml) } /** Make a form with all the editable fields of an user, from a template */ protected def localForm(xhtml: NodeSeq, user: User, ignorePassword: Boolean): NodeSeq = { signupFields .map(fi = getSingleton.getActualBaseField(user, fi)) //get actual fields .filter(f = !ignorePassword || (f match { //remove the password field case f: MappedPassword[_] = false case _ = true })) .flatMap(f = bind(field, xhtml, name - Text(f.displayName), form - f.toForm) ) } - The template: lift:surround with=default at=content lift:User.edit form=POST table tbody user:field tr tdfield:name//td tdfield:form//td /tr /user:field /tbody tfoot tr tdnbsp;/td tduser:submit//td /tr /tfoot /table /lift:User.edit /lift:surround -- Lift, the simply functional web frameworkhttp://liftweb.net
[Lift] Re: Help with writing generic functions for lift mapper
Thanks for the quick response! I will submit a ticket in the scala bug tracker. On Jun 19, 10:14 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Fri, Jun 19, 2009 at 6:35 AM, Sean Reque seanre...@gmail.com wrote: I am trying to write a generic function to do a on-to-one join between mapper objects in memory using a map. The function is as follows: def oneToOneJoin[PType : LongKeyedMapper[PType] with IdPK, CType : LongKeyedMapper[CType] with IdPK, CMetaType : CType with LongKeyedMetaMapper [CType], FKType : MappedLongForeignKey[PType, CType]] (parents: List[PType], metaMapper: CMetaType, keyGetter: (PType) = FKType ): Map[Long, CType] = { (Map.empty[Long, CType] /: metaMapper.findAll( ByList(metaMapper.id, parents.map {p = keyGetter (p).is.longValue } )) ) {(accum, v) = accum + (v.id.longValue - v) } This function compiles fine, but I can't use it! Here is the call site: Util.oneToOneJoin(runs, TestSubject, (tr: TestRun) = tr.testSubject where runs is of type List[TestRun] Here are the relevant class and object definitions. All the definitions are by the book, meaning the exploring Lift book :). Each test run has one test subject. class TestSubject extends LongKeyedMapper[TestSubject] with IdPK { object TestSubject extends TestSubject with LongKeyedMetaMapper [TestSubject] { class TestRun extends LongKeyedMapper[TestRun] with IdPK { object testSubject extends MappedLongForeignKey(this, TestSubject) } object TestRun extends TestRun with LongKeyedMetaMapper[TestRun] with CRUDify[Long, TestRun] { I get an error that makes me think I'm coding in C++ with the boost library. Scala is inferring CType as Nothing, which is definitely not what I want. error: inferred type arguments [com.test_results.model.TestRun,Nothing,object com.test_results.model.TestSubject,object com.test_results.model.TestRun#testSubject] do not conform to method oneToOneJoin's type parameter bounds [PType : net.liftweb.mapper.LongKeyedMapper[PType] with net.liftweb.mapper.IdPK,CType : net.liftweb.mapper.LongKeyedMapper [CType] with net.liftweb.mapper.IdPK,CMetaType : CType with net.liftweb.mapper.LongKeyedMetaMapper[CType],FKType : net.liftweb.mapper.MappedLongForeignKey[PType,CType]] Util.oneToOneJoin(runs, TestSubject, (tr: TestRun) = tr.testSubject) I cannot find any way to get the class of the TestSubject companion object, So I changed things slightly to create a MetaTestSubject and then tried to explicitly specify the type parameters to the oneToOneJoin function as shown below. MetaTestSubject is the supertype for the TestSubject companion object so that I can reference it's type explicitly. Util.oneToOneJoin[TestRun, TestSubject, MetaTestSubject, (TestRun) = MappedLongForeignKey[TestRun, TestSubject] ](runs, TestSubject, (tr: TestRun) = tr.testSubject) where MetaTestSubject and TestSubject are now defined as class MetaTestSubject extends TestSubject with LongKeyedMetaMapper [TestSubject] object TestSubject extends MetaTestSubject { When I specify the types to the oneToOneJoin function explicitly, Scala then just plain tells me that the types don't match with this error. error: type arguments [com.test_results.model.TestRun,com.test_results.model.TestSubject,com.test_results.model.MetaTestSubject, (com.test_results.model.TestRun) = net.liftweb.mapper.MappedLongForeignKey [com.test_results.model.TestRun,com.test_results.model.TestSubject]] do not conform to method oneToOneJoin's type parameter bounds [PType : net.liftweb.mapper.LongKeyedMapper[PType] with net.liftweb.mapper.IdPK,CType : net.liftweb.mapper.LongKeyedMapper [CType] with net.liftweb.mapper.IdPK,CMetaType : CType with net.liftweb.mapper.LongKeyedMetaMapper[CType],FKType : net.liftweb.mapper.MappedLongForeignKey[PType,CType]] Util.oneToOneJoin[TestRun, After a couple of hours of trying I am stuck at this point and all of the types look like they line up to me. TestRun is a LongKeyedMapper of the right type with IdPK, and so is TestSubject. MetaTestSubject inherits from TestSubject with LongKeyedMetaMapper[TestSubject]. The third value parameter is a function takes a type TestRun and returns a MappedLongForeignKey[TestRun, TestSubject]. What am I doing wrong? In the second one where you explicitly specified the types, you are doing nothing wrong. In the first case, because there were no parameters with the type CType, the type inferencer couldn't figure out what CType was. The type inferencer only looks a certain number of levels for a type in order to avoid cyclical type references and in order to save compilation speed. Is this a scala bug? Yes. I would suggest reporting it. - Sean Reque -- Lift,
[Lift] Re: Error reporting and early failure in lift ?
Derek Chen-Becker a écrit : I second that. Please, please open tickets if you think that there's something that could use improvement, if documentation is unclear, etc. Worst case we close them as wontfix, although I think that that will be quite rare. Currently I'm using a lot of tags in gmail to try and track issues that people have brought up but then that's only visible to me. I will open ticket, if I find some specific spot. That was just a global felling, without real precise argument. So when I will have something more useful, I'm going to open tickets, don't fear I won't ;) Thanks for the answers ! -- Francois Armand http://fanf42.blogspot.com --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: selectObj again
Thanks Dave! I modified the code a little bit: object tradeType extends MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){ override def _toForm = Full(SHtml.selectObj[TradeType] (List( (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))(0), kaufen), (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, SELL))(0), verkaufen)), Full(TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))(0)), (t: TradeType) = set(t)) ) } But I still get the same compiler error! Seems like I've to use some other method instead of set()? I discovered the set() method in one of the tutorials/Lift Book any ideas? thanks On Fri, Jun 19, 2009 at 6:10 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi Dave, thanks again! But I can't find any documentation about the selectType method. I looked at the API docs on the website, but in SHtml the selectType method didn't exist!? Even inside the sources from SHtml on github selectType wasn't there Can you tell me how to use and maybe a short code snippet? Sorry... I typed this when I was wicked tired and my brain fired wrong. :-( SHtml.selectObj[TradeType](...) You have to give the compiler a hint about the type of the list. thanks and sorry for wasting your time... Try: SHtml.selectType[TradeType]() On Thu, Jun 18, 2009 at 6:30 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi There, I'm still having problems with the selectObj method. Here's the code: */* The basic trade types are: BUY and SELL */ object tradeType extends MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){ override def _toForm = Full(SHtml.selectObj (List( (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY)), kaufen), (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, SELL)),verkaufen)), Full(TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))), (t: TradeType) = set(t)) ) }* and here's the compiler error: [INFO] Compiling 1 source files to /home/wacky/workspace_VirtuelleBoerse/virtualMarket/target/classes [WARNING] /home/wacky/workspace_VirtuelleBoerse/virtualMarket/src/main/scala/org/tobster/model/Order.scala:50: error: value set is not a member of Long [WARNING](t: TradeType) = set(t)) [WARNING] ^ [WARNING] one error found What do I've to do, to store the selected object in the corresponding table. thanks -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: Making MetaMegaProtoUser templateable
Well, OK, I'm sorry everyone, I should have been more clear: The goal that I have is to make a snippet that creates a templated edit form for me. However, this is not the issue which I want to discuss. The issue is that when I try to make this snippet (and this could have been any snippet, since the principles are the same), I am unable to, because somewhere the instance of the Mapper for which I want to create the snippet (in this case it's a MetaMegaProtoUser) gets lost, and thus no changes are preserved. The reason why I mentioned the templating in the first place is because I basically use exactly the same code as in the default MetaMegaProtoUser.edit method, just adding some bind calls and an extra parameter: the template NodeSeq, and suddenly the code breaks. As mentioned before, any changes I make in the client aren't saved. I have no good way of checking whether the changes even are contained within the POST(→it's the localForm's fault) or if the User instance gets lost earlier (→it's some closure that fails somewhere), but the testEdit function gets called for sure, but with the wrong user instance. Hopefully I've made my problem more clear. On Jun 19, 6:19 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Fri, Jun 19, 2009 at 3:25 AM, dflemstr david.flemst...@gmail.com wrote: Well, that probably is good advice, but doesn't really relate to the matter at hand if I understand you correctly. As you may notice, the code is a modified version of the embedded code, but it's completely independent from it (it doesn't override anything). It could have been code that had been written completely by me. And anyways, my goal is to make a snippet out of the edit form, and not to just be able to load a template from a file (I need to put the whole edit form in multiple, obscure places) so your solution, I must say, isn't any help to me. Maybe my original message title was misleading. I am totally confused as to what your goal is? Is it to put the form into a template file (a .html) file? Is it to control the rendering of the form elements? Is it something else? In terms of ProtoUser, that class is meant as a quick bootstrap to getting your project going. It lends itself nicely to adding fields. Any styling needs to be done via CSS. If you need something more complex (like ESME does), you can pull the code into your User class and then work to achieve the particular goal. If we can cycle a bit on what your particular goal is, I'm sure we can get you there. The issue is that the theUser object isn't preserved between requests. Apart from that, the snippet could've been any other snippet (because it's just being used as a generic mapper; I could've created this form for any structure). Thank you for your effort, anyhow! On Jun 19, 6:21 am, David Pollak feeder.of.the.be...@gmail.com wrote: I'd suggest copying/pasting the code from ProtoUser and MegaProtoUser and munging the code so that you don't have to work around the embedded MegaProtoUser code. Seehttp:// svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/sca... I recently made this change to the On Thu, Jun 18, 2009 at 1:51 PM, dflemstr david.flemst...@gmail.com wrote: Hello everyone, I'm having some problems with making the MetaMegaProtoUser edit method templateable (because I believe in the concept of separating content and design) and am succeeding quite well, except for with one little detail: I can't make my changes in the edit form persistent; it seems that the User instance gets lost somewhere in the process and that all the client-side changes therefore also get lost. The code is at the end of the message. The edit method is called with a template which also is at the very end of the message. I would really appreciate if anyone with more Lift experience than me could spot the mistake, because I simply cannot find it. - The snippet (inside a subclass of MetaMegaProtoUser): /** Create an edit form with the specified template */ def edit(xhtml: NodeSeq) = { val theUser: User = currentUser.open_! // we know we're logged in def testEdit() { theUser.validate match { case Nil = theUser.save S.notice(Profile updated) //The Lift Core has a spelling mistake in its translation, so I don't use S.?? S.redirectTo(homePage) case xs = S.error(xs) S.mapSnippet(S.currentSnippet.open_!, innerEdit) } } def innerEdit(t: NodeSeq) = bind(user, t, field - ((h: NodeSeq) = localForm (h, theUser, true)), submit - SHtml.submit(S.??(edit), testEdit _)) innerEdit(xhtml) } /** Make a form
[Lift] Re: Properties Files and Databases
Thanks, David, that works perfectly. Just for clarification, is the XML format of Java properties files not supported in Lift? Peter On Jun 18, 9:15 pm, David Pollak feeder.of.the.be...@gmail.com wrote: If your username is peter, put a file in src/main/resources/props named peter.props In that file, place the following lines: db.driver=*the_name_name_of_your_driver* db.url=*the_url_to_access_your_database* db.user=*the_username* db.password=*the_db_password* test.me=true ** ** Add the following line to Boot.scala: println(Props.get(test.me) When you run your app Full(true) should appear on the console and the correct db settings should be picked up. Thanks, David ** On Thu, Jun 18, 2009 at 3:49 PM, Peter Robinett pe...@bubblefoundry.comwrote: Hi all, I'm looking to switch a basic Lift install to use MySQL. I see that this has been addressed on the wiki (http://wiki.liftweb.net/index.php/ HowTo_configure_lift_with_MySQL), though it involves hardcoding the connection details in Boot.scala. I'd like something easier to deploy to various machines. The thread following Jörn's announcement of the wiki page on MySQL is useful (http://groups.google.com/group/liftweb/browse_thread/thread/ bd4e74b68e8aa2a9/9eb2c2ef39442d63) but none of them mention using properties files, which I understand from this mailing list (e.g. http://groups.google.com/group/liftweb/browse_thread/thread/49eb17b5d... ) is the best way store database settings. So, I created src/main/resources/props/peter.db.xml: ?xml version=1.0 encoding=UTF-8? !DOCTYPE properties SYSTEM http://java.sun.com/dtd/properties.dtd; properties comment/comment entry key=db.drivercom.mysql.jdbc.Driver/entry entry key=db.urljdbc:mysql://localhost/mydb/entry entry key=db.usermyusername/entry entry key=db.passwordmypassword/entry /properties Unfortunately, the property file does appear to be loaded, as the DBVendor code in Boot.scala generated by the lift-archetype-basic archetype falls back to its derby defaults. Do you have any idea what I'm doing wrong? Not having any experience with Java, I wouldn't be surprised if it's something as simple as getting the properties XML wrong... Thanks for your help! Peter -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: is there a name for this pattern?
On Thursday June 18 2009, Eric Bowman wrote: The basic trick where a superclass has its subclass as a type parameter, e.g. class User extends MegaProtoUser[User] I've run into this before, I remember struggling to get it, then getting it, but I can't recall the epiphany. But obviously this is a relatively common technique, so something to google is much appreciated. The example I find helps the most to make this comprehensible is Ordered (generically, not necessarily Scala's actual Ordered class): What does it mean for something to be able to be ordered? It means that if you give me two instances of such a thing, I can tell you whether they stand in a particular order (which may be numeric but need not be; other examples include lexicographic ordering or something defined on a metric space like edit distance). No breathtaking insight there. So naturally when I want to capture orderability generically, I have to say that it establishes a relationship with other things of the same (or compatible / conformant) type. Thus: class Ordered[WithRespectToWhat] Now, to define a class that conforms to Ordered, we have to specify ordered with respect to what? And the usual answer is with respect to the same type: class Numeric extends Ordered[Numeric] You might reasonably want that to be covariant: class Ordered[+WithRespectToWhat] But by cheating (me cheating in writing this up, that is) we find in the ScalaDocs this note on the page for Ordered [1]: Note that since version 2006-07-24 this trait is no longer covariant in a. It is important that the equals method for an instance of Ordered[A] be consistent with the compare method. However, due to limitations inherent in the type erasure semantics, there is no reasonable way to provide a default implementation of equality for instances of Ordered[A]. Therefore, if you need to be able to use equality on an instance of Ordered[A] you must provide it yourself either when inheiriting or instantiating. [1] http://www.scala-lang.org/docu/files/api/scala/Ordered.html Thanks, Eric Randall Schulz --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: YA menu question: separate menus
Derek, It does not appear that these changes have been migrated to the snapshot repository yet. What are you plans? thanks, Glenn... On Jun 19, 8:57 am, Derek Chen-Becker dchenbec...@gmail.com wrote: OK, I've committed some new support for groups in the MenuWidget class. Also, the existing MenuWidget had facilities set up to take a SiteMap instance as part of the setup params, but those params were never used. In the interest of simplicity, I've removed those extra params unless someone has a use case that's not covered by groups or the other new functionality. If no one has any issues with the new code I'll merge to master later today. Derek On Fri, Jun 12, 2009 at 1:02 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: Tied up with work this afternoon, but I'll look at reworking MenuWidget with the added functionality. On Fri, Jun 12, 2009 at 6:40 AM, glenn gl...@exmbly.com wrote: Derek, Your new Menu snippet works great. I created a superfish-style menu using a list of groups, like so: object MenuWidgetEx { def apply(groups:List[String]) = new MenuWidgetEx(groups, MenuStyle.HORIZONTAL, JsObj()) render def apply(groups:List[String], style: MenuStyle.Value) = new MenuWidgetEx(groups, style, JsObj()) render def apply(groups:List[String], jsObj: JsObj) = new MenuWidgetEx (groups, MenuStyle.HORIZONTAL, jsObj) render def apply(groups:List[String], style: MenuStyle.Value, jsObj: JsObj) = new MenuWidgetEx(groups, style, jsObj) render } class MenuWidgetEx(groups:List[String], style: MenuStyle.Value, jsObj: JsObj) extends MenuWidget(LiftRules.siteMap open_!, style: MenuStyle.Value, jsObj: JsObj){ override def render :NodeSeq = { def buildMenu(group:String) = lift:Menu.builder group={group} expandAll=true top:class={style.toString} / head ++ div {for(group - groups) yield {buildMenu(group)}} /div } Someone should redo the MenuWidget snippet to handle your new Menu.builder construct, so it doesn't have to be subclassed. Glenn... On Jun 12, 4:59 am, glenn gl...@exmbly.com wrote: My error. Ignore this. I did a mvn clean then mvn install outside of Eclipse on the parent pom and everything worked fine. Glenn... On Jun 12, 4:45 am, glenn gl...@exmbly.com wrote: Derek, I'd love to test the changes you made to Menu, but my build fails when I run mvn install on the pom in the lift directory of the download from http://github.com/dpp/liftweb/tree/wip-dcb-menu-addons Here's what maven reports: [WARNING] Warning in manifest for net.liftweb:lift-webkit:jar:1.1- SNAPSHOT : Did not find matching r eferal for org.slf4j.* [ERROR] Error in manifest for net.liftweb:lift-webkit:jar:1.1- SNAPSHOT : The default package '.' is not permitted by the Import-Package syntax. This can be caused by compile errors in Eclipse because Eclipse creates valid class files regardless of compile errors. The following package(s) import from the default package [net.liftweb.http, net.liftweb.http.auth, n et.liftweb.http.js, net.liftweb.http.js.jquery, net.liftweb.sitemap] [ERROR] Error(s) found in manifest configuration [INFO] [ERROR] BUILD ERROR [INFO] [INFO] Error(s) found in manifest configuration It seems like a problem with the construction of the following plugin in the pom. plugin groupIdorg.apache.felix/groupId artifactIdmaven-bundle-plugin/artifactId configuration instructions Export-Package! net.liftweb.util.*,net.liftweb.*;version=${pom.version}/Export- Package Import-Packageorg.slf4j.*;resolution:=optional,*/ Import-Package DynamicImport-Package*/DynamicImport-Package /instructions /configuration /plugin Either that, or there's something else going on. Any ideas? Glenn... On Jun 11, 11:54 am, Derek Chen-Becker dchenbec...@gmail.com wrote: I'm building some code right now that I think should handle all of your cases. Since Menu.builder is already concerned with building a menu tree, I decided that it would be better to allow you to specify a specific item or group to Menu.builder instead of conflating tree building with the current Menu.item and Menu.group snippets. Given a SiteMap like: val menus = Menu(Loc(Home, List(index), Home Page)) :: Menu(Loc(Viewtest, List(ViewTest, test), View test)) :: Menu(Loc(InsecureViewtest, List(Insecure, test), Insecure View test)) :: Menu(Loc(SelectTest, List(select), asm select test)) :: Menu(Loc(Help, List(help,
[Lift] Re: Making MetaMegaProtoUser templateable
Hello again, thank you so much for your time. My fork is located here: git://github.com/dflemstr/lift_1_1_sample.git The code is very straightforward and I removed all unnecessary constructs (such as the User.scala file) so it should be really clear what the problem is now. On Jun 19, 7:06 pm, David Pollak feeder.of.the.be...@gmail.com wrote: 2009/6/19 dflemstr david.flemst...@gmail.com Well, OK, I'm sorry everyone, I should have been more clear: The goal that I have is to make a snippet that creates a templated edit form for me. However, this is not the issue which I want to discuss. The issue is that when I try to make this snippet (and this could have been any snippet, since the principles are the same), I am unable to, because somewhere the instance of the Mapper for which I want to create the snippet (in this case it's a MetaMegaProtoUser) gets lost, and thus no changes are preserved. I am very confused. I don't understand what gets lost means? The reason why I mentioned the templating in the first place is because I basically use exactly the same code as in the default MetaMegaProtoUser.edit method, just adding some bind calls and an extra parameter: the template NodeSeq, and suddenly the code breaks. A compiler error? An exception? What kind of break do you mean? As mentioned before, any changes I make in the client aren't saved. I have no good way of checking whether the changes even are contained within the POST(→it's the localForm's fault) or if the User instance gets lost earlier (→it's some closure that fails somewhere), but the testEdit function gets called for sure, but with the wrong user instance. I think the best thing to do with discuss in code. I've created a simple project athttp://github.com/dpp/lift_1_1_sample/tree/master Please fork the repository and enhance the code to edit the Dog object... your code doesn't have to compile or run, but if I can see where you're having problems, I can work to resolve them and to help you get over this hump. Point out where you're running into problems and I'll fix up the code to work the way you want it to. Thanks, David Hopefully I've made my problem more clear. On Jun 19, 6:19 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Fri, Jun 19, 2009 at 3:25 AM, dflemstr david.flemst...@gmail.com wrote: Well, that probably is good advice, but doesn't really relate to the matter at hand if I understand you correctly. As you may notice, the code is a modified version of the embedded code, but it's completely independent from it (it doesn't override anything). It could have been code that had been written completely by me. And anyways, my goal is to make a snippet out of the edit form, and not to just be able to load a template from a file (I need to put the whole edit form in multiple, obscure places) so your solution, I must say, isn't any help to me. Maybe my original message title was misleading. I am totally confused as to what your goal is? Is it to put the form into a template file (a .html) file? Is it to control the rendering of the form elements? Is it something else? In terms of ProtoUser, that class is meant as a quick bootstrap to getting your project going. It lends itself nicely to adding fields. Any styling needs to be done via CSS. If you need something more complex (like ESME does), you can pull the code into your User class and then work to achieve the particular goal. If we can cycle a bit on what your particular goal is, I'm sure we can get you there. The issue is that the theUser object isn't preserved between requests. Apart from that, the snippet could've been any other snippet (because it's just being used as a generic mapper; I could've created this form for any structure). Thank you for your effort, anyhow! On Jun 19, 6:21 am, David Pollak feeder.of.the.be...@gmail.com wrote: I'd suggest copying/pasting the code from ProtoUser and MegaProtoUser and munging the code so that you don't have to work around the embedded MegaProtoUser code. Seehttp:// svn.apache.org/viewvc/incubator/esme/trunk/server/src/main/sca... I recently made this change to the On Thu, Jun 18, 2009 at 1:51 PM, dflemstr david.flemst...@gmail.com wrote: Hello everyone, I'm having some problems with making the MetaMegaProtoUser edit method templateable (because I believe in the concept of separating content and design) and am succeeding quite well, except for with one little detail: I can't make my changes in the edit form persistent; it seems that the User instance gets lost somewhere in the process and that all the client-side changes therefore also get lost. The code is at the end of the message. The edit method is called with a template which also is
[Lift] Re: selectObj again
David, thanks a lot. That was exactly what I was looking for, I think I would never had figured this out by myself! thanks! Tobias, Please see http://github.com/dpp/lift_1_1_sample/blob/selectObj/src/main/scala/com/liftcode/model/SelectTrait.scala I think this does what you want it to. Please let me know if it doesn't. Thanks, David On Fri, Jun 19, 2009 at 9:32 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Thanks Dave! I modified the code a little bit: object tradeType extends MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){ override def _toForm = Full(SHtml.selectObj[TradeType] (List( (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))(0), kaufen), (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, SELL))(0), verkaufen)), Full(TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))(0)), (t: TradeType) = set(t)) ) } But I still get the same compiler error! Seems like I've to use some other method instead of set()? I discovered the set() method in one of the tutorials/Lift Book any ideas? thanks On Fri, Jun 19, 2009 at 6:10 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi Dave, thanks again! But I can't find any documentation about the selectType method. I looked at the API docs on the website, but in SHtml the selectType method didn't exist!? Even inside the sources from SHtml on github selectType wasn't there Can you tell me how to use and maybe a short code snippet? Sorry... I typed this when I was wicked tired and my brain fired wrong. :-( SHtml.selectObj[TradeType](...) You have to give the compiler a hint about the type of the list. thanks and sorry for wasting your time... Try: SHtml.selectType[TradeType]() On Thu, Jun 18, 2009 at 6:30 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi There, I'm still having problems with the selectObj method. Here's the code: */* The basic trade types are: BUY and SELL */ object tradeType extends MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){ override def _toForm = Full(SHtml.selectObj (List( (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY)), kaufen), (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, SELL)),verkaufen)), Full(TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))), (t: TradeType) = set(t)) ) }* and here's the compiler error: [INFO] Compiling 1 source files to /home/wacky/workspace_VirtuelleBoerse/virtualMarket/target/classes [WARNING] /home/wacky/workspace_VirtuelleBoerse/virtualMarket/src/main/scala/org/tobster/model/Order.scala:50: error: value set is not a member of Long [WARNING](t: TradeType) = set(t)) [WARNING] ^ [WARNING] one error found What do I've to do, to store the selected object in the corresponding table. thanks -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git
[Lift] Re: malformed Scala signature of User
Hi David, I'm getting a compile error saying that User is already defined. Thinking that it was similar to the problem discussed in this thread, I tried both mvn clean test and the fieldOrder solutions but neither worked. This is with the User model generated from basic archetype and it had previously compiled. Do you or anyone else here have any idea why the compiler is finding another User definition? Thanks! Peter On Apr 28, 10:12 am, David Pollak feeder.of.the.be...@gmail.com wrote: How about: override def fieldOrder = List[BaseOwnedMappedField[User]](id, firstName, lastName, email, locale, timezone, password, textArea) The compiler often gets the type signature wrong on Lists of MappedField. On Tue, Apr 28, 2009 at 9:51 AM, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: hello, Tried to dig a bit more. I noticed that I get the cryptic compile error with the mock objects if I have the following code for User: --- object User extends MetaUser { override def dbTableName = users // define the DB table name override def screenWrap = Full(lift:surround with=default at=content lift:bind //lift:surround) override def fieldOrder = List(id, firstName, lastName, email, locale, timezone, password, textArea) override def skipEmailValidation = true } trait MetaUser extends User with MetaMegaProtoUser[User] /** * An O-R mapped User class that includes first name, last name, password and we add a Personal Essay to it */ class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server // define an additional field for a personal essay object textArea extends MappedTextarea(this, 2048) { override def textareaRows = 10 override def textareaCols = 50 override def displayName = Personal Essay } } --- However, if I change the line: override def fieldOrder = List(id, firstName, lastName, email, locale, timezone, password, textArea) to: override def fieldOrder = List(firstName, lastName, email, locale, timezone, password,textArea) then things get compiled nicely. I noticed that if I putt the Id anywhere inside the list the compile error hits. Am I just doing something really stupid or have I hit some real issue with the compiler? I think more about the first option. br, - Erik On Apr 28, 12:52 am, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Hi, I have noticed this and I always run mvn clean before running the tests or just compiling them. So I get the issue even I run the clean command. -erik David Pollak kirjoitti: Erik, Please do an: mvn clean test From the command line. The Eclipse plugin uses a different version of Scala than does Lift. There will be weird errors like the one you've seen. Thanks, David On Mon, Apr 27, 2009 at 2:24 PM, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Weird thing is that I'm able to mock MetaTeam: --- trait MetaTeam extends Team with LongKeyedMetaMapper[Team] { def findByUser(user:User): List[Team] } object Team extends MetaTeam { def findByUser(user:User): List[Team] = UserTeam.findAll( By(UserTeam.user, user.id), OrderBy(UserTeam.team, Ascending)).map(_.team.obj.open_!) } --- - Erik On Apr 28, 12:19 am, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Hi, I have set of specs test and I'm using mockito I noticed that if I have a list of Users (pretty much same class that is coming from archetype) and do following test: users(1).firstName must beEqualTo(name2) Then I get : [WARNING] Exception in thread main java.lang.RuntimeException: malformed Scala signature of User at 13798; reference type _5 of none refers to nonexisting symbol. If the line is changed to: (users(1).firstName == name2) must beTrue it compiles really nicely. Based on previous posts here it seams to be that this is scala bug (I use 2.7.4|3) Much bigger problem for me is that when trying to mock the User: var userDbMock = mock[MetaUser] causes the same issue: [WARNING] Exception in thread main java.lang.RuntimeException: malformed Scala signature of User at 13798; reference type _5 of none refers to nonexisting symbol. MetaUser is trait: object User extends MetaUser { override def dbTableName = users // define the DB table name override def screenWrap = Full(lift:surround with=default at=content lift:bind //lift:surround) // define the order fields will appear in forms and output override def fieldOrder = List(id, firstName, lastName, email, locale, timezone, password, textArea) // comment this line out to
[Lift] Re: malformed Scala signature of User
Try mvn -U clean install On Fri, Jun 19, 2009 at 12:46 PM, Peter Robinett pe...@bubblefoundry.comwrote: Hi David, I'm getting a compile error saying that User is already defined. Thinking that it was similar to the problem discussed in this thread, I tried both mvn clean test and the fieldOrder solutions but neither worked. This is with the User model generated from basic archetype and it had previously compiled. Do you or anyone else here have any idea why the compiler is finding another User definition? Thanks! Peter On Apr 28, 10:12 am, David Pollak feeder.of.the.be...@gmail.com wrote: How about: override def fieldOrder = List[BaseOwnedMappedField[User]](id, firstName, lastName, email, locale, timezone, password, textArea) The compiler often gets the type signature wrong on Lists of MappedField. On Tue, Apr 28, 2009 at 9:51 AM, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: hello, Tried to dig a bit more. I noticed that I get the cryptic compile error with the mock objects if I have the following code for User: --- object User extends MetaUser { override def dbTableName = users // define the DB table name override def screenWrap = Full(lift:surround with=default at=content lift:bind //lift:surround) override def fieldOrder = List(id, firstName, lastName, email, locale, timezone, password, textArea) override def skipEmailValidation = true } trait MetaUser extends User with MetaMegaProtoUser[User] /** * An O-R mapped User class that includes first name, last name, password and we add a Personal Essay to it */ class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server // define an additional field for a personal essay object textArea extends MappedTextarea(this, 2048) { override def textareaRows = 10 override def textareaCols = 50 override def displayName = Personal Essay } } --- However, if I change the line: override def fieldOrder = List(id, firstName, lastName, email, locale, timezone, password, textArea) to: override def fieldOrder = List(firstName, lastName, email, locale, timezone, password,textArea) then things get compiled nicely. I noticed that if I putt the Id anywhere inside the list the compile error hits. Am I just doing something really stupid or have I hit some real issue with the compiler? I think more about the first option. br, - Erik On Apr 28, 12:52 am, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Hi, I have noticed this and I always run mvn clean before running the tests or just compiling them. So I get the issue even I run the clean command. -erik David Pollak kirjoitti: Erik, Please do an: mvn clean test From the command line. The Eclipse plugin uses a different version of Scala than does Lift. There will be weird errors like the one you've seen. Thanks, David On Mon, Apr 27, 2009 at 2:24 PM, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Weird thing is that I'm able to mock MetaTeam: --- trait MetaTeam extends Team with LongKeyedMetaMapper[Team] { def findByUser(user:User): List[Team] } object Team extends MetaTeam { def findByUser(user:User): List[Team] = UserTeam.findAll( By(UserTeam.user, user.id), OrderBy(UserTeam.team, Ascending)).map(_.team.obj.open_!) } --- - Erik On Apr 28, 12:19 am, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Hi, I have set of specs test and I'm using mockito I noticed that if I have a list of Users (pretty much same class that is coming from archetype) and do following test: users(1).firstName must beEqualTo(name2) Then I get : [WARNING] Exception in thread main java.lang.RuntimeException: malformed Scala signature of User at 13798; reference type _5 of none refers to nonexisting symbol. If the line is changed to: (users(1).firstName == name2) must beTrue it compiles really nicely. Based on previous posts here it seams to be that this is scala bug (I use 2.7.4|3) Much bigger problem for me is that when trying to mock the User: var userDbMock = mock[MetaUser] causes the same issue: [WARNING] Exception in thread main java.lang.RuntimeException: malformed Scala signature of User at 13798; reference type _5 of none refers to nonexisting symbol. MetaUser is trait: object User extends MetaUser { override def dbTableName = users // define the DB table name override def screenWrap = Full(lift:surround with=default at=content
[Lift] Re: selectObj again
On Fri, Jun 19, 2009 at 12:36 PM, Tobias Daub hannes.flo...@gmx.li wrote: David, thanks a lot. That was exactly what I was looking for, I think I would never had figured this out by myself! You were 95% of the way there. thanks! Tobias, Please see http://github.com/dpp/lift_1_1_sample/blob/selectObj/src/main/scala/com/liftcode/model/SelectTrait.scala I think this does what you want it to. Please let me know if it doesn't. Thanks, David On Fri, Jun 19, 2009 at 9:32 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Thanks Dave! I modified the code a little bit: object tradeType extends MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){ override def _toForm = Full(SHtml.selectObj[TradeType] (List( (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))(0), kaufen), (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, SELL))(0), verkaufen)), Full(TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))(0)), (t: TradeType) = set(t)) ) } But I still get the same compiler error! Seems like I've to use some other method instead of set()? I discovered the set() method in one of the tutorials/Lift Book any ideas? thanks On Fri, Jun 19, 2009 at 6:10 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi Dave, thanks again! But I can't find any documentation about the selectType method. I looked at the API docs on the website, but in SHtml the selectType method didn't exist!? Even inside the sources from SHtml on github selectType wasn't there Can you tell me how to use and maybe a short code snippet? Sorry... I typed this when I was wicked tired and my brain fired wrong. :-( SHtml.selectObj[TradeType](...) You have to give the compiler a hint about the type of the list. thanks and sorry for wasting your time... Try: SHtml.selectType[TradeType]() On Thu, Jun 18, 2009 at 6:30 AM, Tobias Daub hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li mailto:hannes.flo...@gmx.li wrote: Hi There, I'm still having problems with the selectObj method. Here's the code: */* The basic trade types are: BUY and SELL */ object tradeType extends MappedLongForeignKey(this.asInstanceOf[MapperType], TradeTypeMetaObj){ override def _toForm = Full(SHtml.selectObj (List( (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY)), kaufen), (TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, SELL)),verkaufen)), Full(TradeTypeMetaObj.findAll(By(TradeTypeMetaObj.name, BUY))), (t: TradeType) = set(t)) ) }* and here's the compiler error: [INFO] Compiling 1 source files to /home/wacky/workspace_VirtuelleBoerse/virtualMarket/target/classes [WARNING] /home/wacky/workspace_VirtuelleBoerse/virtualMarket/src/main/scala/org/tobster/model/Order.scala:50: error: value set is not a member of Long [WARNING](t: TradeType) = set(t)) [WARNING] ^ [WARNING] one error found What do I've to do, to store the selected object in the corresponding table. thanks -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp
[Lift] Deployment questions and little Java web dev experience
Hi, all. I'm new to Lift and have a few questions about using it. For background, I'm coming from Ruby to Scala, having finally been frustrated by some aspects of the former enough to try jumping ship. I know Java syntax, but the simplicity of Ruby has always been a powerful draw for me, so when I used Java I always stayed away from Maven and other cornerstones of the Java tool community. I say all of this not to stir up Ruby vs. Scala drama (because we just don't have enough of that already :P ) but to explain that I'm mistified by much of the Java ecosystem, and a lot of what's out there seems to take it for granted that I know all of this. So please pardon my newbie questions, and feel free to point me to the FM on the subject if there is one, because I've certainly been *trying* to RTFM. :) I also recognize that these topics aren't specific to Lift, but I figure I'm likely to find more proponents of low ceremony in the Scala community than I'd find if I seeked out some more general purpose Java enterprise deployment resource. First...servlets? Web containers? App servers? Oh my. I want to write a few hobbyist apps with Lift and deploy them to my VPS. They may or may not take off, in which case I'd like a solution that can scale to real-world use. Not heavy real-world use, mind you, but I figure a separate VM/port for every app instance is overkill. So what do I need for this? I gather the app server is what handles arranging web apps in a single VM instance, but it's tough cutting through all the enterprise language to figure out which one of these is best for my circumstances, especially since I'm not dealing with legacy code and just want to launch hobbyist/personal projects. And I can't for the life of me figure out whether Tomcat is an app server or something else entirely. This seems so much more complicated than just throwing up a few Mongrels and a load balancer, or reading through the nicely-written Passenger manual and following the step-by-step instructions. I'm sure it has its advantages, I just can't get a grip on how it works. I've also been reading a lot about OSGi and it looks really nice. Am I correct in assuming that OSGi is to Java web apps what Rack is to Ruby ones? OK, maybe not exactly, and I know it's a more general-purpose mechanism (I'm toying with ScalaModules in a desktop app for providing pluggable UIs and other services) but in poking through OSGi articles, I've read a few statements hinting that this is probably the best way to deploy new apps with no legacy dependencies. Is this true? Is an app server actually needed here, or do I just create an OSGi execution environment and start adding bundles? It seems like the way to deploy an app is to build a war file and drop it into a specific directory of your servlet/app server/doohicky-whatamajig serverletcontainerthingie. It also looks as if all apps are installed into the same HTTP namespace, with URL path collisions resolved by editing web.xml and prepending something to the /* for the map elements. Is this accurate? Or is it possible to have the server prepend /myapp or /myapp.war based on the name of the deployed app, then handle the mappings via ProxyPass in the front-end server? That's closer to what I'm used to in Ruby, where the app takes over the URL namespace beneath whatever path you assign it, but it's not clear to me based on what I've read that this happens with Java app servers. Thanks for reading, and again, feel free to respond with a link or google keywords if I'm just missing something obvious. One of the biggest challenges I find myself facing with this move is that most of what I've found assumes a high ceremony-low ceremony migration path, or at least assumes that you've spent enough time in the Java ecosystem at some point to get it. :) --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
[Lift] Re: malformed Scala signature of User
Thanks for the quick response. However, I'm afraid that didn't work. I then deleted the entire project and ~/.m2/ and cloned my project from my remote git repo. The project now compiles with no problems but when I visit the site I just get the html fragment from src/main/webapp/ index.html, without any of the output expected from lift:surround. mvn -U clean install doesn't have any effect. Peter On Jun 19, 1:00 pm, David Pollak feeder.of.the.be...@gmail.com wrote: Try mvn -U clean install On Fri, Jun 19, 2009 at 12:46 PM, Peter Robinett pe...@bubblefoundry.comwrote: Hi David, I'm getting a compile error saying that User is already defined. Thinking that it was similar to the problem discussed in this thread, I tried both mvn clean test and the fieldOrder solutions but neither worked. This is with the User model generated from basic archetype and it had previously compiled. Do you or anyone else here have any idea why the compiler is finding another User definition? Thanks! Peter On Apr 28, 10:12 am, David Pollak feeder.of.the.be...@gmail.com wrote: How about: override def fieldOrder = List[BaseOwnedMappedField[User]](id, firstName, lastName, email, locale, timezone, password, textArea) The compiler often gets the type signature wrong on Lists of MappedField. On Tue, Apr 28, 2009 at 9:51 AM, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: hello, Tried to dig a bit more. I noticed that I get the cryptic compile error with the mock objects if I have the following code for User: --- object User extends MetaUser { override def dbTableName = users // define the DB table name override def screenWrap = Full(lift:surround with=default at=content lift:bind //lift:surround) override def fieldOrder = List(id, firstName, lastName, email, locale, timezone, password, textArea) override def skipEmailValidation = true } trait MetaUser extends User with MetaMegaProtoUser[User] /** * An O-R mapped User class that includes first name, last name, password and we add a Personal Essay to it */ class User extends MegaProtoUser[User] { def getSingleton = User // what's the meta server // define an additional field for a personal essay object textArea extends MappedTextarea(this, 2048) { override def textareaRows = 10 override def textareaCols = 50 override def displayName = Personal Essay } } --- However, if I change the line: override def fieldOrder = List(id, firstName, lastName, email, locale, timezone, password, textArea) to: override def fieldOrder = List(firstName, lastName, email, locale, timezone, password,textArea) then things get compiled nicely. I noticed that if I putt the Id anywhere inside the list the compile error hits. Am I just doing something really stupid or have I hit some real issue with the compiler? I think more about the first option. br, - Erik On Apr 28, 12:52 am, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Hi, I have noticed this and I always run mvn clean before running the tests or just compiling them. So I get the issue even I run the clean command. -erik David Pollak kirjoitti: Erik, Please do an: mvn clean test From the command line. The Eclipse plugin uses a different version of Scala than does Lift. There will be weird errors like the one you've seen. Thanks, David On Mon, Apr 27, 2009 at 2:24 PM, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Weird thing is that I'm able to mock MetaTeam: --- trait MetaTeam extends Team with LongKeyedMetaMapper[Team] { def findByUser(user:User): List[Team] } object Team extends MetaTeam { def findByUser(user:User): List[Team] = UserTeam.findAll( By(UserTeam.user, user.id), OrderBy(UserTeam.team, Ascending)).map(_.team.obj.open_!) } --- - Erik On Apr 28, 12:19 am, erik.karls...@iki.fi erik.b.karls...@gmail.com wrote: Hi, I have set of specs test and I'm using mockito I noticed that if I have a list of Users (pretty much same class that is coming from archetype) and do following test: users(1).firstName must beEqualTo(name2) Then I get : [WARNING] Exception in thread main java.lang.RuntimeException: malformed Scala signature of User at 13798; reference type _5 of none refers to nonexisting symbol. If the line is changed to: (users(1).firstName == name2) must beTrue it compiles really nicely. Based on previous posts here it seams to be that this is scala bug (I use 2.7.4|3) Much
[Lift] Re: YA menu question: separate menus
I'll merge it first thing Monday. I'm going to be in and out this weekend so I don't want to merge something that may potentially break anything. Derek On Fri, Jun 19, 2009 at 11:54 AM, glenn gl...@exmbly.com wrote: Derek, It does not appear that these changes have been migrated to the snapshot repository yet. What are you plans? thanks, Glenn... On Jun 19, 8:57 am, Derek Chen-Becker dchenbec...@gmail.com wrote: OK, I've committed some new support for groups in the MenuWidget class. Also, the existing MenuWidget had facilities set up to take a SiteMap instance as part of the setup params, but those params were never used. In the interest of simplicity, I've removed those extra params unless someone has a use case that's not covered by groups or the other new functionality. If no one has any issues with the new code I'll merge to master later today. Derek On Fri, Jun 12, 2009 at 1:02 PM, Derek Chen-Becker dchenbec...@gmail.comwrote: Tied up with work this afternoon, but I'll look at reworking MenuWidget with the added functionality. On Fri, Jun 12, 2009 at 6:40 AM, glenn gl...@exmbly.com wrote: Derek, Your new Menu snippet works great. I created a superfish-style menu using a list of groups, like so: object MenuWidgetEx { def apply(groups:List[String]) = new MenuWidgetEx(groups, MenuStyle.HORIZONTAL, JsObj()) render def apply(groups:List[String], style: MenuStyle.Value) = new MenuWidgetEx(groups, style, JsObj()) render def apply(groups:List[String], jsObj: JsObj) = new MenuWidgetEx (groups, MenuStyle.HORIZONTAL, jsObj) render def apply(groups:List[String], style: MenuStyle.Value, jsObj: JsObj) = new MenuWidgetEx(groups, style, jsObj) render } class MenuWidgetEx(groups:List[String], style: MenuStyle.Value, jsObj: JsObj) extends MenuWidget(LiftRules.siteMap open_!, style: MenuStyle.Value, jsObj: JsObj){ override def render :NodeSeq = { def buildMenu(group:String) = lift:Menu.builder group={group} expandAll=true top:class={style.toString} / head ++ div {for(group - groups) yield {buildMenu(group)}} /div } Someone should redo the MenuWidget snippet to handle your new Menu.builder construct, so it doesn't have to be subclassed. Glenn... On Jun 12, 4:59 am, glenn gl...@exmbly.com wrote: My error. Ignore this. I did a mvn clean then mvn install outside of Eclipse on the parent pom and everything worked fine. Glenn... On Jun 12, 4:45 am, glenn gl...@exmbly.com wrote: Derek, I'd love to test the changes you made to Menu, but my build fails when I run mvn install on the pom in the lift directory of the download from http://github.com/dpp/liftweb/tree/wip-dcb-menu-addons Here's what maven reports: [WARNING] Warning in manifest for net.liftweb:lift-webkit:jar:1.1- SNAPSHOT : Did not find matching r eferal for org.slf4j.* [ERROR] Error in manifest for net.liftweb:lift-webkit:jar:1.1- SNAPSHOT : The default package '.' is not permitted by the Import-Package syntax. This can be caused by compile errors in Eclipse because Eclipse creates valid class files regardless of compile errors. The following package(s) import from the default package [net.liftweb.http, net.liftweb.http.auth, n et.liftweb.http.js, net.liftweb.http.js.jquery, net.liftweb.sitemap] [ERROR] Error(s) found in manifest configuration [INFO] [ERROR] BUILD ERROR [INFO] [INFO] Error(s) found in manifest configuration It seems like a problem with the construction of the following plugin in the pom. plugin groupIdorg.apache.felix/groupId artifactIdmaven-bundle-plugin/artifactId configuration instructions Export-Package! net.liftweb.util.*,net.liftweb.*;version=${pom.version}/Export- Package Import-Packageorg.slf4j.*;resolution:=optional,*/ Import-Package DynamicImport-Package*/DynamicImport-Package /instructions /configuration /plugin Either that, or there's something else going on. Any ideas? Glenn... On Jun 11, 11:54 am, Derek Chen-Becker dchenbec...@gmail.com wrote: I'm building some code right now that I think should handle all of your cases. Since Menu.builder is already concerned with building a menu tree, I decided that it would be better to allow you to specify a specific item or group to Menu.builder instead of conflating tree building with the current Menu.item and Menu.group
[Lift] Re: Making MetaMegaProtoUser templateable
Okay... this was the hardest problem I've dealt with in a while. Lift processed form elements in the order that they are created. Usually, the order that they are created is the order they appear in bind. However, that is not the case here because the binding to field is a function that is evaluated when each field element is encountered, but the submit button is bound when it's encountered in the bind() method... so the submit button gets bound before the form elements and because of that the functions for the form elements never get run because the submit does a redirect which internally to Lift throws an exception. The Dog was in fact getting saved to the RDBMS, but with its original values. The short answer on how to fix the problem is to change: def innerEdit = bind(dog, xhtml, field - ((x: NodeSeq) = localForm(x, dogToEdit)), submit - SHtml.submit(Edit, testEdit _)) to: def innerEdit = bind(dog, xhtml, field - ((x: NodeSeq) = localForm(x, dogToEdit)), submit - ((ignore: NodeSeq) = SHtml.submit(Edit, testEdit _))) The submit button will be evaluated lazily and last. This will fix the problem. Now... I have to figure out what to do in the broader case because the lazy vs. strict evaluation will cause this subtle thing to happen again and again and it's amazingly non-trivial to figure it out. Thanks, David 2009/6/19 dflemstr david.flemst...@gmail.com Hello again, thank you so much for your time. My fork is located here: git://github.com/dflemstr/lift_1_1_sample.git The code is very straightforward and I removed all unnecessary constructs (such as the User.scala file) so it should be really clear what the problem is now. On Jun 19, 7:06 pm, David Pollak feeder.of.the.be...@gmail.com wrote: 2009/6/19 dflemstr david.flemst...@gmail.com Well, OK, I'm sorry everyone, I should have been more clear: The goal that I have is to make a snippet that creates a templated edit form for me. However, this is not the issue which I want to discuss. The issue is that when I try to make this snippet (and this could have been any snippet, since the principles are the same), I am unable to, because somewhere the instance of the Mapper for which I want to create the snippet (in this case it's a MetaMegaProtoUser) gets lost, and thus no changes are preserved. I am very confused. I don't understand what gets lost means? The reason why I mentioned the templating in the first place is because I basically use exactly the same code as in the default MetaMegaProtoUser.edit method, just adding some bind calls and an extra parameter: the template NodeSeq, and suddenly the code breaks. A compiler error? An exception? What kind of break do you mean? As mentioned before, any changes I make in the client aren't saved. I have no good way of checking whether the changes even are contained within the POST(→it's the localForm's fault) or if the User instance gets lost earlier (→it's some closure that fails somewhere), but the testEdit function gets called for sure, but with the wrong user instance. I think the best thing to do with discuss in code. I've created a simple project athttp://github.com/dpp/lift_1_1_sample/tree/master Please fork the repository and enhance the code to edit the Dog object... your code doesn't have to compile or run, but if I can see where you're having problems, I can work to resolve them and to help you get over this hump. Point out where you're running into problems and I'll fix up the code to work the way you want it to. Thanks, David Hopefully I've made my problem more clear. On Jun 19, 6:19 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Fri, Jun 19, 2009 at 3:25 AM, dflemstr david.flemst...@gmail.com wrote: Well, that probably is good advice, but doesn't really relate to the matter at hand if I understand you correctly. As you may notice, the code is a modified version of the embedded code, but it's completely independent from it (it doesn't override anything). It could have been code that had been written completely by me. And anyways, my goal is to make a snippet out of the edit form, and not to just be able to load a template from a file (I need to put the whole edit form in multiple, obscure places) so your solution, I must say, isn't any help to me. Maybe my original message title was misleading. I am totally confused as to what your goal is? Is it to put the form into a template file (a .html) file? Is it to control the rendering of the form elements? Is it something else? In terms of ProtoUser, that class is meant as a quick bootstrap to getting your project going. It lends itself nicely to adding fields. Any styling needs to be done via CSS. If you need something more complex (like ESME does), you can
[Lift] Re: is there a name for this pattern?
On Thu, Jun 18, 2009 at 11:18 PM, Eric Bowman ebow...@boboco.ie wrote: The basic trick where a superclass has its subclass as a type parameter, e.g. class User extends MegaProtoUser[User] I've run into this before, I remember struggling to get it, then getting it, but I can't recall the epiphany. But obviously this is a relatively common technique, so something to google is much appreciated. I agree with Kris, this circular/recursive type pattern has two edges and I'm not sure one is worth the other. The main benefit I see with this pattern is that it enforces class User to pass the User type parameter to Mapper, so you don't end up with a mixin that doesn't make sense... although I doubt this error would actually happen in reality because you'd quickly realize at design-time that calling any method on User/MetaUser would return you something different than what you expect. ( The drawback is that type signatures are more verbose, complex and viral (if you care about extensibility). Just try explaining the type signature to Scala newbie and they'll run away scared! :) An alternative design would be something of the form, trait Mapper { type MapperType } class User extends Mapper { type MapperType : User } I think this design would be simpler to read and understand, without any practical loss in type checking. (As a side note, if you don't specify the correct type to Mapper with the current design, you get an error message that's hardly helpful to newbies, so it doesn't help much either... but I disgress.) While I'm at it, there are also places in the code that could use this.type instead of MapperType (also called A as parameter) to give out an even more specific type without any tradeoffs. A prime example of this would be Mapper.saveMe(). Just to be clear, I'm not proposing anything be changed in Lift's current mapper since it would break compatibility I'm just suggesting it for consideration in future design work... perhaps in Lift's new record module? alex --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---