[Lift] Re: Using TemplatePf for JPA powered templates
Will do, if I figure it out. But my comment wasn't complaining. I am honestly mystified. Am I the only one using trees in Hibernate? Is there a tree library in Scala that I'm missing? What the heck does everyone else do? It just blows my mind. Chas. Viktor Klang wrote: On Mon, Dec 1, 2008 at 5:42 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Doing nested sets in your Lift snippet is pretty easy with JPA. I'm doing it on one of my Lift sites. One thing to remember, however, is to use a transaction. You don't want to do half the update to the tree and then have another use start an update before you've finished yours (or have half of it fail). Once it gets messed up it's a disaster. Nested tables are good when you have lots of lookups, particularly pulling ancestors or descendants, but not too many updates. Inserts are not too bad, but if you have to move whole subtrees, that's a pain. I'm using one for, among other things, a forum, so messages once posted never get moved. Nested sets work great for that. But, honestly, it is astonishing to me that Java, Scala, and especially JPA/Hibernate apparently have no built in features for creating, manipulating, and persisting trees (and networks are even less supported). These problems were largely solved long ago. Why aren't they built in? Charles, I hate to say this, but Hibernate is Open Source, so you can add the support for it. :) Rails has a cool set of plugins -- acts_as_list, acts_as_tree, and acts_as_nested_set -- that make it drop-dead simple to implement trees. I was thinking that it would be cool if Lift had something similar but maybe as a trait? So my object extends ActsAsNestedSet? I tried to do this in Hibernate, but it would require the object to query for other similar objects. For example, if I had a Node object that I was persisting, I'd like to do class Node extends ActsAsNestedSet And then define methods such as moveToChildOf(node), moveToFirst, moveBack, moveForth, moveToLast, etc. But it appears that you need an EntityManager to run a query, and there doesn't seem to be a way to go backwards from the Node to the EntityManager (probably because, if I understand it correctly, there will only be one copy of a given Node in memory but there may be multiple EntityManagers?). So I put the code in the snippet. If you come up with any clever solutions, I'd love to hear them. Chas. Tim Perrett wrote: Hey Derek, I've been playing around with this nested set stuff today - it's pretty cool. I nearly have an app working that uses the db for page content and maps the urls out however you want, it's pretty neat. I have a slight HQL problem with subquery's but I'll post that 2mro :-) Thanks for all your help Tim Sent from my iPhone On 30 Nov 2008, at 23:37, Derek Chen-Becker [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: IIRC, JPA has support for batch updates, but I'm not 100% positive on that. I'll have more time tomorrow to look at this if you'd still like to discuss it. Derek On Sun, Nov 30, 2008 at 12:32 PM, Tim Perrett mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED][EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Derek, Those links are *extremely* good - thank you! I've not really done anything with tree structures before and they are really, really usefull. One thing however, it appears the optimal way of doing the insert queries would be with stored procedures, however that im not down with, and ideally, i want to keep database vendor independent (part of the point of using JPA) so ideally i want to suck that up into the application logic. For instance: --START SELECT @myRight := rgt FROM nested_category WHERE name = 'TELEVISIONS'; UPDATE nested_category SET rgt = rgt + 2 WHERE rgt @myRight; UPDATE nested_category SET lft = lft + 2 WHERE lft @myRight; INSERT INTO nested_category(name, lft, rgt) VALUES('GAME CONSOLES', @myRight + 1, @myRight + 2); --END This makes use of variables, and i could of course do this via 3 separate queries in JPA, but i wondered if there was a neater way to construct this type of thing with JPA? Any advice you guys have is most welcome
[Lift] Re: JPA find or create new
That will probably work. I was thinking it would be nice to build in a method findOrNew that would do it for me... but it looks like that might involve some sort of implicit manifest thingy, so I don't know. Chas. Viktor Klang wrote: On Mon, Dec 1, 2008 at 7:12 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Is there a simple way in JPA/Lift to query to retrieve a single object from the database, assign it to a val if found, or create a new object of that type and assign it instead of there is no such object in the database? Sort of a... val user: User = Model.createNamedQuery( findUserByUsername, username - hal ).findOr(new User()) (Can ! (yourQuery.uniqueResult)).openOr(new User()) Should work? or something like that? That would be very useful. Thanks, Chas. -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Using TemplatePf for JPA powered templates
Are you including a link to the parent node or are you just using the left and right values to figure out which nodes are children? I always include a foreign key to the parent so I can just select the children of that parent directly. Then to get all descendants, I use the left and right values. Similarly, to get the parent I use the foreign key, to get all ancestors, I use the left/right values. Does this help? (Sometimes I also include a calculated field called level which indicates how far away I am from the root node. It's a simple matter of counting the ancestors, but you have to remember to update it on moves. The level field is very useful if you want to go, say, two levels deep on children, or to parent and grandparent, but not great-grandparent.) Chas. Tim Perrett wrote: On Dec 1, 9:21 am, Charles F. Munat [EMAIL PROTECTED] wrote: Will do, if I figure it out. But my comment wasn't complaining. I am honestly mystified. Am I the only one using trees in Hibernate? Is there a tree library in Scala that I'm missing? What the heck does everyone else do? It just blows my mind. I found someone's contribution on Hibernate JIRA for handling sets, but it never seems to make it into core or the proper distro; it does seem odd its not in there. Anyway, the HQL problem I mentioned last night... I have the following HQL, which is just a slight mod from what was in that mysql article; effectivly I want to list all the children of a single leaf: SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth FROM Content AS node, Content AS parent, Content AS sub_parent, ( SELECT node.name, (COUNT(parent.name) - 1) AS depth FROM Content AS node, Content AS parent WHERE node.lft BETWEEN parent.lft AND parent.rft AND node.name = :leaf GROUP BY node.name ORDER BY node.lft ) AS sub_tree WHERE node.lft BETWEEN parent.lft AND parent.rft AND node.lft BETWEEN sub_parent.lft AND sub_parent.rft AND sub_parent.name = sub_tree.name GROUP BY node.name HAVING depth = 1 ORDER BY node.lft However, it bombs on the sub-query in the SELECT ... FROM ... subquery statement im guessing you guys are using get all leaf nodes type queries, so what are you doing instead of this? Cheers Tim --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Using TemplatePf for JPA powered templates
Im not sure I follow? Can you use this diagram to try and explain?: http://dev.mysql.com/tech-resources/articles/hierarchical-data-4.png If you wanted to select the direct children of 'electronics', how would one go about doing that? Is there a simpler way than all that HQL? Cheers Tim On Dec 1, 10:28 am, Charles F. Munat [EMAIL PROTECTED] wrote: Are you including a link to the parent node or are you just using the left and right values to figure out which nodes are children? I always include a foreign key to the parent so I can just select the children of that parent directly. Then to get all descendants, I use the left and right values. Similarly, to get the parent I use the foreign key, to get all ancestors, I use the left/right values. Does this help? (Sometimes I also include a calculated field called level which indicates how far away I am from the root node. It's a simple matter of counting the ancestors, but you have to remember to update it on moves. The level field is very useful if you want to go, say, two levels deep on children, or to parent and grandparent, but not great-grandparent.) Chas. Tim Perrett wrote: On Dec 1, 9:21 am, Charles F. Munat [EMAIL PROTECTED] wrote: Will do, if I figure it out. But my comment wasn't complaining. I am honestly mystified. Am I the only one using trees in Hibernate? Is there a tree library in Scala that I'm missing? What the heck does everyone else do? It just blows my mind. I found someone's contribution on Hibernate JIRA for handling sets, but it never seems to make it into core or the proper distro; it does seem odd its not in there. Anyway, the HQL problem I mentioned last night... I have the following HQL, which is just a slight mod from what was in that mysql article; effectivly I want to list all the children of a single leaf: SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth FROM Content AS node, Content AS parent, Content AS sub_parent, ( SELECT node.name, (COUNT(parent.name) - 1) AS depth FROM Content AS node, Content AS parent WHERE node.lft BETWEEN parent.lft AND parent.rft AND node.name = :leaf GROUP BY node.name ORDER BY node.lft ) AS sub_tree WHERE node.lft BETWEEN parent.lft AND parent.rft AND node.lft BETWEEN sub_parent.lft AND sub_parent.rft AND sub_parent.name = sub_tree.name GROUP BY node.name HAVING depth = 1 ORDER BY node.lft However, it bombs on the sub-query in the SELECT ... FROM ... subquery statement im guessing you guys are using get all leaf nodes type queries, so what are you doing instead of this? Cheers Tim --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: a plea for documentation
http://github.com/tjweir/liftbook/tree/master See earlier posts for details. Derek On Sun, Nov 30, 2008 at 7:33 PM, Oscar Picasso [EMAIL PROTECTED]wrote: Which book are you talking about? I didn't know that they were already chapters of a lift book we could read. On Wed, Nov 26, 2008 at 9:15 PM, David Stein [EMAIL PROTECTED] wrote: I started looking at a few chapters a while ago, but they were more outlines at the time. Somehow I missed the chapters which are actually pretty comprehensive, like the one on JPA. Very much looking forward to this! --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA find or create new
Because it's type erasure I don't think I can do a generic new inside the methods, but the findOne method does return a Can. That means that you were actually pretty close in your demo code. Here's what it could look like: val user: User = Model.createNamedQuery[User]( findUserByUsername, username - hal ).findOne or (new User) Derek On Mon, Dec 1, 2008 at 2:24 AM, Charles F. Munat [EMAIL PROTECTED] wrote: That will probably work. I was thinking it would be nice to build in a method findOrNew that would do it for me... but it looks like that might involve some sort of implicit manifest thingy, so I don't know. Chas. Viktor Klang wrote: On Mon, Dec 1, 2008 at 7:12 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Is there a simple way in JPA/Lift to query to retrieve a single object from the database, assign it to a val if found, or create a new object of that type and assign it instead of there is no such object in the database? Sort of a... val user: User = Model.createNamedQuery( findUserByUsername, username - hal ).findOr(new User()) (Can ! (yourQuery.uniqueResult)).openOr(new User()) Should work? or something like that? That would be very useful. Thanks, Chas. -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Testing for well-formed XML
For now the plugin lives here: http://github.com/dchenbecker/maven-lift/tree/master I'm going to talk to David B. about hosting the plugin on scala-tools, but for now you can check it out and do a mvn install on the source. Then add plugin groupIdnet.liftweb.tools/groupId artifactIdmaven-lift/artifactId /plugin To your POM's plugins section. Once you've done that the plugin should automatically run during the compile phase, and will produce a file called target/i18n-template.properties that contains all of the found I18N keys. If you want to run the plugin manually, just run mvn lift:i18ngen. Derek On Sun, Nov 30, 2008 at 4:46 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: OK, I have a maven-lift plugin done with an i18ngen target that you can use to parse all of your Scala and xhtml sources for i18n keys (lift:loc, etc). The question now is, where should I put it? Should I put it in the main lift repo or just dump it in my own github repo? Derek On Fri, Nov 28, 2008 at 7:49 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote: Yes, I was just reading about writing Maven plugins yesterday for the I18N tool and it looks like they depend heavily on javadoc-style annontations. Right now that means the plugin I'm hacking on has a Scala implementation with essentially a Java shim. I would much prefer to just have a single scala plugin :) Derek On Fri, Nov 28, 2008 at 6:34 AM, Josh Suereth [EMAIL PROTECTED]wrote: Alright, My new side project is to be able to write maven plugins in the scala language. Luckily for us JRuby and Groovy have already done this (although Groovy took a huge shortcut that JRuby/Scala are unable to use), so I have some great sample code. Anyway, before I start cranking on this, just wanted to make sure this is needed/desired for future lift work? On Thu, Nov 27, 2008 at 10:27 PM, Josh Suereth [EMAIL PROTECTED] wrote: The maven-scala-plugin is a great place to look to get started. DavidB did a great job on that. Whenever I need to figure out how to do maven trickery I usually just download the source to the closest plugin I can think of. I'm not sure anyone is doing maven plugins in pure-scala, which might be a downside for the lift framework. Let me take a shot and see what's required to do a pure-scala maven plugin. If I'm quick, it might be out soon. On Thu, Nov 27, 2008 at 12:09 PM, Jorge Ortiz [EMAIL PROTECTED]wrote: Yeah, I'd love to make this a Maven build plugin. When it comes to Maven I'm a total dunce though, but I'll look into it. Any pointers on where to get started? On Thu, Nov 27, 2008 at 3:59 AM, Josh Suereth [EMAIL PROTECTED] wrote: Hey, neat idea! That will definitely help me avoid my own dumb errors. I'm just throwing this out there, but would it make sense to try to make this a Maven build plugin in the future? That way you could control where it runs in the lifecycle if you wanted to. -Josh On Wed, Nov 26, 2008 at 8:07 PM, Jorge Ortiz [EMAIL PROTECTED]wrote: Oops, it just test *.htm and *.xhtml files as well. Updated code below. --j /** * Tests to make sure the project's XML files are well-formed. * * Finds every *.html and *.xml file in src/main/webapp (and its * subdirectories) and tests to make sure they are well-formed. */ def testXml() = { var failed: List[java.io.File] = Nil def handled(file: String) = file.endsWith(.html) || file.endsWith(.xml) || file.endsWith(.htm) || file.endsWith(.xhtml) def wellFormed(file: java.io.File) { if (file.isDirectory) for (f - file.listFiles) wellFormed(f) if (file.isFile handled(file.getName)) { try { scala.xml.XML.loadFile(file) } catch { case e: org.xml.sax.SAXParseException = failed = file :: failed } } } wellFormed(new java.io.File(src/main/webapp)) val numFails = failed.size if (numFails 0) { val fileStr = if (numFails == 1) file else files val msg = Malformed XML in + numFails + + fileStr + : + failed.mkString(, ) println(msg) fail(msg) } } On Wed, Nov 26, 2008 at 4:58 PM, Jorge Ortiz [EMAIL PROTECTED]wrote: Folks, One of the concerns raised at the Lift Workshop on Saturday was that ill-formed XML files in your templates will fail at run time instead of compile time, often with cryptic errors. To correct for this, I've added a simple test to lift-archetype-basic and lift-archetype-blank that will test all *.html and *.xml files in your src/main/webapp directory (and its subdirectories) to make sure they can all be loaded by Scala's XML parser. If they can't be loaded the test will fail and notify you which files couldn't be loaded and why. These tests run during Maven's 'test' phase. This phase is required before the 'package', 'install', or 'deploy' phases can run. Unfortunately, the
[Lift] Re: Using TemplatePf for JPA powered templates
Tim, Please remember that Lift's Snippet processing is recursive. Thus, you don't really need to hook into the templating system in order to be able to using Lift's templates. For example, if your snippet returned: spanlift:comet type=Dog/lift:comet type=Cat//span Lift would then interpret the two comet tags and you'd wind up with two comet components on the page. However, I think it's a security risk to allow arbitrary users to be able to embed lift:xxx/ tags in their content. This would in effect allow any user access to any resource that any snippet has access to. On the caching front, I'd hand-roll my own caching mechanism. You'll probably end up caching all (or almost all) the content. Rather than doing some goofy stuff in SQL trying to do object graph traversals, just do it in objects. You can use immutability and actors to deal with most of the concurrency issues. Thanks, David On Sat, Nov 29, 2008 at 6:25 PM, Tim Perrett [EMAIL PROTECTED] wrote: I've been playing around with this and extending the template loader is actually pretty easy. Its much simpler than I thought it would be! I have a dilemma however - store the templates (and associated meta data) in the database and then have to do a fetch / read on every request, or, use the file system and hold (for instance): example.html and example.meta // java properties file format The tree structure of the file system is the path of least resistance for my particular use case i think, but i guess im after some input / advice...? I feel as either way has a couple of hang-ups! The kind of meta data is just simple key-value pair stuff, but my plan would be to extend Record so that the save() etc became transparent and was abstracted away (i.e. don't need to worry about InputStreams etc) Appreciate any input / advice people have Cheers Tim On Nov 29, 2:31 pm, Derek Chen-Becker [EMAIL PROTECTED] wrote: Looking at findVisibleTemplate in LiftSession (line 512) certainly makes it appear that the template table defined by addTemplateBefore/After is consulted before it checks the filesystem. Derek On Fri, Nov 28, 2008 at 10:26 AM, Tim Perrett [EMAIL PROTECTED] wrote: Hey guys, I want to user lifts LiftRules.addTemplateBefore/After to load templates from a database, where my persistence is JPA. With TemplatePf can I do this? Im also thinking this will be one of the nice things about having lift tags, as it will mean i shouldn't need to build a custom tagging language or anything (as we already have it!). I presume that TemplatePf just tells lift where to get the XHTML from then it continues to do the processing on it (process snippets etc)? Cheers Tim -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Testing for well-formed XML
On Sun, Nov 30, 2008 at 3:46 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: OK, I have a maven-lift plugin done with an i18ngen target that you can use to parse all of your Scala and xhtml sources for i18n keys (lift:loc, etc). The question now is, where should I put it? Should I put it in the main lift repo or just dump it in my own github repo? Awesome stuff. Please let DavidB decide how and where it should go. I have a minor preference for putting it right in Lift, but we don't really have a tools section, so it might make more sense to have it live separately, but host the compiled code on scala-tools.org. Derek On Fri, Nov 28, 2008 at 7:49 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote: Yes, I was just reading about writing Maven plugins yesterday for the I18N tool and it looks like they depend heavily on javadoc-style annontations. Right now that means the plugin I'm hacking on has a Scala implementation with essentially a Java shim. I would much prefer to just have a single scala plugin :) Derek On Fri, Nov 28, 2008 at 6:34 AM, Josh Suereth [EMAIL PROTECTED]wrote: Alright, My new side project is to be able to write maven plugins in the scala language. Luckily for us JRuby and Groovy have already done this (although Groovy took a huge shortcut that JRuby/Scala are unable to use), so I have some great sample code. Anyway, before I start cranking on this, just wanted to make sure this is needed/desired for future lift work? On Thu, Nov 27, 2008 at 10:27 PM, Josh Suereth [EMAIL PROTECTED] wrote: The maven-scala-plugin is a great place to look to get started. DavidB did a great job on that. Whenever I need to figure out how to do maven trickery I usually just download the source to the closest plugin I can think of. I'm not sure anyone is doing maven plugins in pure-scala, which might be a downside for the lift framework. Let me take a shot and see what's required to do a pure-scala maven plugin. If I'm quick, it might be out soon. On Thu, Nov 27, 2008 at 12:09 PM, Jorge Ortiz [EMAIL PROTECTED]wrote: Yeah, I'd love to make this a Maven build plugin. When it comes to Maven I'm a total dunce though, but I'll look into it. Any pointers on where to get started? On Thu, Nov 27, 2008 at 3:59 AM, Josh Suereth [EMAIL PROTECTED] wrote: Hey, neat idea! That will definitely help me avoid my own dumb errors. I'm just throwing this out there, but would it make sense to try to make this a Maven build plugin in the future? That way you could control where it runs in the lifecycle if you wanted to. -Josh On Wed, Nov 26, 2008 at 8:07 PM, Jorge Ortiz [EMAIL PROTECTED]wrote: Oops, it just test *.htm and *.xhtml files as well. Updated code below. --j /** * Tests to make sure the project's XML files are well-formed. * * Finds every *.html and *.xml file in src/main/webapp (and its * subdirectories) and tests to make sure they are well-formed. */ def testXml() = { var failed: List[java.io.File] = Nil def handled(file: String) = file.endsWith(.html) || file.endsWith(.xml) || file.endsWith(.htm) || file.endsWith(.xhtml) def wellFormed(file: java.io.File) { if (file.isDirectory) for (f - file.listFiles) wellFormed(f) if (file.isFile handled(file.getName)) { try { scala.xml.XML.loadFile(file) } catch { case e: org.xml.sax.SAXParseException = failed = file :: failed } } } wellFormed(new java.io.File(src/main/webapp)) val numFails = failed.size if (numFails 0) { val fileStr = if (numFails == 1) file else files val msg = Malformed XML in + numFails + + fileStr + : + failed.mkString(, ) println(msg) fail(msg) } } On Wed, Nov 26, 2008 at 4:58 PM, Jorge Ortiz [EMAIL PROTECTED]wrote: Folks, One of the concerns raised at the Lift Workshop on Saturday was that ill-formed XML files in your templates will fail at run time instead of compile time, often with cryptic errors. To correct for this, I've added a simple test to lift-archetype-basic and lift-archetype-blank that will test all *.html and *.xml files in your src/main/webapp directory (and its subdirectories) to make sure they can all be loaded by Scala's XML parser. If they can't be loaded the test will fail and notify you which files couldn't be loaded and why. These tests run during Maven's 'test' phase. This phase is required before the 'package', 'install', or 'deploy' phases can run. Unfortunately, the 'jetty:run' phase only requires 'test-compile', not 'test'. If you want the test to run before starting Jetty, you'll have to specify it manually: 'mvn test jetty:run' (or 'mvn install jetty:run', etc). The test is available on any new projects created with Lift's archetypes. To add the test to your own project, the code is included below. It's a
[Lift] Re: Using TemplatePf for JPA powered templates
Hey David, Thanks for the response - I have been reflecting on the whole L2 cache thing today and kind of came to the same conclusion. If the content has been served, it might as well be cached in its entirety as a HTML file so it can then be served by the front end web-server (nginx, apache etc) and i'll just expire the cache on a ad-hoc basis from the admin application. As for your concerns over security - I agree, it has grounding, but on the other hand, my plan was to provide a couple of snippets and document those, things like: - list all leaf nodes - list all nodes etc, etc I can also then take advantage of the lift localization mechanism - so all in all, I think the pro's out weigh the cons. Potentially in the XML page parser I could add a step which checked for the presence of un-allowed tags (like comet) via some XML DOM checking. Just a thought anyways :-) Cheers Tim On Dec 1, 5:11 pm, David Pollak [EMAIL PROTECTED] wrote: Tim, Please remember that Lift's Snippet processing is recursive. Thus, you don't really need to hook into the templating system in order to be able to using Lift's templates. For example, if your snippet returned: spanlift:comet type=Dog/lift:comet type=Cat//span Lift would then interpret the two comet tags and you'd wind up with two comet components on the page. However, I think it's a security risk to allow arbitrary users to be able to embed lift:xxx/ tags in their content. This would in effect allow any user access to any resource that any snippet has access to. On the caching front, I'd hand-roll my own caching mechanism. You'll probably end up caching all (or almost all) the content. Rather than doing some goofy stuff in SQL trying to do object graph traversals, just do it in objects. You can use immutability and actors to deal with most of the concurrency issues. Thanks, David --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Named Partial Functions
On Wed, Nov 26, 2008 at 2:44 PM, Alex Boisvert [EMAIL PROTECTED] wrote: ... extends PartialFunction with Named ? I was looking to name the companion object. It's called NamedPF alex On Wed, Nov 26, 2008 at 2:08 PM, TylerWeir [EMAIL PROTECTED] wrote: DebugPartialFunction, DbgPartialFunction, DebugPf, DbgPf, TracePartialFunction, TracePf (Sort of took the shotgun approach :) On Nov 26, 4:19 pm, Marius [EMAIL PROTECTED] wrote: TrackPf ? On Nov 26, 10:21 pm, David Pollak [EMAIL PROTECTED] wrote: Folks, One of the things that came out of the Lift Workshop was the need for tracing of rewrites, sitemaps, etc. Most of the rewrite, etc. logic is buried in PartialFunctions that are composed together. In order to accommodate the need to trace what code is changing requests, matching stuff for sitemaps, etc., I need to add a name to the PartialFunction... a trait I'm calling NamedPartialFunction I'm going to create a helper object that will vend NamedPartialFunctions and do other things (like tracing their execution). I'd like to have a name that's shorter than NamedPartialFunction, but longer than NPF. Any ideas? Thanks, David -- Lift, the simply functional web frameworkhttp://liftweb.net Collaborative Task Managementhttp://much4.us Follow me:http://twitter.com/dpp Git some:http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Alter presentation behavior with snippet markup
I've added def dmap[B](dflt: = B)(f: A = B): B to Cans: S.param(foo).dmap(5)(toInt) On Fri, Nov 28, 2008 at 6:53 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote: I have to say, I love this Can-map-openOr idiom. I use it all of the time in my code for parameter handling, etc. Derek On Fri, Nov 28, 2008 at 5:51 AM, Marius [EMAIL PROTECTED] wrote: Yup ... or you can have val count = S.attr(count).map(_.toInt) openOr 5 Br's, Marius On Nov 28, 2:15 pm, Tim Perrett [EMAIL PROTECTED] wrote: Wow, I cant belive I didnt know about that - thats pretty fricking useful!! Presumably: val count: Int = S.attr(count) match { case Full(item) = item.toInt case Empty = 5 } Is the normal idiom? Cheers Tim On Nov 27, 11:34 pm, Tim Perrett [EMAIL PROTECTED] wrote: Hmm interesting! This I'm not familiar with - I'll give it a whirl tomorow. Cheers, Derek Sent from my iPhone On 27 Nov 2008, at 22:11, Derek Chen-Becker [EMAIL PROTECTED] wrote: I thought that S.attr could already be used to get the attributes on a tag. Am I misunderstanding what you're getting at? Derek On Thu, Nov 27, 2008 at 11:38 AM, Tim Perrett [EMAIL PROTECTED] wrote: Guys, Im currently re-designing the whole bloglite publishing engine im writing and one of the things im considering is how I could possible extend lifts tagging mechanism so that users could decide on there own dynamic content, rather than just have textile based articles. For instance, a list of latest blogs on the home page of a site: this might be a mixture of static content, and then the dynamic list of course. My original plan was to provide a bunch of default snippets; stuff like list all the child pages of this page type thing, but im pretty sure that simply wont be flexible enough. I know its very JSP like, but it does seem like we could add on functionality for things such as deciding how many items should be within a list. The programmer builds his app to say heres a list of articles, but surley, its up to the designer to decide how many should be displayed on that page? given this snippet: class Articles { def list(max: Int) = { ... // fetch articles } } that it would then be sensible for the designer to be able to do: lift:articles.list max=5 / What is the feeling on this type of thing? I appreciate this could well be abused, but right now it strikes me that there are lots of situations where the designer doesnt have quite enough control over the (presentation) logic without coding scala (altering the snippet) Thoughts? Cheers Tim -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Lift and eclipse hotdeploy
On Fri, Nov 28, 2008 at 4:39 AM, Acciaio [EMAIL PROTECTED] wrote: Thanx for the advice, Now I'm writing code into eclipse with a project setted up without source files to compile and after I run jetty I also run a scala:cc on the same project... Don't works perfectly but in this way I have completion help on my scala code and a on-the-fly compile of my classes... You might also try JavaRebel This is the better situation that I find. Andrea On Nov 27, 8:07 pm, Tim Perrett [EMAIL PROTECTED] wrote: When it cant find Boot thats usually because there was some duff code before the compiller got to compiling Boot. From the terminal, cd into that directory of your project and do: mvn clean scala:cc If you have any errors in your file this wil then be highlighted as the compiller daemon runs. It will also compile your files as you save them. Im afraid I cant comment on eclipse as im really not familiar with it - terminal window and textmate all the way! HTH Tim On Nov 27, 1:07 pm, Acciaio [EMAIL PROTECTED] wrote: On the other hand also trying to run the same project with mvn jetty:run from command line don't works because cannot find bootstrap.liftweb.Boot. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA and Record
My 2 cents: - I'm strongly opposed to any compiler plugins as they (1) mean that IDEs will work less well and (2) they require some sort of installation (if they can be rolled into the Maven building stuff, it makes this objection go away) - I'm strongly opposed to mixing annotations and the Record stuff. It'll just make for wicked ugly looking code. I believe there are ways to use Record's deep knowledge of class layouts to generate data structures and/or XML to send to JPA to do the right thing. On Sun, Nov 30, 2008 at 7:45 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote: The whole point of integrating (and I use the word integrating here loosely) is so that there's a common form framework for people to use. Really, the point of Record as far as I can tell is to loosen and/or remove the tight coupling with the datastore, and in that sense Record is succeeding. As Tim points out, there are going to be people with existing JPA libraries and what we're trying to propose is a means for them to leverage their existing libraries alongside the nice work done in Record. As ugly as the boilerplate for delegation may seem, I don't see any better solution without adding significant complexity. I've done bytecode manipulation in the past and while it can be very handy, it makes things a lot more complex on the backend and I'm really trying to avoid complexity (this includes a compiler plugin, too). Delegation provides the cleanest approach I can come up with; it actually helps in the case where someone wants to use an existing JPA library because you could simply wrap an instance and delegate to it: class MyEntry extends Record[MyEntry] { var inner : RealEntry = _ object name extends StringField(this) with Delegation name.delegate(inner.name, inner.name = _) ... } By adding a few lines of boilerplate in each class you get validation, form generation, presentation HTML, JSON representation, etc. It's up to the end-user to determine whether these features are worth the cost of a few LoC. I'm not saying this is a perfect solution, just that I think that this is the best first cut at it. Also, no one is saying that people have to use JPA with Record. I'm assuming that the majority of new Lift apps will probably use Record/Mapper because they're simple, easy to use and quite capable of handling most data models. But for the people with existing JPA libraries, or for people who would like to use JPA for the additional features, compatibility with Java apps, etc, I'd like to have a better answer than an absolute Don't use Record or Switch to Record. Derek On Sun, Nov 30, 2008 at 1:40 AM, Marius [EMAIL PROTECTED] wrote: I totally agree with you Viktor! ... although it seems like a workable solution in this case a Record contains to distinct entities to represent the same data and of course the boilerplate. It was mentioned above compiler plugins which I expressed my opinion about it (I'd stay away) but there might be another way to alter the bytecode at runtime. I'm talking about dynamic class weaving. Basically it is a class loader that before returning the actual updated class. Kind of what AspectJ is doing. A while ago a wrote a bytecode level manipulation framework and combined with a special classloader I was able to modify a class dynamically and use it. Of course there are caveats: 1. Complexity induced by bytecode level manipulation 2. How a dynamic class loader cope with container's classloader that essentially loads the web application. Of course it would delegate the loading to the container's classloader but these modifiable classes should probably not live in WEB-INF/classes or WEB-INF/lib folder. But all in all I'm not convinced that this effort really worth it. AFAIC I still don;t get the whole point of integrating Record/Field with JPA. If someone wants to switch easily from JPA to Record or vice- versa, to have this flexibility perhaps consider to abstract these layers from the rest of the application and using other persistence technologies would not affect the application business logic ... but this is about how the appliation is designed etc. Br's, Marius On Nov 30, 9:56 am, Viktor Klang [EMAIL PROTECTED] wrote: IMHO: @Column{val name = my_name} var name : String = _ object nameField extends StringField(this,100) with Delegated nameField.delegate(name, name = _) That's just too much boilerplate. For me, who went to scala to lose boilerplate, this is not a viable solution. Unfortunately the JPA spec is kind of weak when it comes to adaptation, so my suggestion to make it work with Hibernate first still stands. What do you guys think? Cheers, Viktor On Sat, Nov 29, 2008 at 10:23 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: No big deal. In the example code I did a by-name in the delegate method so at least it's transparent to the
[Lift] Re: Alter presentation behavior with snippet markup
On Mon, Dec 1, 2008 at 10:24 AM, Alex Boisvert [EMAIL PROTECTED] wrote: Isn't this similar to Option.mapOrElse that you opposed on the scala mailing list? :) In fact it is. :-) Polluting Scala is bad. Polluting Lift is less bad. alex On Mon, Dec 1, 2008 at 9:55 AM, David Pollak [EMAIL PROTECTED] wrote: I've added def dmap[B](dflt: = B)(f: A = B): B to Cans: S.param(foo).dmap(5)(toInt) On Fri, Nov 28, 2008 at 6:53 AM, Derek Chen-Becker [EMAIL PROTECTED] wrote: I have to say, I love this Can-map-openOr idiom. I use it all of the time in my code for parameter handling, etc. Derek On Fri, Nov 28, 2008 at 5:51 AM, Marius [EMAIL PROTECTED] wrote: Yup ... or you can have val count = S.attr(count).map(_.toInt) openOr 5 Br's, Marius On Nov 28, 2:15 pm, Tim Perrett [EMAIL PROTECTED] wrote: Wow, I cant belive I didnt know about that - thats pretty fricking useful!! Presumably: val count: Int = S.attr(count) match { case Full(item) = item.toInt case Empty = 5 } Is the normal idiom? Cheers Tim On Nov 27, 11:34 pm, Tim Perrett [EMAIL PROTECTED] wrote: Hmm interesting! This I'm not familiar with - I'll give it a whirl tomorow. Cheers, Derek Sent from my iPhone On 27 Nov 2008, at 22:11, Derek Chen-Becker [EMAIL PROTECTED] wrote: I thought that S.attr could already be used to get the attributes on a tag. Am I misunderstanding what you're getting at? Derek On Thu, Nov 27, 2008 at 11:38 AM, Tim Perrett [EMAIL PROTECTED] wrote: Guys, Im currently re-designing the whole bloglite publishing engine im writing and one of the things im considering is how I could possible extend lifts tagging mechanism so that users could decide on there own dynamic content, rather than just have textile based articles. For instance, a list of latest blogs on the home page of a site: this might be a mixture of static content, and then the dynamic list of course. My original plan was to provide a bunch of default snippets; stuff like list all the child pages of this page type thing, but im pretty sure that simply wont be flexible enough. I know its very JSP like, but it does seem like we could add on functionality for things such as deciding how many items should be within a list. The programmer builds his app to say heres a list of articles, but surley, its up to the designer to decide how many should be displayed on that page? given this snippet: class Articles { def list(max: Int) = { ... // fetch articles } } that it would then be sensible for the designer to be able to do: lift:articles.list max=5 / What is the feeling on this type of thing? I appreciate this could well be abused, but right now it strikes me that there are lots of situations where the designer doesnt have quite enough control over the (presentation) logic without coding scala (altering the snippet) Thoughts? Cheers Tim -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: A quick question
Marius, Back when I wrote the mapper stuff, there were a bunch of limitations of using vals: - Because of uniform access rules, the difference between val foo = new Thing ; def bar = foo was not possible to calculate. It looks like the compiler now stores things in a named field, so looking for method/fields with the same name that also inherit from Field should allow us to figure things out. - In the past if you had extra methods on a val field, they would not be visible to a caller. This has been relaxed because of structural types. On the plus side, there's a minor speed advantage to accessing vals, but objects are created lazily. See the enclosed code. Personally, I like to object stuff because I'm used to it and it also distinguishes the stuff to be persisted, but I'm not strongly wedded to keeping things the way they are. Thanks, David On Sun, Nov 30, 2008 at 8:17 AM, Marius Danciu [EMAIL PROTECTED]wrote: Hi Dave, Do you think it worth do goon this route? class Person extends Record[Person] { def meta = PersonMeta val firstName = new StringField(this, Marius) val lastName = new StringField(this, Danciu) } like using val-sfor fields, instead of object? ... Allowing this style, required only some minor updated in MetaRecord ro make it work. What do you think would be the downsides? Br's, Marius -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~--- ValObj.scala Description: Binary data
[Lift] Re: JPA and Record
- I'm pretty close to having a releasable version of the maven-scala-plugin that supports compiler plugins. - Adding integration between the maven-pom and eclipse is going to take some time (but is possible). I'm not sure about the netbeans/IntelliJ tools, but this could be an awkward integration for all of them. Don't know if that helps. (Personally I think compiler plugins are better for POCs). On Mon, Dec 1, 2008 at 1:22 PM, David Pollak [EMAIL PROTECTED]wrote: My 2 cents: - I'm strongly opposed to any compiler plugins as they (1) mean that IDEs will work less well and (2) they require some sort of installation (if they can be rolled into the Maven building stuff, it makes this objection go away) - I'm strongly opposed to mixing annotations and the Record stuff. It'll just make for wicked ugly looking code. I believe there are ways to use Record's deep knowledge of class layouts to generate data structures and/or XML to send to JPA to do the right thing. On Sun, Nov 30, 2008 at 7:45 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote: The whole point of integrating (and I use the word integrating here loosely) is so that there's a common form framework for people to use. Really, the point of Record as far as I can tell is to loosen and/or remove the tight coupling with the datastore, and in that sense Record is succeeding. As Tim points out, there are going to be people with existing JPA libraries and what we're trying to propose is a means for them to leverage their existing libraries alongside the nice work done in Record. As ugly as the boilerplate for delegation may seem, I don't see any better solution without adding significant complexity. I've done bytecode manipulation in the past and while it can be very handy, it makes things a lot more complex on the backend and I'm really trying to avoid complexity (this includes a compiler plugin, too). Delegation provides the cleanest approach I can come up with; it actually helps in the case where someone wants to use an existing JPA library because you could simply wrap an instance and delegate to it: class MyEntry extends Record[MyEntry] { var inner : RealEntry = _ object name extends StringField(this) with Delegation name.delegate(inner.name, inner.name = _) ... } By adding a few lines of boilerplate in each class you get validation, form generation, presentation HTML, JSON representation, etc. It's up to the end-user to determine whether these features are worth the cost of a few LoC. I'm not saying this is a perfect solution, just that I think that this is the best first cut at it. Also, no one is saying that people have to use JPA with Record. I'm assuming that the majority of new Lift apps will probably use Record/Mapper because they're simple, easy to use and quite capable of handling most data models. But for the people with existing JPA libraries, or for people who would like to use JPA for the additional features, compatibility with Java apps, etc, I'd like to have a better answer than an absolute Don't use Record or Switch to Record. Derek On Sun, Nov 30, 2008 at 1:40 AM, Marius [EMAIL PROTECTED] wrote: I totally agree with you Viktor! ... although it seems like a workable solution in this case a Record contains to distinct entities to represent the same data and of course the boilerplate. It was mentioned above compiler plugins which I expressed my opinion about it (I'd stay away) but there might be another way to alter the bytecode at runtime. I'm talking about dynamic class weaving. Basically it is a class loader that before returning the actual updated class. Kind of what AspectJ is doing. A while ago a wrote a bytecode level manipulation framework and combined with a special classloader I was able to modify a class dynamically and use it. Of course there are caveats: 1. Complexity induced by bytecode level manipulation 2. How a dynamic class loader cope with container's classloader that essentially loads the web application. Of course it would delegate the loading to the container's classloader but these modifiable classes should probably not live in WEB-INF/classes or WEB-INF/lib folder. But all in all I'm not convinced that this effort really worth it. AFAIC I still don;t get the whole point of integrating Record/Field with JPA. If someone wants to switch easily from JPA to Record or vice- versa, to have this flexibility perhaps consider to abstract these layers from the rest of the application and using other persistence technologies would not affect the application business logic ... but this is about how the appliation is designed etc. Br's, Marius On Nov 30, 9:56 am, Viktor Klang [EMAIL PROTECTED] wrote: IMHO: @Column{val name = my_name} var name : String = _ object nameField extends StringField(this,100) with Delegated nameField.delegate(name, name = _) That's just too much boilerplate.
[Lift] Re: JPA and Record
On Dec 1, 8:22 pm, David Pollak [EMAIL PROTECTED] wrote: My 2 cents: - I'm strongly opposed to any compiler plugins as they (1) mean that IDEs will work less well and (2) they require some sort of installation (if they can be rolled into the Maven building stuff, it makes this objection go away) I'm not sure about people hat love lift but hate maven (if there are any) ... would we want to force them to love maven if they want JPA Record :) ? - I'm strongly opposed to mixing annotations and the Record stuff. It'll just make for wicked ugly looking code. I believe there are ways to use Record's deep knowledge of class layouts to generate data structures and/or XML to send to JPA to do the right thing. On Sun, Nov 30, 2008 at 7:45 AM, Derek Chen-Becker [EMAIL PROTECTED]wrote: The whole point of integrating (and I use the word integrating here loosely) is so that there's a common form framework for people to use. Really, the point of Record as far as I can tell is to loosen and/or remove the tight coupling with the datastore, and in that sense Record is succeeding. As Tim points out, there are going to be people with existing JPA libraries and what we're trying to propose is a means for them to leverage their existing libraries alongside the nice work done in Record. As ugly as the boilerplate for delegation may seem, I don't see any better solution without adding significant complexity. I've done bytecode manipulation in the past and while it can be very handy, it makes things a lot more complex on the backend and I'm really trying to avoid complexity (this includes a compiler plugin, too). Delegation provides the cleanest approach I can come up with; it actually helps in the case where someone wants to use an existing JPA library because you could simply wrap an instance and delegate to it: class MyEntry extends Record[MyEntry] { var inner : RealEntry = _ object name extends StringField(this) with Delegation name.delegate(inner.name, inner.name = _) ... } By adding a few lines of boilerplate in each class you get validation, form generation, presentation HTML, JSON representation, etc. It's up to the end-user to determine whether these features are worth the cost of a few LoC. I'm not saying this is a perfect solution, just that I think that this is the best first cut at it. Also, no one is saying that people have to use JPA with Record. I'm assuming that the majority of new Lift apps will probably use Record/Mapper because they're simple, easy to use and quite capable of handling most data models. But for the people with existing JPA libraries, or for people who would like to use JPA for the additional features, compatibility with Java apps, etc, I'd like to have a better answer than an absolute Don't use Record or Switch to Record. Derek On Sun, Nov 30, 2008 at 1:40 AM, Marius [EMAIL PROTECTED] wrote: I totally agree with you Viktor! ... although it seems like a workable solution in this case a Record contains to distinct entities to represent the same data and of course the boilerplate. It was mentioned above compiler plugins which I expressed my opinion about it (I'd stay away) but there might be another way to alter the bytecode at runtime. I'm talking about dynamic class weaving. Basically it is a class loader that before returning the actual updated class. Kind of what AspectJ is doing. A while ago a wrote a bytecode level manipulation framework and combined with a special classloader I was able to modify a class dynamically and use it. Of course there are caveats: 1. Complexity induced by bytecode level manipulation 2. How a dynamic class loader cope with container's classloader that essentially loads the web application. Of course it would delegate the loading to the container's classloader but these modifiable classes should probably not live in WEB-INF/classes or WEB-INF/lib folder. But all in all I'm not convinced that this effort really worth it. AFAIC I still don;t get the whole point of integrating Record/Field with JPA. If someone wants to switch easily from JPA to Record or vice- versa, to have this flexibility perhaps consider to abstract these layers from the rest of the application and using other persistence technologies would not affect the application business logic ... but this is about how the appliation is designed etc. Br's, Marius On Nov 30, 9:56 am, Viktor Klang [EMAIL PROTECTED] wrote: IMHO: [EMAIL PROTECTED] name = my_name} var name : String = _ object nameField extends StringField(this,100) with Delegated nameField.delegate(name, name = _) That's just too much boilerplate. For me, who went to scala to lose boilerplate, this is not a viable solution. Unfortunately the JPA spec is kind of weak when it comes to adaptation, so my suggestion to make it work
[Lift] new to lift ... horizontal scaling of databases?
Hi ... new to Scala and Lift. I'm having trouble understanding how to think about a project with a horizontally scaled database. I guess people call this sharding these days? My existing app uses PHP, no framework, and no O-R mapping. It's all PHP/MySQL with SQL statements. Some O-R mappers seem to partially support sharding and I'm wondering if Lift's does? Adding AJAX to this app is not going to be easy, and I'm considering a rewrite now that I know a little more about what I'm doing. Plus, I'm kind of bored with PHP. When it comes to database access, does Lift avoid the scalability problems I hear Rails has? Or, is there a better way do horizontally scale these days? I see that SQL Server supports distributed partition views, which I'm still learning about. Something at the database server side of things which transparently handles the horizontal scale-out would be great. Not sure if distributed partition views actually do this though. This also looks like it'd make my life easier: http://www.hivedb.org/ thanks, Bob --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Using TemplatePf for JPA powered templates
When I use a nested set, I make it like a combination of nested set and a simple tree. So in my database, I have: idparent_idlftrgtname -- 1 NULL 1 20Electronics 21 2 9Televisions 32 3 4Tube 42 5 6LCD 52 7 8Plasma 61 10 19Portable Electronics 76 11 14MP3 Players 87 12 13Flash 96 15 16CD Players 106 17 182-way Radios Then I get things the following way: For MP3 Players (#7): -- Ancestors select * from mytable where lft 11 and rgt 14; -- Ancestors and self select * from mytable where lft = 11 and rgt = 14; -- Parent select * from mytable where id = 6; -- Siblings and self select * from mytable where parent_id = 6; -- Siblings select * from mytable where parent_id = 6 and id 7; -- Siblings on the left select * from mytable where parent_id = 6 and rgt 11; -- Siblings on the right select * from mytable where parent_id = 6 and lft 14; -- Immediate children select * from mytable where parent_id = 7; -- Descendants and self select * from mytable where lft = 11 and rgt = 14; -- Descendants select * from mytable where lft 11 and rgt 14; In JPA/Hibernate, you'd have to modify this slightly. Each node in the tree would have a parent: Node attribute and a children: java.util.Set[Node] attribute. So then for example to get immediate children you would do: from Node n where n.parent.id = :id (But you could just access them through node.children as well.) Is this helping at all? Chas. Tim Perrett wrote: Im not sure I follow? Can you use this diagram to try and explain?: http://dev.mysql.com/tech-resources/articles/hierarchical-data-4.png If you wanted to select the direct children of 'electronics', how would one go about doing that? Is there a simpler way than all that HQL? Cheers Tim On Dec 1, 10:28 am, Charles F. Munat [EMAIL PROTECTED] wrote: Are you including a link to the parent node or are you just using the left and right values to figure out which nodes are children? I always include a foreign key to the parent so I can just select the children of that parent directly. Then to get all descendants, I use the left and right values. Similarly, to get the parent I use the foreign key, to get all ancestors, I use the left/right values. Does this help? (Sometimes I also include a calculated field called level which indicates how far away I am from the root node. It's a simple matter of counting the ancestors, but you have to remember to update it on moves. The level field is very useful if you want to go, say, two levels deep on children, or to parent and grandparent, but not great-grandparent.) Chas. Tim Perrett wrote: On Dec 1, 9:21 am, Charles F. Munat [EMAIL PROTECTED] wrote: Will do, if I figure it out. But my comment wasn't complaining. I am honestly mystified. Am I the only one using trees in Hibernate? Is there a tree library in Scala that I'm missing? What the heck does everyone else do? It just blows my mind. I found someone's contribution on Hibernate JIRA for handling sets, but it never seems to make it into core or the proper distro; it does seem odd its not in there. Anyway, the HQL problem I mentioned last night... I have the following HQL, which is just a slight mod from what was in that mysql article; effectivly I want to list all the children of a single leaf: SELECT node.name, (COUNT(parent.name) - (sub_tree.depth + 1)) AS depth FROM Content AS node, Content AS parent, Content AS sub_parent, ( SELECT node.name, (COUNT(parent.name) - 1) AS depth FROM Content AS node, Content AS parent WHERE node.lft BETWEEN parent.lft AND parent.rft AND node.name = :leaf GROUP BY node.name ORDER BY node.lft ) AS sub_tree WHERE node.lft BETWEEN parent.lft AND parent.rft AND node.lft BETWEEN sub_parent.lft AND sub_parent.rft AND sub_parent.name = sub_tree.name GROUP BY node.name HAVING depth = 1 ORDER BY node.lft However, it bombs on the sub-query in the SELECT ... FROM ... subquery statement im guessing you guys are using get all leaf nodes type queries, so what are you doing instead of this? Cheers Tim --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Using TemplatePf for JPA powered templates
On Sun, Nov 30, 2008 at 6:27 AM, Derek Chen-Becker [EMAIL PROTECTED] wrote: If you're heavily skewed towards reads and not writes (as it seems in the case of a CMS), you might want to look at Celko nested sets: http://www.intelligententerprise.com/001020/celko.jhtml http://dev.mysql.com/tech-resources/articles/hierarchical-data.html If you're going down this path, you should also read some of Vadim Tropashko's work on hierarchical SQL approaches. This blog post of his offers a good comparison of adjacency relations, nested sets, materialized paths, and nested intervals via matrix encoding: http://vadimtropashko.wordpress.com/2008/08/09/one-more-nested-intervals-vs-adjacency-list-comparison Trees in SQL http://www.dbazine.com/oracle/or-articles/tropashko4 http://www.dbazine.com/oracle/or-articles/tropashko5 Nested Intervals Tree Encoding with Continued Fractions http://arxiv.org/pdf/cs.DB/0402051 And here's an example circa 2004 Postgres There are some other options to consider, though. 1. You might be using a database that implements Recursive SQL 2. You might consider something like JCR instead here's an example of scaffolding for nodes with scalascii art: http://dev.day.com/microsling/content/blogs/main/scalajcr2.html 3. Why doesn't a template/metadata name without hierarchy work in your example? Shawn --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Bug in Chat example?
I hate to nag, but does anyone have any idea what's up with the bug in the chat example I e-mailed about a while ago? I've been playing around with the ask/answer functionality in the interim, and (although it's quite possible that I'm missing something) I can't get it to work at all. The first time I call ask it works as I'd expect, but the second time it doesn't seem to have any effect (the page remains as it was before calling ask). Which is consistent with what I see in the chat example. Does anyone have any examples of ask/answer other than the chat example? Of course, none of this stops me from being able to implement comet functionality (and Lift is still the best framework I've come across for this purpose, even without ask/answer). But being able to use ask/ answer would be nice :-) On Nov 21, 6:27 pm, Paul Butcher [EMAIL PROTECTED] wrote: So I'm gradually getting my head around lift, in particular the comet support. I'm currently trying to understand how the Chat example's AskName functionality works. I believe that I've uncovered a bug, but I'm not sure why it doesn't work or how to fix it. The Chat class's localSetup method is clearly trying to ensure that the name entered is at least 3 characters long: override def localSetup { if (userName.length == 0) { ask(new AskName, what's your username) { case s: String if (s.trim.length 2) = userName = s.trim; reRender(true) case s = localSetup; reRender(false) } } } But this doesn't seem to work. If you enter a name longer than 2 characters everything works just fine. If, on the other hand, you enter a shorter one it doesn't let you proceed (which is good), but if you subsequently enter a longer name, it still doesn't let you proceed. I'm pretty sure that this isn't some artifact of my local installation as I see the same behavior here: http://demo.liftweb.net/chat I can see what the code is trying to achieve. Why isn't it working? Thanks in advance! Paul. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: JPA find or create new
Thanks. Types are still largely a mystery to me, but this works just fine. Chas. Derek Chen-Becker wrote: Because it's type erasure I don't think I can do a generic new inside the methods, but the findOne method does return a Can. That means that you were actually pretty close in your demo code. Here's what it could look like: val user: User = Model.createNamedQuery[User]( findUserByUsername, username - hal ).findOne or (new User) Derek On Mon, Dec 1, 2008 at 2:24 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: That will probably work. I was thinking it would be nice to build in a method findOrNew that would do it for me... but it looks like that might involve some sort of implicit manifest thingy, so I don't know. Chas. Viktor Klang wrote: On Mon, Dec 1, 2008 at 7:12 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Is there a simple way in JPA/Lift to query to retrieve a single object from the database, assign it to a val if found, or create a new object of that type and assign it instead of there is no such object in the database? Sort of a... val user: User = Model.createNamedQuery( findUserByUsername, username - hal ).findOr(new User()) (Can ! (yourQuery.uniqueResult)).openOr(new User()) Should work? or something like that? That would be very useful. Thanks, Chas. -- Viktor Klang Senior Systems Analyst --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: new to lift ... horizontal scaling of databases?
On Sun, Nov 30, 2008 at 6:07 PM, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: Hi ... new to Scala and Lift. I'm having trouble understanding how to think about a project with a horizontally scaled database. I guess people call this sharding these days? My existing app uses PHP, no framework, and no O-R mapping. It's all PHP/MySQL with SQL statements. Some O-R mappers seem to partially support sharding and I'm wondering if Lift's does? Adding AJAX to this app is not going to be easy, and I'm considering a rewrite now that I know a little more about what I'm doing. Plus, I'm kind of bored with PHP. When it comes to database access, does Lift avoid the scalability problems I hear Rails has? Lift has built in DB sharding. You can have multiple RDBMS connection identifiers. Each record has its connection identifier associated with it (where it came from) and there's a place in each MetaModel to insert a function to calculate the connection identifier given a record to be saved or a primary key to be recalled. With that being said, Rails' scaling issues have some to do with assuming infinite RDBMS capacity or that memcached will solve all woes. Rails also scales badly because the MRI (Matz Ruby Implementation) sucks badly and a fair number of MRI instances fail or snarf all available system resources. Or, is there a better way do horizontally scale these days? I see that SQL Server supports distributed partition views, which I'm still learning about. Something at the database server side of things which transparently handles the horizontal scale-out would be great. Not sure if distributed partition views actually do this though. I'm a very big fan of using Actors as a smart caching mechanism. With the Skittr example, I scaled a Twitter-like service to 1M users on a dual process box. With all of your questions and updates going through Actors, you've got a lot of fine-grains control over caching policies, etc. But we're also talking about scaling to Twitter/Facebook type traffic. For the normal 100K users, 1K active users kinda sites, you don't have to worry much. This also looks like it'd make my life easier: http://www.hivedb.org/ Gaaak. If you're hell-bent on staying with SQL, I'd strongly suggest using something built on top of PostgreSQL. thanks, Bob -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Inserting/deleting table rows with AJAX
I have a table in which each row represents an object in the database, with each cell in the row an input bound to an attribute of the object. I want to be able to add rows (with new, blank objects) and delete rows (deleting both the row on the page and the associated object in the database). I've set up a snippet method to insert a new row. It returns the table row with all the inputs nicely bound. How do I call this with AJAX and insert the NodeSeq into the current table? At the end of the row I have a [-] ajaxButton. It should delete that row and the associated object using AJAX, but when I click it, the page reloads and nothing changes. I've looked through the jQuery Lift stuff. Am I using the ajaxButton wrong? Why would the page reload? And what methods are appropriate to both updating an object (Model.remove(obj)) and deleting the row ($('#rowid').remove())? Any help appreciated. Chas. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Inserting/deleting table rows with AJAX
Charles, If you're planning to deploy this app in IE, you may have an issue. My experience with IE is that adding/removing tr doesn't always work well. :-( What is most likely happening is that your button is inside a form. It turns out that there's a race condition where sometimes the XmlHttpRequest will get fired first and sometimes the form will be submitted first. Lemme see if I can do something fancy with returning false from the button ajax request to the event doesn't bubble up. Thanks, David On Mon, Dec 1, 2008 at 1:08 PM, Charles F. Munat [EMAIL PROTECTED] wrote: I have a table in which each row represents an object in the database, with each cell in the row an input bound to an attribute of the object. I want to be able to add rows (with new, blank objects) and delete rows (deleting both the row on the page and the associated object in the database). I've set up a snippet method to insert a new row. It returns the table row with all the inputs nicely bound. How do I call this with AJAX and insert the NodeSeq into the current table? At the end of the row I have a [-] ajaxButton. It should delete that row and the associated object using AJAX, but when I click it, the page reloads and nothing changes. I've looked through the jQuery Lift stuff. Am I using the ajaxButton wrong? Why would the page reload? And what methods are appropriate to both updating an object (Model.remove(obj)) and deleting the row ($('#rowid').remove())? Any help appreciated. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Joins in Lift mapper
On Thu, Oct 9, 2008 at 9:46 AM, Charles F. Munat [EMAIL PROTECTED] wrote: Is it possible to do joins in Lift Mapper? For example, I have a Category class that has a name and position (an int). I have a Document class that has a name, a URI, and a Category. I want to query the database and get back all the Documents *and their associated Categories* and I'd like to sort the results by the Category.position. Ideas? This is one of the places that having a strongly typed language is less than optimal. Because we can't return a Document or a (Document, Category) depending on the query, this kind of query is difficult. So, the best I can suggest is running two queries (as I suggested on another thread today.) Sorry. David Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Tools
Charles, I use NetBeans and a whole lot of printlns. In general, if you've got a case class or Scala collections, the toString methods are pretty descriptive of what's going on. I have heard tell that it's possible to hook the NetBeans debugger up to a running Jetty instance and do breakpoints in the Scala code and inspect variables. I have not tried it myself. Thanks, David On Wed, Oct 15, 2008 at 8:22 AM, Charles F. Munat [EMAIL PROTECTED] wrote: One of the hardest parts about learning Lift and Scala is not really know what objects look like. Things get pretty complicated and it's difficult to remember what's in what. It would be very nice to be able to step through Lift and see exactly what is where in memory and how things change, etc. Normally, I'd use an IDE for this. I used to work in C#, and Visual Studio has some very nice tools. I can step through the program, look in any variable to see what's in it, etc. In Ruby, I use TextMate. I'm not very good at it, so most of my techniques are more rudimentary. But Rails has a nice method called debug. I can spit out what's in a variable by just adding: %= debug @my_variable % to a template. Lift, however, eschews code in templates. I created a Test snippet to do the same thing, but I'm having trouble understanding reflection in Scala. In Ruby, object.inspect or object.to_yaml can give me a pretty good picture of the object. I've tried Lift in Eclipse, NetBeans, and JEdit and none of them seem to work very well. Out of memory errors are common, or I just can't seem to get it set up properly. What tricks are others using to make it easier to see what's going on in Lift? Is there a way to step through a request and see exactly what happens and in what order? I would kill for that ability. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Minor differences between mapper and record
Hi, I'm writing the chapter on Mapper/Record right now and I was wondering why there have been small name changes between the two frameworks. Things like 1. MappedField.validations vs. Field.validators 2. MappedField.asHtml vs. Field.asXHtml (and Field.toXHtml, which seems redundant) If these are still in flux I'll just leave it alone and make a task for myself to check back later, but in general I'd say sticking with the Mapper method names would help the transition unless there's a strong desire to rename things. Derek --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Tools
I've done it in Eclipse and I'm assuming it would be similarly easy in NetBeans. There's a good article on setting up Maven remote debugging with Jetty here: http://www.mojavelinux.com/blog/archives/2007/03/remote_debugging_with_jetty/ Derek On Mon, Dec 1, 2008 at 2:43 PM, David Pollak [EMAIL PROTECTED]wrote: Charles, I use NetBeans and a whole lot of printlns. In general, if you've got a case class or Scala collections, the toString methods are pretty descriptive of what's going on. I have heard tell that it's possible to hook the NetBeans debugger up to a running Jetty instance and do breakpoints in the Scala code and inspect variables. I have not tried it myself. Thanks, David On Wed, Oct 15, 2008 at 8:22 AM, Charles F. Munat [EMAIL PROTECTED] wrote: One of the hardest parts about learning Lift and Scala is not really know what objects look like. Things get pretty complicated and it's difficult to remember what's in what. It would be very nice to be able to step through Lift and see exactly what is where in memory and how things change, etc. Normally, I'd use an IDE for this. I used to work in C#, and Visual Studio has some very nice tools. I can step through the program, look in any variable to see what's in it, etc. In Ruby, I use TextMate. I'm not very good at it, so most of my techniques are more rudimentary. But Rails has a nice method called debug. I can spit out what's in a variable by just adding: %= debug @my_variable % to a template. Lift, however, eschews code in templates. I created a Test snippet to do the same thing, but I'm having trouble understanding reflection in Scala. In Ruby, object.inspect or object.to_yaml can give me a pretty good picture of the object. I've tried Lift in Eclipse, NetBeans, and JEdit and none of them seem to work very well. Out of memory errors are common, or I just can't seem to get it set up properly. What tricks are others using to make it easier to see what's going on in Lift? Is there a way to step through a request and see exactly what happens and in what order? I would kill for that ability. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Inserting/deleting table rows with AJAX
Hmm. Crap. Damn that IE. Well, I have something working in Firefox on Mac for the button. It's probably more complicated than it needs to be... def ajaxRemove(name: String, func: AFuncHolder, attrs: Tuple2[String, String]*): Elem = { val funcName = mapFunc(func) (input type=button/) % (value - name) % (onclick - (makeAjaxCall(JsRaw(' + funcName+='+this.checked)) + ; return false)) % (class - removeButton) % getAttrs(attrs: _*) } Then: td class=button{FH.ajaxRemove(-, () = { val x = Model.getReference[X](classOf[X], tp.id) survey.technicalPotentials.remove(x) Model.merge(survey) Model.remove(x) Model.flush() Run($('#tp + tp.id.toString + ').hide().remove();) })}/td #tp + tp.id.toString is the id of the tr attribute. I'll crank up the virtual machine and test it in IE. Thanks for looking at this. I could conceivably hide the row and delete all the individual inputs (or maybe just hide the row), but that seems pretty kludgy. Chas. David Pollak wrote: Charles, If you're planning to deploy this app in IE, you may have an issue. My experience with IE is that adding/removing tr doesn't always work well. :-( What is most likely happening is that your button is inside a form. It turns out that there's a race condition where sometimes the XmlHttpRequest will get fired first and sometimes the form will be submitted first. Lemme see if I can do something fancy with returning false from the button ajax request to the event doesn't bubble up. Thanks, David On Mon, Dec 1, 2008 at 1:08 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I have a table in which each row represents an object in the database, with each cell in the row an input bound to an attribute of the object. I want to be able to add rows (with new, blank objects) and delete rows (deleting both the row on the page and the associated object in the database). I've set up a snippet method to insert a new row. It returns the table row with all the inputs nicely bound. How do I call this with AJAX and insert the NodeSeq into the current table? At the end of the row I have a [-] ajaxButton. It should delete that row and the associated object using AJAX, but when I click it, the page reloads and nothing changes. I've looked through the jQuery Lift stuff. Am I using the ajaxButton wrong? Why would the page reload? And what methods are appropriate to both updating an object (Model.remove(obj)) and deleting the row ($('#rowid').remove())? Any help appreciated. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Minor differences between mapper and record
On Mon, Dec 1, 2008 at 1:44 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: Hi, I'm writing the chapter on Mapper/Record right now and I was wondering why there have been small name changes between the two frameworks. Things like 1. MappedField.validations vs. Field.validators 2. MappedField.asHtml vs. Field.asXHtml (and Field.toXHtml, which seems redundant) If these are still in flux I'll just leave it alone and make a task for myself to check back later, but in general I'd say sticking with the Mapper method names would help the transition unless there's a strong desire to rename things. Some of the Mapper names suck. Renaming them would be good. Do you want to own the task of choosing the method names that suck and proposing changes and marking the names that don't suck as don't change? Derek -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Compile problems with lift
I'm not sure whether it is just me, but I seem to be stumbling on the Scala compiler exceptions whatever I do. First there was one when creating specs that I mailed earlier, and now I get compile problems when I changed Boot-class. I have changed Boot-class as follows. Idea is to allow different database based on runlevel and also cleaning up the tables when doing tests. I have tried to change models to List[KeyedMapper[Any, Any]] but then I just get different set of exceptions. If I expand models by hand to schemify and cleanTables, it works just fine. Should I just send report to scala lang -list or am I doing something wrong? class Boot { def database = (org.apache.derby.jdbc.EmbeddedDriver, jdbc:derby:liftdb_+Props.mode.toString.toLowerCase+;create=true) def dbVendor = new ConnectionManager { def newConnection(name: ConnectionIdentifier): Can[Connection] = { try { val (driver, databaseString) = database Class.forName(driver) Full(DriverManager.getConnection(databaseString)) } catch { case e : Exception = e.printStackTrace; Empty } } def releaseConnection(conn: Connection) {conn.close} } val models = List(User, Game, GameUser, Hull, Ship, StarSystem) def schemify { models foreach { m = Schemifier.schemify(true, Log.infoF _, m) } } def cleanTables { models foreach { m = m.bulkDelete_!!() } } def boot { Log.info(Running boot at runmode + Props.mode) if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager (DefaultConnectionIdentifier, dbVendor) Props.mode match { case Props.RunModes.Development = schemify case Props.RunModes.Test = schemify cleanTables case _ = } ... I get this kind of stack trace: [WARNING] Exception in thread main java.lang.OutOfMemoryError: Java heap space [WARNING] at scala.tools.nsc.util.HashSet.growTable (HashSet.scala:58) [WARNING] at scala.tools.nsc.util.HashSet.addEntry(HashSet.scala: 41) [WARNING] at scala.tools.nsc.symtab.Types$class.unique (Types.scala:2221) [WARNING] at scala.tools.nsc.symtab.Types$class.mkThisType (Types.scala:1910) [WARNING] at scala.tools.nsc.symtab.SymbolTable.mkThisType (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Symbols$ClassSymbol.thisType (Symbols.scala:1540) [WARNING] at scala.tools.nsc.symtab.Types$class.copyRefinedType (Types.scala:1986) [WARNING] at scala.tools.nsc.symtab.SymbolTable.copyRefinedType (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Types$TypeMap.mapOver (Types.scala:2324) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2708) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2575) [WARNING] at scala.tools.nsc.symtab.Types$TypeMap.mapOver (Types.scala:2343) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2708) [WARNING] at scala.tools.nsc.symtab.Types$Type.asSeenFrom (Types.scala:399) [WARNING] at scala.tools.nsc.symtab.Types$Type.memberType (Types.scala:429) [WARNING] at scala.tools.nsc.symtab.Types$Type.findMember (Types.scala:696) [WARNING] at scala.tools.nsc.symtab.Types$Type.nonPrivateMember (Types.scala:378) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$29.apply (Types.scala:3984) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$29.apply (Types.scala:3983) [WARNING] at scala.List.map(List.scala:805) [WARNING] at scala.tools.nsc.symtab.Types$class.lubsym$1 (Types.scala:3983) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$31.apply (Types.scala:4015) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$31.apply (Types.scala:4010) [WARNING] at scala.List.foreach(List.scala:834) [WARNING] at scala.tools.nsc.symtab.Types$class.lub0$1 (Types.scala:4010) [WARNING] at scala.tools.nsc.symtab.Types$class.lub(Types.scala: 4034) [WARNING] at scala.tools.nsc.symtab.SymbolTable.lub (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$41.apply (Types.scala:4180) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$41.apply (Types.scala:4171) [WARNING] at scala.List$.map2(List.scala:326) [WARNING] at scala.tools.nsc.symtab.Types $class.mergePrefixAndArgs(Types.scala:4170) [WARNING] at scala.tools.nsc.symtab.SymbolTable.mergePrefixAndArgs (SymbolTable.scala:12) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SHtml form inputs and attributes/labels
Charles, Thanks for the suggestion. I've just checked up code that looks something like yours: def ajaxButton(text: NodeSeq, func: () = JsCmd, attrs: (String, String)*): Elem = attrs.foldLeft(button onclick={makeAjaxCall(Str(mapFunc(func)+=true)).toJsCmd+; return false;} {text}/button)(_ % _) All the various form element creation methods take an attrs vararg. Also, note the use of foldLeft Thanks, David On Tue, Nov 18, 2008 at 1:25 AM, Charles F. Munat [EMAIL PROTECTED] wrote: So I copied SHtml over for fun and renamed it FH (form helper). Then I tried messing with textarea first, just for fun. This can probably be done much better, but this works just fine: private def getAttrs(attrs: Tuple2[String, String]*) : MetaData = { attrs.toList match { case x :: xs = new UnprefixedAttribute(x._1, x._2, getAttrs(xs: _*)) case _ = Null } } def textarea(value: String, func: String = Any, attrs: Tuple2[String, String]*): Elem = textarea_*(value, SFuncHolder(func), attrs: _*) def textarea_*(value: String, func: AFuncHolder, attrs: Tuple2[String, String]*): Elem = { (textarea name={mapFunc(func)} rows=8 cols=40{value}/textarea) % getAttrs(attrs: _*) } Now I can call it like this: FH.textarea(contact.message, contact.message = _, (id, myId), (class, myClass), (rows, 12)) And I get this: textarea id=myId class=myClass rows=12 cols=40/textarea (I added default rows and cols attributes because they are required for valid XHTML.) For what it's worth, this works much better for me. Chas. Charles F. Munat wrote: Ha. Great minds stink alike. I just discovered this little setback (after adding id attributes to about fifty checkboxes -- note to self: check one before doing them all). I've been messing with the map but it's messing with me. I can grab the right node pretty easily, but then I can't seem to add the MetaData. If you're looking to add an id, you can use checkbox_id: SHtml.checkbox_id(user.isStupid, user.isStupid = _, Full(isStupid)) which adds id=isStupid to the checkbox input. Chas. Derek Chen-Becker wrote: For a really neat trick, how would I set the ID for a checkbox? The SHtml checkbox method returns a NodeSeq. I suppose I could just do a map, but I was wondering if there was a simpler way. Thanks, Derek On Mon, Nov 17, 2008 at 4:54 PM, David Pollak [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Mon, Nov 17, 2008 at 3:41 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Added: http://liftweb.net/index.php/FAQ#How_do_I_add_attributes_to_form_fields_created_with_SHtml_methods.3F Awesome! Thanks! Chas. Jorge Ortiz wrote: Oops, it might be: SHtml.text(user.name http://user.name http://user.name, user.name http://user.name http://user.name = _) % (size - 24) % (maxlength - 48) % (id - user_name) % (title - Enter your name) One or both of those should work. --j On Mon, Nov 17, 2008 at 12:27 PM, Jorge Ortiz [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Try: SHtml.text(user.name http://user.name http://user.name, user.name http://user.name http://user.name = _) % (size, 24) % (maxlength, 48) % (id, user_name) % (title, Enter your name) That should work. --j On Mon, Nov 17, 2008 at 12:21 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I spend a lot of time writing % new UnprefixedAttribute(...) to add attributes to SHtml form elements (input, textarea, select, etc.). It would be nice if the relevant SHtml methods would permit optional extra parameters in the form of tuples where contents are name-value pairs that get translated to attributes. I don't think this would be a breaking change. In other words, instead of: SHtml.text(user.name http://user.name http://user.name, user.name http://user.name http://user.name = _) % new UnprefixedAttribute(size, 24, new UnprefixedAttribute(maxlength, 48,
[Lift] Re: Compile problems with lift
The exception is an out of memory exception. What OS and RAM size are you running? On Mon, Dec 1, 2008 at 1:44 PM, Juha L [EMAIL PROTECTED] wrote: I'm not sure whether it is just me, but I seem to be stumbling on the Scala compiler exceptions whatever I do. First there was one when creating specs that I mailed earlier, and now I get compile problems when I changed Boot-class. I have changed Boot-class as follows. Idea is to allow different database based on runlevel and also cleaning up the tables when doing tests. I have tried to change models to List[KeyedMapper[Any, Any]] but then I just get different set of exceptions. If I expand models by hand to schemify and cleanTables, it works just fine. Should I just send report to scala lang -list or am I doing something wrong? class Boot { def database = (org.apache.derby.jdbc.EmbeddedDriver, jdbc:derby:liftdb_+Props.mode.toString.toLowerCase+;create=true) def dbVendor = new ConnectionManager { def newConnection(name: ConnectionIdentifier): Can[Connection] = { try { val (driver, databaseString) = database Class.forName(driver) Full(DriverManager.getConnection(databaseString)) } catch { case e : Exception = e.printStackTrace; Empty } } def releaseConnection(conn: Connection) {conn.close} } val models = List(User, Game, GameUser, Hull, Ship, StarSystem) def schemify { models foreach { m = Schemifier.schemify(true, Log.infoF _, m) } } def cleanTables { models foreach { m = m.bulkDelete_!!() } } def boot { Log.info(Running boot at runmode + Props.mode) if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager (DefaultConnectionIdentifier, dbVendor) Props.mode match { case Props.RunModes.Development = schemify case Props.RunModes.Test = schemify cleanTables case _ = } ... I get this kind of stack trace: [WARNING] Exception in thread main java.lang.OutOfMemoryError: Java heap space [WARNING] at scala.tools.nsc.util.HashSet.growTable (HashSet.scala:58) [WARNING] at scala.tools.nsc.util.HashSet.addEntry(HashSet.scala: 41) [WARNING] at scala.tools.nsc.symtab.Types$class.unique (Types.scala:2221) [WARNING] at scala.tools.nsc.symtab.Types$class.mkThisType (Types.scala:1910) [WARNING] at scala.tools.nsc.symtab.SymbolTable.mkThisType (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Symbols$ClassSymbol.thisType (Symbols.scala:1540) [WARNING] at scala.tools.nsc.symtab.Types$class.copyRefinedType (Types.scala:1986) [WARNING] at scala.tools.nsc.symtab.SymbolTable.copyRefinedType (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Types$TypeMap.mapOver (Types.scala:2324) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2708) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2575) [WARNING] at scala.tools.nsc.symtab.Types$TypeMap.mapOver (Types.scala:2343) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2708) [WARNING] at scala.tools.nsc.symtab.Types$Type.asSeenFrom (Types.scala:399) [WARNING] at scala.tools.nsc.symtab.Types$Type.memberType (Types.scala:429) [WARNING] at scala.tools.nsc.symtab.Types$Type.findMember (Types.scala:696) [WARNING] at scala.tools.nsc.symtab.Types$Type.nonPrivateMember (Types.scala:378) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$29.apply (Types.scala:3984) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$29.apply (Types.scala:3983) [WARNING] at scala.List.map(List.scala:805) [WARNING] at scala.tools.nsc.symtab.Types$class.lubsym$1 (Types.scala:3983) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$31.apply (Types.scala:4015) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$31.apply (Types.scala:4010) [WARNING] at scala.List.foreach(List.scala:834) [WARNING] at scala.tools.nsc.symtab.Types$class.lub0$1 (Types.scala:4010) [WARNING] at scala.tools.nsc.symtab.Types$class.lub(Types.scala: 4034) [WARNING] at scala.tools.nsc.symtab.SymbolTable.lub (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$41.apply (Types.scala:4180) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$41.apply (Types.scala:4171) [WARNING] at scala.List$.map2(List.scala:326) [WARNING] at scala.tools.nsc.symtab.Types $class.mergePrefixAndArgs(Types.scala:4170) [WARNING] at scala.tools.nsc.symtab.SymbolTable.mergePrefixAndArgs (SymbolTable.scala:12) -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message
[Lift] Re: Compile problems with lift
It might be the type checker getting confused. Try: val models: List[MetaMapper] = List(User, Game, GameUser, Hull, Ship, StarSystem) You can also call schemify with: Schemifier.schemify(true, Log.infoF _, models :_*) Instead of the foreach stuff --j On Mon, Dec 1, 2008 at 3:44 PM, Juha L [EMAIL PROTECTED] wrote: I'm not sure whether it is just me, but I seem to be stumbling on the Scala compiler exceptions whatever I do. First there was one when creating specs that I mailed earlier, and now I get compile problems when I changed Boot-class. I have changed Boot-class as follows. Idea is to allow different database based on runlevel and also cleaning up the tables when doing tests. I have tried to change models to List[KeyedMapper[Any, Any]] but then I just get different set of exceptions. If I expand models by hand to schemify and cleanTables, it works just fine. Should I just send report to scala lang -list or am I doing something wrong? class Boot { def database = (org.apache.derby.jdbc.EmbeddedDriver, jdbc:derby:liftdb_+Props.mode.toString.toLowerCase+;create=true) def dbVendor = new ConnectionManager { def newConnection(name: ConnectionIdentifier): Can[Connection] = { try { val (driver, databaseString) = database Class.forName(driver) Full(DriverManager.getConnection(databaseString)) } catch { case e : Exception = e.printStackTrace; Empty } } def releaseConnection(conn: Connection) {conn.close} } val models = List(User, Game, GameUser, Hull, Ship, StarSystem) def schemify { models foreach { m = Schemifier.schemify(true, Log.infoF _, m) } } def cleanTables { models foreach { m = m.bulkDelete_!!() } } def boot { Log.info(Running boot at runmode + Props.mode) if (!DB.jndiJdbcConnAvailable_?) DB.defineConnectionManager (DefaultConnectionIdentifier, dbVendor) Props.mode match { case Props.RunModes.Development = schemify case Props.RunModes.Test = schemify cleanTables case _ = } ... I get this kind of stack trace: [WARNING] Exception in thread main java.lang.OutOfMemoryError: Java heap space [WARNING] at scala.tools.nsc.util.HashSet.growTable (HashSet.scala:58) [WARNING] at scala.tools.nsc.util.HashSet.addEntry(HashSet.scala: 41) [WARNING] at scala.tools.nsc.symtab.Types$class.unique (Types.scala:2221) [WARNING] at scala.tools.nsc.symtab.Types$class.mkThisType (Types.scala:1910) [WARNING] at scala.tools.nsc.symtab.SymbolTable.mkThisType (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Symbols$ClassSymbol.thisType (Symbols.scala:1540) [WARNING] at scala.tools.nsc.symtab.Types$class.copyRefinedType (Types.scala:1986) [WARNING] at scala.tools.nsc.symtab.SymbolTable.copyRefinedType (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Types$TypeMap.mapOver (Types.scala:2324) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2708) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2575) [WARNING] at scala.tools.nsc.symtab.Types$TypeMap.mapOver (Types.scala:2343) [WARNING] at scala.tools.nsc.symtab.Types$AsSeenFromMap.apply (Types.scala:2708) [WARNING] at scala.tools.nsc.symtab.Types$Type.asSeenFrom (Types.scala:399) [WARNING] at scala.tools.nsc.symtab.Types$Type.memberType (Types.scala:429) [WARNING] at scala.tools.nsc.symtab.Types$Type.findMember (Types.scala:696) [WARNING] at scala.tools.nsc.symtab.Types$Type.nonPrivateMember (Types.scala:378) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$29.apply (Types.scala:3984) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$29.apply (Types.scala:3983) [WARNING] at scala.List.map(List.scala:805) [WARNING] at scala.tools.nsc.symtab.Types$class.lubsym$1 (Types.scala:3983) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$31.apply (Types.scala:4015) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$31.apply (Types.scala:4010) [WARNING] at scala.List.foreach(List.scala:834) [WARNING] at scala.tools.nsc.symtab.Types$class.lub0$1 (Types.scala:4010) [WARNING] at scala.tools.nsc.symtab.Types$class.lub(Types.scala: 4034) [WARNING] at scala.tools.nsc.symtab.SymbolTable.lub (SymbolTable.scala:12) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$41.apply (Types.scala:4180) [WARNING] at scala.tools.nsc.symtab.Types$$anonfun$41.apply (Types.scala:4171) [WARNING] at scala.List$.map2(List.scala:326) [WARNING] at scala.tools.nsc.symtab.Types $class.mergePrefixAndArgs(Types.scala:4170) [WARNING] at scala.tools.nsc.symtab.SymbolTable.mergePrefixAndArgs (SymbolTable.scala:12) --~--~-~--~~~---~--~~ You received this message
[Lift] Re: Strange behavior for /index.html
Derek, I've made the default behavior to not pass requests to the container (you can change the default in LiftRules.) That will address the raw template being displayed. Now... I have no idea why you need an index and a List(index) always matches for me. Are you using 0.10-SNAPSHOT? Thanks, David On Fri, Nov 21, 2008 at 4:08 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: I may be missing something here, but when I browse to the root of my webapp context: http://foo.com/context/ I get served up the index.html template *unprocessed*. If I use the full URL instead: http://foo.com/context/index I get the processed template. The only thing I did was add a SiteMap to my Boot: val entries = Menu(Loc(Home, index :: Nil, Home)) :: Menu(Loc(Search, search :: Nil, Search)) :: Nil If I change the Link from index to then I still get the unprocessed template if I use the first URL, and the second URL gives me a 404 error. If I add in a dummy menu entry instead: val entries = Menu(Loc(Home, index :: Nil, Home)) :: Menu(Loc(HomeEmpty, :: Nil, HomeEmpty, Hidden)) :: Menu(Loc(Search, search :: Nil, Search Studios)) :: Nil Then both URLs work, but that seems redundant since I thought David had stated before that URLs ending in / were automatically changed to .../index. I could have sworn that this worked with a single menu entry before, but my memory isn't always great. Another interesting thing to me is that I thought that without a Menu entry templates are denied (404) by default, so it's really strange that I'm getting the raw template back. Derek -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SHtml form inputs and attributes/labels
Gah, this is super-handy. Thanks Chas, Dave. On Dec 1, 5:41 pm, David Pollak [EMAIL PROTECTED] wrote: Charles, Thanks for the suggestion. I've just checked up code that looks something like yours: def ajaxButton(text: NodeSeq, func: () = JsCmd, attrs: (String, String)*): Elem = attrs.foldLeft(button onclick={makeAjaxCall(Str(mapFunc(func)+=true)).toJsCmd+; return false;} {text}/button)(_ % _) All the various form element creation methods take an attrs vararg. Also, note the use of foldLeft Thanks, David On Tue, Nov 18, 2008 at 1:25 AM, Charles F. Munat [EMAIL PROTECTED] wrote: So I copied SHtml over for fun and renamed it FH (form helper). Then I tried messing with textarea first, just for fun. This can probably be done much better, but this works just fine: private def getAttrs(attrs: Tuple2[String, String]*) : MetaData = { attrs.toList match { case x :: xs = new UnprefixedAttribute(x._1, x._2, getAttrs(xs: _*)) case _ = Null } } def textarea(value: String, func: String = Any, attrs: Tuple2[String, String]*): Elem = textarea_*(value, SFuncHolder(func), attrs: _*) def textarea_*(value: String, func: AFuncHolder, attrs: Tuple2[String, String]*): Elem = { (textarea name={mapFunc(func)} rows=8 cols=40{value}/textarea) % getAttrs(attrs: _*) } Now I can call it like this: FH.textarea(contact.message, contact.message = _, (id, myId), (class, myClass), (rows, 12)) And I get this: textarea id=myId class=myClass rows=12 cols=40/textarea (I added default rows and cols attributes because they are required for valid XHTML.) For what it's worth, this works much better for me. Chas. Charles F. Munat wrote: Ha. Great minds stink alike. I just discovered this little setback (after adding id attributes to about fifty checkboxes -- note to self: check one before doing them all). I've been messing with the map but it's messing with me. I can grab the right node pretty easily, but then I can't seem to add the MetaData. If you're looking to add an id, you can use checkbox_id: SHtml.checkbox_id(user.isStupid, user.isStupid = _, Full(isStupid)) which adds id=isStupid to the checkbox input. Chas. Derek Chen-Becker wrote: For a really neat trick, how would I set the ID for a checkbox? The SHtml checkbox method returns a NodeSeq. I suppose I could just do a map, but I was wondering if there was a simpler way. Thanks, Derek On Mon, Nov 17, 2008 at 4:54 PM, David Pollak [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Mon, Nov 17, 2008 at 3:41 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Added: http://liftweb.net/index.php/FAQ#How_do_I_add_attributes_to_form_fiel... Awesome! Thanks! Chas. Jorge Ortiz wrote: Oops, it might be: SHtml.text(user.name http://user.name http://user.name, user.name http://user.name http://user.name = _) % (size - 24) % (maxlength - 48) % (id - user_name) % (title - Enter your name) One or both of those should work. --j On Mon, Nov 17, 2008 at 12:27 PM, Jorge Ortiz [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Try: SHtml.text(user.name http://user.name http://user.name, user.name http://user.name http://user.name = _) % (size, 24) % (maxlength, 48) % (id, user_name) % (title, Enter your name) That should work. --j On Mon, Nov 17, 2008 at 12:21 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I spend a lot of time writing % new UnprefixedAttribute(...) to add attributes to SHtml form elements (input, textarea, select, etc.). It would be nice if the relevant SHtml methods would permit optional extra parameters in the form of tuples where contents are name-value pairs that get translated to attributes. I don't think this would be a breaking change. In other words, instead of: SHtml.text(user.name http://user.name http://user.name, user.name http://user.name http://user.name = _) % new UnprefixedAttribute(size, 24, new UnprefixedAttribute(maxlength, 48,
[Lift] Re: Minor differences between mapper and record
I would but I have so many other things going on right now I don't want to hold things up. I don't want to sound like I'm complaining about something and not wanting to actually deal with it but my plate is pretty full :( Derek On Mon, Dec 1, 2008 at 3:21 PM, David Pollak [EMAIL PROTECTED]wrote: On Mon, Dec 1, 2008 at 1:44 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: Hi, I'm writing the chapter on Mapper/Record right now and I was wondering why there have been small name changes between the two frameworks. Things like 1. MappedField.validations vs. Field.validators 2. MappedField.asHtml vs. Field.asXHtml (and Field.toXHtml, which seems redundant) If these are still in flux I'll just leave it alone and make a task for myself to check back later, but in general I'd say sticking with the Mapper method names would help the transition unless there's a strong desire to rename things. Some of the Mapper names suck. Renaming them would be good. Do you want to own the task of choosing the method names that suck and proposing changes and marking the names that don't suck as don't change? Derek -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Strange behavior for /index.html
I am using 0.10-SNAPSHOT, but let me do a clean jetty:run and make sure it's still doing it. Thanks! Derek On Mon, Dec 1, 2008 at 3:44 PM, David Pollak [EMAIL PROTECTED]wrote: Derek, I've made the default behavior to not pass requests to the container (you can change the default in LiftRules.) That will address the raw template being displayed. Now... I have no idea why you need an index and a List(index) always matches for me. Are you using 0.10-SNAPSHOT? Thanks, David On Fri, Nov 21, 2008 at 4:08 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: I may be missing something here, but when I browse to the root of my webapp context: http://foo.com/context/ I get served up the index.html template *unprocessed*. If I use the full URL instead: http://foo.com/context/index I get the processed template. The only thing I did was add a SiteMap to my Boot: val entries = Menu(Loc(Home, index :: Nil, Home)) :: Menu(Loc(Search, search :: Nil, Search)) :: Nil If I change the Link from index to then I still get the unprocessed template if I use the first URL, and the second URL gives me a 404 error. If I add in a dummy menu entry instead: val entries = Menu(Loc(Home, index :: Nil, Home)) :: Menu(Loc(HomeEmpty, :: Nil, HomeEmpty, Hidden)) :: Menu(Loc(Search, search :: Nil, Search Studios)) :: Nil Then both URLs work, but that seems redundant since I thought David had stated before that URLs ending in / were automatically changed to .../index. I could have sworn that this worked with a single menu entry before, but my memory isn't always great. Another interesting thing to me is that I thought that without a Menu entry templates are denied (404) by default, so it's really strange that I'm getting the raw template back. Derek -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Tools
I've tried twice to get NetBeans up and running on my MacBook Pro with 2 gigs of RAM. Both times I made the mistake of loading in the entire liftweb library. After that -- and even after I closed the liftweb master project -- NetBeans will lock up for long periods of time (e.g. ten minutes or more) every few keystrokes to do some sort of indexing. It is unbelievably frustrating. Closing and re-opening NetBeans, rebooting the computer, etc. do nothing to help. As far as I can tell, once that happens, NetBeans is toast. I plan to reinstall NetBeans (for the nth time) and *never* open Lift in it, but that sort of defeats the purpose a bit since perusing the source code is where it would be most useful. Maybe I need to set some variable differently? I tried enlarging the heap space and things just got worse. I don't seem to have a plethora of other choices. Chas. David Pollak wrote: Charles, I use NetBeans and a whole lot of printlns. In general, if you've got a case class or Scala collections, the toString methods are pretty descriptive of what's going on. I have heard tell that it's possible to hook the NetBeans debugger up to a running Jetty instance and do breakpoints in the Scala code and inspect variables. I have not tried it myself. Thanks, David On Wed, Oct 15, 2008 at 8:22 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: One of the hardest parts about learning Lift and Scala is not really know what objects look like. Things get pretty complicated and it's difficult to remember what's in what. It would be very nice to be able to step through Lift and see exactly what is where in memory and how things change, etc. Normally, I'd use an IDE for this. I used to work in C#, and Visual Studio has some very nice tools. I can step through the program, look in any variable to see what's in it, etc. In Ruby, I use TextMate. I'm not very good at it, so most of my techniques are more rudimentary. But Rails has a nice method called debug. I can spit out what's in a variable by just adding: %= debug @my_variable % to a template. Lift, however, eschews code in templates. I created a Test snippet to do the same thing, but I'm having trouble understanding reflection in Scala. In Ruby, object.inspect or object.to_yaml can give me a pretty good picture of the object. I've tried Lift in Eclipse, NetBeans, and JEdit and none of them seem to work very well. Out of memory errors are common, or I just can't seem to get it set up properly. What tricks are others using to make it easier to see what's going on in Lift? Is there a way to step through a request and see exactly what happens and in what order? I would kill for that ability. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Are there printable versions of any draft Lift books?
Are there printable versions of any draft Lift books? It would help me and would provide an easy basis for feedback to the authors if the Lift books currently in draft were made available for easy download and printing, in say PDF format. The Scala book early access process was both useful and efficient. I'm not expecting polished early drafts. Just something to read that will help enlighten me about Lift. Mal. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Tools
Cool. I hope I get time to read this really soon. Thanks! Chas. Derek Chen-Becker wrote: I've done it in Eclipse and I'm assuming it would be similarly easy in NetBeans. There's a good article on setting up Maven remote debugging with Jetty here: http://www.mojavelinux.com/blog/archives/2007/03/remote_debugging_with_jetty/ Derek On Mon, Dec 1, 2008 at 2:43 PM, David Pollak [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Charles, I use NetBeans and a whole lot of printlns. In general, if you've got a case class or Scala collections, the toString methods are pretty descriptive of what's going on. I have heard tell that it's possible to hook the NetBeans debugger up to a running Jetty instance and do breakpoints in the Scala code and inspect variables. I have not tried it myself. Thanks, David On Wed, Oct 15, 2008 at 8:22 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: One of the hardest parts about learning Lift and Scala is not really know what objects look like. Things get pretty complicated and it's difficult to remember what's in what. It would be very nice to be able to step through Lift and see exactly what is where in memory and how things change, etc. Normally, I'd use an IDE for this. I used to work in C#, and Visual Studio has some very nice tools. I can step through the program, look in any variable to see what's in it, etc. In Ruby, I use TextMate. I'm not very good at it, so most of my techniques are more rudimentary. But Rails has a nice method called debug. I can spit out what's in a variable by just adding: %= debug @my_variable % to a template. Lift, however, eschews code in templates. I created a Test snippet to do the same thing, but I'm having trouble understanding reflection in Scala. In Ruby, object.inspect or object.to_yaml can give me a pretty good picture of the object. I've tried Lift in Eclipse, NetBeans, and JEdit and none of them seem to work very well. Out of memory errors are common, or I just can't seem to get it set up properly. What tricks are others using to make it easier to see what's going on in Lift? Is there a way to step through a request and see exactly what happens and in what order? I would kill for that ability. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Inserting/deleting table rows with AJAX
Will do. Thanks. Chas. David Pollak wrote: Charles, I just checked in code that has a return false at the end of ajaxButton. If you've pulled the Lift source from GitHub, please do a fresh pull and an mvn clean install on Lift and then give it a try. Thanks, David On Mon, Dec 1, 2008 at 2:18 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Hmm. Crap. Damn that IE. Well, I have something working in Firefox on Mac for the button. It's probably more complicated than it needs to be... def ajaxRemove(name: String, func: AFuncHolder, attrs: Tuple2[String, String]*): Elem = { val funcName = mapFunc(func) (input type=button/) % (value - name) % (onclick - (makeAjaxCall(JsRaw(' + funcName+='+this.checked)) + ; return false)) % (class - removeButton) % getAttrs(attrs: _*) } Then: td class=button{FH.ajaxRemove(-, () = { val x = Model.getReference[X](classOf[X], tp.id http://tp.id) survey.technicalPotentials.remove(x) Model.merge(survey) Model.remove(x) Model.flush() Run($('#tp + tp.id.toString + ').hide().remove();) })}/td #tp + tp.id.toString is the id of the tr attribute. I'll crank up the virtual machine and test it in IE. Thanks for looking at this. I could conceivably hide the row and delete all the individual inputs (or maybe just hide the row), but that seems pretty kludgy. Chas. David Pollak wrote: Charles, If you're planning to deploy this app in IE, you may have an issue. My experience with IE is that adding/removing tr doesn't always work well. :-( What is most likely happening is that your button is inside a form. It turns out that there's a race condition where sometimes the XmlHttpRequest will get fired first and sometimes the form will be submitted first. Lemme see if I can do something fancy with returning false from the button ajax request to the event doesn't bubble up. Thanks, David On Mon, Dec 1, 2008 at 1:08 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I have a table in which each row represents an object in the database, with each cell in the row an input bound to an attribute of the object. I want to be able to add rows (with new, blank objects) and delete rows (deleting both the row on the page and the associated object in the database). I've set up a snippet method to insert a new row. It returns the table row with all the inputs nicely bound. How do I call this with AJAX and insert the NodeSeq into the current table? At the end of the row I have a [-] ajaxButton. It should delete that row and the associated object using AJAX, but when I click it, the page reloads and nothing changes. I've looked through the jQuery Lift stuff. Am I using the ajaxButton wrong? Why would the page reload? And what methods are appropriate to both updating an object (Model.remove(obj)) and deleting the row ($('#rowid').remove())? Any help appreciated. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: SHtml form inputs and attributes/labels
I figured there was a better way to do it. I rewrote pretty much all of SHtml to allow adding attributes easily (which is why mine says FH instead of SHtml). This looks interesting. I'll check it out. Thanks, Chas. David Pollak wrote: Charles, Thanks for the suggestion. I've just checked up code that looks something like yours: def ajaxButton(text: NodeSeq, func: () = JsCmd, attrs: (String, String)*): Elem = attrs.foldLeft(button onclick={makeAjaxCall(Str(mapFunc(func)+=true)).toJsCmd+; return false;} {text}/button)(_ % _) All the various form element creation methods take an attrs vararg. Also, note the use of foldLeft Thanks, David On Tue, Nov 18, 2008 at 1:25 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: So I copied SHtml over for fun and renamed it FH (form helper). Then I tried messing with textarea first, just for fun. This can probably be done much better, but this works just fine: private def getAttrs(attrs: Tuple2[String, String]*) : MetaData = { attrs.toList match { case x :: xs = new UnprefixedAttribute(x._1, x._2, getAttrs(xs: _*)) case _ = Null } } def textarea(value: String, func: String = Any, attrs: Tuple2[String, String]*): Elem = textarea_*(value, SFuncHolder(func), attrs: _*) def textarea_*(value: String, func: AFuncHolder, attrs: Tuple2[String, String]*): Elem = { (textarea name={mapFunc(func)} rows=8 cols=40{value}/textarea) % getAttrs(attrs: _*) } Now I can call it like this: FH.textarea(contact.message, contact.message = _, (id, myId), (class, myClass), (rows, 12)) And I get this: textarea id=myId class=myClass rows=12 cols=40/textarea (I added default rows and cols attributes because they are required for valid XHTML.) For what it's worth, this works much better for me. Chas. Charles F. Munat wrote: Ha. Great minds stink alike. I just discovered this little setback (after adding id attributes to about fifty checkboxes -- note to self: check one before doing them all). I've been messing with the map but it's messing with me. I can grab the right node pretty easily, but then I can't seem to add the MetaData. If you're looking to add an id, you can use checkbox_id: SHtml.checkbox_id(user.isStupid, user.isStupid = _, Full(isStupid)) which adds id=isStupid to the checkbox input. Chas. Derek Chen-Becker wrote: For a really neat trick, how would I set the ID for a checkbox? The SHtml checkbox method returns a NodeSeq. I suppose I could just do a map, but I was wondering if there was a simpler way. Thanks, Derek On Mon, Nov 17, 2008 at 4:54 PM, David Pollak [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: On Mon, Nov 17, 2008 at 3:41 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Added: http://liftweb.net/index.php/FAQ#How_do_I_add_attributes_to_form_fields_created_with_SHtml_methods.3F Awesome! Thanks! Chas. Jorge Ortiz wrote: Oops, it might be: SHtml.text(user.name http://user.name http://user.name http://user.name, user.name http://user.name http://user.name http://user.name = _) % (size - 24) % (maxlength - 48) % (id - user_name) % (title - Enter your name) One or both of those should work. --j On Mon, Nov 17, 2008 at 12:27 PM, Jorge Ortiz [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: Try: SHtml.text(user.name http://user.name http://user.name http://user.name, user.name http://user.name http://user.name http://user.name = _) % (size, 24) % (maxlength, 48) % (id, user_name) % (title, Enter your name) That should work.
[Lift] Re: Tools
There was a defect in the plugin. Cauyuon posted a fix to this list last week. On Mon, Dec 1, 2008 at 3:07 PM, Charles F. Munat [EMAIL PROTECTED] wrote: I've tried twice to get NetBeans up and running on my MacBook Pro with 2 gigs of RAM. Both times I made the mistake of loading in the entire liftweb library. After that -- and even after I closed the liftweb master project -- NetBeans will lock up for long periods of time (e.g. ten minutes or more) every few keystrokes to do some sort of indexing. It is unbelievably frustrating. Closing and re-opening NetBeans, rebooting the computer, etc. do nothing to help. As far as I can tell, once that happens, NetBeans is toast. I plan to reinstall NetBeans (for the nth time) and *never* open Lift in it, but that sort of defeats the purpose a bit since perusing the source code is where it would be most useful. Maybe I need to set some variable differently? I tried enlarging the heap space and things just got worse. I don't seem to have a plethora of other choices. Chas. David Pollak wrote: Charles, I use NetBeans and a whole lot of printlns. In general, if you've got a case class or Scala collections, the toString methods are pretty descriptive of what's going on. I have heard tell that it's possible to hook the NetBeans debugger up to a running Jetty instance and do breakpoints in the Scala code and inspect variables. I have not tried it myself. Thanks, David On Wed, Oct 15, 2008 at 8:22 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: One of the hardest parts about learning Lift and Scala is not really know what objects look like. Things get pretty complicated and it's difficult to remember what's in what. It would be very nice to be able to step through Lift and see exactly what is where in memory and how things change, etc. Normally, I'd use an IDE for this. I used to work in C#, and Visual Studio has some very nice tools. I can step through the program, look in any variable to see what's in it, etc. In Ruby, I use TextMate. I'm not very good at it, so most of my techniques are more rudimentary. But Rails has a nice method called debug. I can spit out what's in a variable by just adding: %= debug @my_variable % to a template. Lift, however, eschews code in templates. I created a Test snippet to do the same thing, but I'm having trouble understanding reflection in Scala. In Ruby, object.inspect or object.to_yaml can give me a pretty good picture of the object. I've tried Lift in Eclipse, NetBeans, and JEdit and none of them seem to work very well. Out of memory errors are common, or I just can't seem to get it set up properly. What tricks are others using to make it easier to see what's going on in Lift? Is there a way to step through a request and see exactly what happens and in what order? I would kill for that ability. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Broken class in latest nightly snapshot?
I just pushed a change... change the line to: class Entry extends KeyedRecord[Entry,Long] and see if it works. On Mon, Dec 1, 2008 at 3:39 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: I'm writing up some sample code for the book (Record chapter) and I got this when trying to do a keyed record: [WARNING] error: error while loading KeyedRecord, class file '/home/software/mavenrepo/net/liftweb/lift-webkit/0.10-SNAPSHOT/lift-webkit-0.10-SNAPSHOT.jar(net/liftweb/record/KeyedRecord.class)' is broken [WARNING] (key not found: KeyType) [WARNING] /home/software/liftbook-demos/demo-record/src/main/scala/com/theliftbook/model/Entry.scala:59: error: net.liftweb.record.KeyedRecord does not take type parameters [WARNING] class Entry extends Record[Entry] with KeyedRecord[Entry,Long] { [WARNING]^ [WARNING] two errors found I'm not sure exactly what's going on there, but according to the source for KeyedRecord it most definitely takes type params unless I'm really reading things wrong. Anyone else get this? I've nuked my maven repo and still no love. Derek -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: A javascript method bound to lift?
You certainly can. The easiest way is with the JsonFunc: val (jsonCall: JsonCall, jsCmd: JsCmd) = S.buildJsonFunc { case JsonCmd(DoSomething, _, s, _) = println(Got +s) Alert(You entered: +s) case _ = Noop } In your page, include: span { Script(jsCmd) // emit the JSON call } { // emit the function showElement that has x as a param. // when the function is called, invoke the JsonCall Script(Function(showElement, List(x), jsonCall(DoSomething, JsVar(x } /span See also http://github.com/dpp/liftweb/tree/master/sites/example/src/main/scala/net/liftweb/example/snippet/Json.scala On Tue, Nov 25, 2008 at 7:59 AM, Joachim A. [EMAIL PROTECTED]wrote: Hi, sorry for my posts. I have some difficult time with the Javascript stuff in Lift. I have some HTML which is generated by XSLT. This data contains links with javascript calls. I want that the javascript ends up as ajax calls to lift. Example data: a onclick=showElement(1)Show Element 1/a Can I create a Javascript method showElement (with Lift's help or without it) which does an ajax request with Lift to show the specified Element? Thanks a lot, Joachim -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Testing best practices
Please make sure that you've got specs 1.4.0 and scalacheck 1.5 Also, please do an mvn clean test Thanks, David On Sat, Nov 29, 2008 at 3:45 AM, Juha L [EMAIL PROTECTED] wrote: I managed after all to find specs test example from the example webapp. Now that I try to start creating some tests of my own, I however get a long stacktrace from the compiler. Is it compiler bug as I assume, or am I doing something horribly wrong? If I remove second test (be fetched) it compiles and executes fine. I'm using git version of lift, scala 2.7.2 and specs 1.4.1. I have tried mvn clean. Actual test (src/test/scala/net/app/model/UserSpec.scala): package net.app.model import _root_.org.specs._ import _root_.org.specs.runner._ import bootstrap.liftweb.Boot import net.liftweb.util._ class UserSpecTest extends Runner(UserSpec) with JUnit with Console object UserSpec extends Specification { val b = new Boot b.boot User can { val created = new User be created in { created.firstName(Foo).lastName(Bar) created.save() must beTrue } be fetched in { User.find(created.id.is) match { case Full(fetched) = fetched must_== created case Empty = true must beFalse } } } } Stack trace: [WARNING] Exception in thread main java.lang.RuntimeException: malformed Scala signature of User at 13802; reference type _9 of none refers to nonexisting symbol. [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.errorBadSignature(UnPickler.scala:762) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readSymbol(UnPickler.scala:172) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readSymbolRef$1.apply(UnPickler.scala:714) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readSymbolRef$1.apply(UnPickler.scala:714) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$$at (UnPickler.scala:139) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readSymbolRef(UnPickler.scala:714) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$$readType (UnPickler.scala:254) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readTypeRef$1.apply(UnPickler.scala:715) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readTypeRef$1.apply(UnPickler.scala:715) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$$at (UnPickler.scala:139) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readTypeRef(UnPickler.scala:715) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$3.apply(UnPickler.scala:255) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$3.apply(UnPickler.scala:255) [WARNING] at scala.tools.nsc.symtab.classfile.PickleBuffer.until (PickleBuffer.scala:127) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$$readType (UnPickler.scala:255) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readTypeRef$1.apply(UnPickler.scala:715) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readTypeRef$1.apply(UnPickler.scala:715) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$$at (UnPickler.scala:139) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readTypeRef(UnPickler.scala:715) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler $UnPickle.scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$$readType (UnPickler.scala:286) [WARNING] at scala.tools.nsc.symtab.classfile.UnPickler$UnPickle$ $anonfun$scala$tools$nsc$symtab$classfile$UnPickler$UnPickle$ $readTypeRef$1.apply(UnPickler.scala:715)
[Lift] Re: Tools
I thought I had updated to that, but maybe I broke it before the update... Will install all the latest this time and will see what happens. But I had the same experience a couple of months ago when I tried it for the first time. I'd really like it to work, though. That would be great, and it would be consistent with my Linux box. Chas. David Pollak wrote: There was a defect in the plugin. Cauyuon posted a fix to this list last week. On Mon, Dec 1, 2008 at 3:07 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I've tried twice to get NetBeans up and running on my MacBook Pro with 2 gigs of RAM. Both times I made the mistake of loading in the entire liftweb library. After that -- and even after I closed the liftweb master project -- NetBeans will lock up for long periods of time (e.g. ten minutes or more) every few keystrokes to do some sort of indexing. It is unbelievably frustrating. Closing and re-opening NetBeans, rebooting the computer, etc. do nothing to help. As far as I can tell, once that happens, NetBeans is toast. I plan to reinstall NetBeans (for the nth time) and *never* open Lift in it, but that sort of defeats the purpose a bit since perusing the source code is where it would be most useful. Maybe I need to set some variable differently? I tried enlarging the heap space and things just got worse. I don't seem to have a plethora of other choices. Chas. David Pollak wrote: Charles, I use NetBeans and a whole lot of printlns. In general, if you've got a case class or Scala collections, the toString methods are pretty descriptive of what's going on. I have heard tell that it's possible to hook the NetBeans debugger up to a running Jetty instance and do breakpoints in the Scala code and inspect variables. I have not tried it myself. Thanks, David On Wed, Oct 15, 2008 at 8:22 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: One of the hardest parts about learning Lift and Scala is not really know what objects look like. Things get pretty complicated and it's difficult to remember what's in what. It would be very nice to be able to step through Lift and see exactly what is where in memory and how things change, etc. Normally, I'd use an IDE for this. I used to work in C#, and Visual Studio has some very nice tools. I can step through the program, look in any variable to see what's in it, etc. In Ruby, I use TextMate. I'm not very good at it, so most of my techniques are more rudimentary. But Rails has a nice method called debug. I can spit out what's in a variable by just adding: %= debug @my_variable % to a template. Lift, however, eschews code in templates. I created a Test snippet to do the same thing, but I'm having trouble understanding reflection in Scala. In Ruby, object.inspect or object.to_yaml can give me a pretty good picture of the object. I've tried Lift in Eclipse, NetBeans, and JEdit and none of them seem to work very well. Out of memory errors are common, or I just can't seem to get it set up properly. What tricks are others using to make it easier to see what's going on in Lift? Is there a way to step through a request and see exactly what happens and in what order? I would kill for that ability. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Tools
I'd suggest removing the ~/.netbeans directory (and anything that looks like it). On Mon, Dec 1, 2008 at 5:00 PM, Charles F. Munat [EMAIL PROTECTED] wrote: I thought I had updated to that, but maybe I broke it before the update... Will install all the latest this time and will see what happens. But I had the same experience a couple of months ago when I tried it for the first time. I'd really like it to work, though. That would be great, and it would be consistent with my Linux box. Chas. David Pollak wrote: There was a defect in the plugin. Cauyuon posted a fix to this list last week. On Mon, Dec 1, 2008 at 3:07 PM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: I've tried twice to get NetBeans up and running on my MacBook Pro with 2 gigs of RAM. Both times I made the mistake of loading in the entire liftweb library. After that -- and even after I closed the liftweb master project -- NetBeans will lock up for long periods of time (e.g. ten minutes or more) every few keystrokes to do some sort of indexing. It is unbelievably frustrating. Closing and re-opening NetBeans, rebooting the computer, etc. do nothing to help. As far as I can tell, once that happens, NetBeans is toast. I plan to reinstall NetBeans (for the nth time) and *never* open Lift in it, but that sort of defeats the purpose a bit since perusing the source code is where it would be most useful. Maybe I need to set some variable differently? I tried enlarging the heap space and things just got worse. I don't seem to have a plethora of other choices. Chas. David Pollak wrote: Charles, I use NetBeans and a whole lot of printlns. In general, if you've got a case class or Scala collections, the toString methods are pretty descriptive of what's going on. I have heard tell that it's possible to hook the NetBeans debugger up to a running Jetty instance and do breakpoints in the Scala code and inspect variables. I have not tried it myself. Thanks, David On Wed, Oct 15, 2008 at 8:22 AM, Charles F. Munat [EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] mailto:[EMAIL PROTECTED] wrote: One of the hardest parts about learning Lift and Scala is not really know what objects look like. Things get pretty complicated and it's difficult to remember what's in what. It would be very nice to be able to step through Lift and see exactly what is where in memory and how things change, etc. Normally, I'd use an IDE for this. I used to work in C#, and Visual Studio has some very nice tools. I can step through the program, look in any variable to see what's in it, etc. In Ruby, I use TextMate. I'm not very good at it, so most of my techniques are more rudimentary. But Rails has a nice method called debug. I can spit out what's in a variable by just adding: %= debug @my_variable % to a template. Lift, however, eschews code in templates. I created a Test snippet to do the same thing, but I'm having trouble understanding reflection in Scala. In Ruby, object.inspect or object.to_yaml can give me a pretty good picture of the object. I've tried Lift in Eclipse, NetBeans, and JEdit and none of them seem to work very well. Out of memory errors are common, or I just can't seem to get it set up properly. What tricks are others using to make it easier to see what's going on in Lift? Is there a way to step through a request and see exactly what happens and in what order? I would kill for that ability. Chas. -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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
[Lift] Re: Are there printable versions of any draft Lift books?
Please keep in mind most things are in flux. Just fair warning. :) On Dec 1, 6:11 pm, mal3 [EMAIL PROTECTED] wrote: Are there printable versions of any draft Lift books? It would help me and would provide an easy basis for feedback to the authors if the Lift books currently in draft were made available for easy download and printing, in say PDF format. The Scala book early access process was both useful and efficient. I'm not expecting polished early drafts. Just something to read that will help enlighten me about Lift. Mal. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Broken class in latest nightly snapshot?
Darnit. I figured out the issue. My pom.xml had a scala.version tucked away and set to 2.7.1. Changing to 2.7.2 fixed it. Derek On Mon, Dec 1, 2008 at 4:58 PM, David Pollak [EMAIL PROTECTED]wrote: I just pushed a change... change the line to: class Entry extends KeyedRecord[Entry,Long] and see if it works. On Mon, Dec 1, 2008 at 3:39 PM, Derek Chen-Becker [EMAIL PROTECTED]wrote: I'm writing up some sample code for the book (Record chapter) and I got this when trying to do a keyed record: [WARNING] error: error while loading KeyedRecord, class file '/home/software/mavenrepo/net/liftweb/lift-webkit/0.10-SNAPSHOT/lift-webkit-0.10-SNAPSHOT.jar(net/liftweb/record/KeyedRecord.class)' is broken [WARNING] (key not found: KeyType) [WARNING] /home/software/liftbook-demos/demo-record/src/main/scala/com/theliftbook/model/Entry.scala:59: error: net.liftweb.record.KeyedRecord does not take type parameters [WARNING] class Entry extends Record[Entry] with KeyedRecord[Entry,Long] { [WARNING]^ [WARNING] two errors found I'm not sure exactly what's going on there, but according to the source for KeyedRecord it most definitely takes type params unless I'm really reading things wrong. Anyone else get this? I've nuked my maven repo and still no love. Derek -- Lift, the simply functional web framework http://liftweb.net Collaborative Task Management http://much4.us 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---