[Lift] Re: testing
OK, I've got the lift-archetype-basic working now just as the post shows. In pursuit of BDD, I want to test some behavior this way: 1. Set up a 'test' database with a single SuperUser using fields I know work with password, salt, etc. 2. Sign In as that SuperUser. 3. Sign Up another SuperUser with fields I supply, and send the verification email. 4. Tear down everything after the tests run, leaving no database. That's the beginning of the sort of testing I want to use to build my next app. Perhaps it's all there already, but it's not obvious to me yet. On Sep 9, 5:35 pm, David Pollak feeder.of.the.be...@gmail.com wrote: Dustin, I've updated the Basic archetype to include a couple of things: - An example of Lift's new Factory support which blends the best of dependency injection and and highly configurable, type-safe factories - An example of how to set up a session to test a snippet - An example of injecting a test value into the snippet test via the factory The test that you asked about looks like: object HelloWorldTestSpecs extends Specification { val session = new LiftSession(, randomString(20), Empty) HelloWorld Snippet should { Put the time in the node in { S.initIfUninitted(session) { val stableTime = now DependencyFactory.time.doWith(stableTime) { val hello = new HelloWorld Thread.sleep(1000) // make sure the time changes val str = hello.howdy(spanHello at b:time//span).toString str.indexOf(stableTime.toString) must be = 0 str.indexOf(Hello at) must be = 0 } } } } } This demonstrates creating a mock LiftSession and setting up S with initIfUnitted. The DepencyFactory.time.doWith sets up a new value to be generated from the DepencyFactory.time object (rather than using the global default function, the stableTime value is used.) In the HelloWord snippet, we inject the value of the time object: class HelloWorld { import DependencyFactory._ // Import the Dependency Injector val date = inject[Date] // inject the date // lazy val date = DependencyFactory.time.make // create the date via factory def howdy(in: NodeSeq): NodeSeq = Helpers.bind(b, in, time - date.map(d = Text(d.toString))) } Note there are two ways of getting the time. The inject method will locate a Maker for a java.util.Date. This is a whole lot less (in my opinion) optimal than the second option, which explicitly calls the time factory. In either case, the current time Maker (global, session-specific, request-specific, and stack-specific) is consulted. To build the Factory itself: object DependencyFactory extends Factory { implicit object time extends FactoryMaker(Helpers.now _) } I hope this answers you question about testing snippets and more broadly addresses some of the recent discussions on the list about Dependency Injection, Factories, mocks, and testing. Thanks, David On Wed, Sep 9, 2009 at 1:05 PM, Dustin Whitney dustin.whit...@gmail.comwrote: All, I am having trouble finding any literature on how to test a Lift app. I've got a snippet. I'd like to mock a request and test the NodeSeq that comes back from the render method in my snippet. Can anyone point me to some code that's doing that? Thanks, Dustin -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Crazy idea for lift's mega proto user: admin panel.
Right -- not knowing personally as to core vs widget (that is up to 'management'), but I would also look to the web2py and django (even Google app engine) frameworks for nice admin interface inspiration... On Sep 7, 4:16 pm, DFectuoso santiago1...@gmail.com wrote: I was thinking about how wonderful it is to get a login/register/ forgotPassword functionality with mega proto user and how it could become even better with a good tool for creating an admin section. I'm just adding the idea here so maybe if other people find value it could be considered for development(or probably it already is, i don't know). Adding an admin panel to mega proto user where the moderators/admins could change some options(like the way a user is validated, if gzip is enabled, etc) would be great for the end users of our apps, since it would be easier to change and maintain the site. Being a administrator at a Invision Power Board forum and having a couple of wordpress blogs, i see a lot of potential on this as a admin/ dev tool! Listing some of the things that i can imagine in this panel are: -phpMyAdmin-type of DB admin(browse your data easily, remove/change/ add stuff to it without having to create a CRUD for each thing) -execute queries -List the actor(and comet actors) with possibility to kill/reset them -Memory use analysis. -Statistics of use(hits, referrals, etc) -Options (any object/class/trait could have a val foo = adminPanel.option(category,optionName,description,defaultValue, otherValues[]) and be included in this place, of course the categories could create different menus. -User management(ban, authorize, give admin-rights). -Simple to-do list that all admins can edit -Log of errors/warnings/exceptions -Css editor -Easy-logo changer -File Manager(upload your images and stuff here) -String editor (you can change any default string from the megaprotouser forms and the index?) Also, a very polemic(and i think bad idea, but its common to see this in admin panels): -Installable plug-ins for this panel I know this seems like one step away from being a full blown CMS, forum, blog, etc. But if its extensible while we are building an app, it will be very useful for the different moments of development and use. Of course i don't expect any of this to be done right now, i understand there are a couple of integrations and bigger things going on but i really wanted to brainstorm on this with you guys! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Invalid dates
OK, I just went through a lot of work on this over the past month ... My solution, in a webapp environment, was to hold all date-times as UNIX timestamps (milliseconds from 1970.1.1), which are in UTC, and then let the client do all conversions, because the browser is set for the local timezone. What I like is that the DB number is a pure Long, so I can add or subtract as I need (either server-side or client-side), and I can even sneak in a call on the server to java.util.Date for a (new Date ()).getTime() if I need a timestamp. The downside is there are some gymnastics to do for JavaScript formatting, conversion, and even validation on input and display, but otherwise it works nicely. On Sep 6, 2:32 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: How do you deal with users entering invalid dates? 1) The default implementation is dependent on the global date formatter/parser, which is nonoptimal. How do you enter a time for a MappedTime? MappedDates should not show the time of day, nor MappedTimes the date. 2) If toForm or setFromAny fails to parse the date, there is no information about it available to validation. I would like to suggest that Mapped(Date)(Time)s hold a DateFormat. MappedDate should default to DateFormat.getDateInstance and MappedTime to DateFormat.getTimeInstance(DateFormat.SHORT). MappedDateTime can use the global. And they could hold a Boxed String which would be Full if parsing failed, and a validator that requires it to be Empty. The actual set method would reset it to Empty. Thanks. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] what's in Classpath?
How can we know what is included in Lift's classpath for javascript and css files? I see src=/classpath/jquery.js and src=/classpath/json.js in the example template, and even lift:CSS.blueprint / and lift:CSS.fancyType /. Where can I see exactly what we are getting 'for free', so I will know what I have to load explicitly into html? Thanks as always! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] why match not exhaustive?
I am getting this warning during compile of my ToDo tutorial app enhancement: ToDo.scala:355: warning: match is not exhaustive! missing combination ParamFailure missing combination Failure case Nil = selectedTag match { My code is: currentTask.validate match { case Nil = selectedTag match { case Full(currentTag) = if (! currentTask.saved_?) { currentTask.save JoinTags.joinTask(currentTag, currentTask) S.notice(added Task: + currentTask.desc.is) } case Empty = S.error(..please supply a Tag); S.mapSnippet(ToDo.addTask, doTaskBind) } case xs = S.error(xs); S.mapSnippet(ToDo.addTask, doTaskBind) } The code runs fine so far... Is it the nested match? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: slow down ajax?
Short story - after a fresh start with your instructions... all is well. I actually just downloaded the zip file into a liftweb temp directory, then entered that and ran mvn as you said. After a huge compile, I changed all 3 of my Lift references in the existing project pom.xml to '1.1-SNAPSHOT' (which may have been a problem on my last attempt), and jetty started perfectly. So, now I will delve back into the mechanics of my program, and tinker along. Thanks for your help, and stay tuned for the next exciting episode... Lift is fun! On Aug 19, 10:42 pm, marius d. marius.dan...@gmail.com wrote: Or just checkout from git master and do a mvn clean:clean install Trust me it's all there :) Br's, Marius On Aug 20, 8:15 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Are you using maven to compile? Delete any earlier jar so you rule out that possibility. Also, if you turn on debug output in maven (-X) it might tell you the path that it's using to invoke the compiler so you can see which jar it's using if any. - g-mangregor...@gmail.com wrote: Well, I went down the rabbit hole on a quest for 1.1-SNAPSHOT - It is not visible, even though my pom points to it, and the .m2 repository shows a directory for it. .m2\repository\net\liftweb\lift-archetype-basic\1.1-SNAPSHOT Bottom line is : src\main\scala\bootstrap\liftweb\Boot.scala:11: error: value provider is not a member of package net.liftweb.http import http.provider._ and: error: wrong number of arguments for method ajaxText: (String,(String) = net.liftweb.http.js.JsCmd)scala.xml.Elem So Lift can't see the new stuff, and I also can't get an archetype created using the 1.1-SNAPSHOT, so I will keep hacking unless you have some further guidance for me. On Aug 19, 12:20 pm, marius d. marius.dan...@gmail.com wrote: Please use Lift 1.1-SNAPSHOT Br's, Marius On Aug 19, 10:06 pm, g-man gregor...@gmail.com wrote: I quoted the def from net.liftweb.http.SHtml in: http://scala-tools.org/scaladocs/liftweb/1.0/ and when I tried the other version, my complier did not accept the extra param. That's why I thought I had to override something... Is there a newer version I should be using? On Aug 18, 10:38 pm, marius d. marius.dan...@gmail.com wrote: No you can't override it because SHtml is an object not a type. The function definition above (def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) ) already exists in SHtml. In fact we have this deferring mechanism for other functions like ajaxButton, a, etc. If you're still having trouble using this please let me know and I'll make and example app. for you. Br's, Marius On Aug 19, 5:42 am, g-man gregor...@gmail.com wrote: OK, seems like I have to learn a little more about Scala so I can override the ajaxText method, right? Here it is in the docs: def ajaxText(value: String, func: String = JsCmd): Elem = ajaxText_* (value, SFuncHolder(func)) When I fumble around, it won't compile, because I'm just not doing it right. My project is a hobby, not mission-critical, so I'm under no pressure. For now, I will change to an ajaxForm, but the learning is all good, and if you want to keep teaching, I will listen! Thanks for your patience... On Aug 18, 12:41 pm, marius d. marius.dan...@gmail.com wrote: Having def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) jsFunc parameter is a Call which is defined as: case class Call(function: String, params: JsExp*) extends JsExp So by this you represent a javascript function invocations. So assuming somewhere you have a javascript function like: function myFunc(myParam, callback) { // do some logic callback() } in the snippet we have something like: ajaxText(task.dueOn.toString, Call(myFunc, Str(some_param_value)) v = { task.dueOn(v.toLong).save; reDrawTasks();}) As you can see we called Call(myFunc, Str (some_param_value)) .. .we provided the JS function name and one parameter. Lift will add the second parameter which is the callback function. This callback function represents the actual ajax call and since it is a callback you can invoke it whenever you want inside 'myFunc' javascript function. In other words you can defer the actual ajax call as you see fit. Now myFunc function declaration can be: 1. In your own .js file 2. Written in the script tag inside your html 3. Generate using Lifts' JS absctrations using JsCmds.Function() object such as: JsCmds.Function(MyFunc, List(myParam, callback
[Lift] Re: slow down ajax?
I quoted the def from net.liftweb.http.SHtml in: http://scala-tools.org/scaladocs/liftweb/1.0/ and when I tried the other version, my complier did not accept the extra param. That's why I thought I had to override something... Is there a newer version I should be using? On Aug 18, 10:38 pm, marius d. marius.dan...@gmail.com wrote: No you can't override it because SHtml is an object not a type. The function definition above (def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) ) already exists in SHtml. In fact we have this deferring mechanism for other functions like ajaxButton, a, etc. If you're still having trouble using this please let me know and I'll make and example app. for you. Br's, Marius On Aug 19, 5:42 am, g-man gregor...@gmail.com wrote: OK, seems like I have to learn a little more about Scala so I can override the ajaxText method, right? Here it is in the docs: def ajaxText(value: String, func: String = JsCmd): Elem = ajaxText_* (value, SFuncHolder(func)) When I fumble around, it won't compile, because I'm just not doing it right. My project is a hobby, not mission-critical, so I'm under no pressure. For now, I will change to an ajaxForm, but the learning is all good, and if you want to keep teaching, I will listen! Thanks for your patience... On Aug 18, 12:41 pm, marius d. marius.dan...@gmail.com wrote: Having def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) jsFunc parameter is a Call which is defined as: case class Call(function: String, params: JsExp*) extends JsExp So by this you represent a javascript function invocations. So assuming somewhere you have a javascript function like: function myFunc(myParam, callback) { // do some logic callback() } in the snippet we have something like: ajaxText(task.dueOn.toString, Call(myFunc, Str(some_param_value)) v = { task.dueOn(v.toLong).save; reDrawTasks();}) As you can see we called Call(myFunc, Str (some_param_value)) .. .we provided the JS function name and one parameter. Lift will add the second parameter which is the callback function. This callback function represents the actual ajax call and since it is a callback you can invoke it whenever you want inside 'myFunc' javascript function. In other words you can defer the actual ajax call as you see fit. Now myFunc function declaration can be: 1. In your own .js file 2. Written in the script tag inside your html 3. Generate using Lifts' JS absctrations using JsCmds.Function() object such as: JsCmds.Function(MyFunc, List(myParam, callback), a_JsCmd_expression_which_is_the_function_body) The main point in all this is that you can defer the actual ajax call. You know better if this fits your case. Br's, Marius On Aug 18, 10:21 pm, g-man gregor...@gmail.com wrote: No, this is the old way ...I am unsure how to invoke the ajax method -- could you enlighten me? On Aug 17, 12:26 pm, marius d. marius.dan...@gmail.com wrote: I don't see in your code the use of the overloaded ajaxText that I posted. Have you tried it? Marius On Aug 17, 10:20 pm, g-man gregor...@gmail.com wrote: OK, thanks for checking back... Snippet: swappable(span class='dueon'{task.dueOn.toString}/span, span class='chgDueon'{ajaxText(task.dueOn.toString, v = { task.dueOn(v.toLong).save; reDrawTasks(); }) % (size - 10)}/span) JS: $chgDueon // jQuery selection for text field .datepicker({dateFormat:'m-d-yy', minDate: +1}) .blur(function(){$chgDueon.val(parseDate($chgDueon.val()));}); // works well to pick a new date and change it to millis for save Emitted XHTML: span span class=dueon id=F111290299287IBE onclick=jQuery('#'+'F111290299287IBE').hide(); jQuery('#'+'F1112902992880KN').show().each(function(i) { var t = this; setTimeout(function() { t.focus(); }, 200);});return false;; 1248493271843/span span style=display: none id=F1112902992880KN onblur=jQuery('#'+'F111290299287IBE').show(); jQuery('#'+'F1112902992880KN').hide(); input onblur=lift_ajaxHandler('F111290299286DL1=' + encodeURIComponent(this.value), null, null) type=text value=1248493271843 onkeypress=lift_blurIfReturn(event) size=10 / /span /span So, all the parts work well together, but Lift's ajax just takes off too quickly, and cannot read the new value. On Aug 16, 11:02 pm, marius d. marius.dan...@gmail.com wrote: You can probably use this definition of ajaxText: def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) See the jsFunc
[Lift] Re: slow down ajax?
Well, I went down the rabbit hole on a quest for 1.1-SNAPSHOT - It is not visible, even though my pom points to it, and the .m2 repository shows a directory for it. .m2\repository\net\liftweb\lift-archetype-basic\1.1-SNAPSHOT Bottom line is : src\main\scala\bootstrap\liftweb\Boot.scala:11: error: value provider is not a member of package net.liftweb.http import http.provider._ and: error: wrong number of arguments for method ajaxText: (String,(String) = net.liftweb.http.js.JsCmd)scala.xml.Elem So Lift can't see the new stuff, and I also can't get an archetype created using the 1.1-SNAPSHOT, so I will keep hacking unless you have some further guidance for me. On Aug 19, 12:20 pm, marius d. marius.dan...@gmail.com wrote: Please use Lift 1.1-SNAPSHOT Br's, Marius On Aug 19, 10:06 pm, g-man gregor...@gmail.com wrote: I quoted the def from net.liftweb.http.SHtml in: http://scala-tools.org/scaladocs/liftweb/1.0/ and when I tried the other version, my complier did not accept the extra param. That's why I thought I had to override something... Is there a newer version I should be using? On Aug 18, 10:38 pm, marius d. marius.dan...@gmail.com wrote: No you can't override it because SHtml is an object not a type. The function definition above (def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) ) already exists in SHtml. In fact we have this deferring mechanism for other functions like ajaxButton, a, etc. If you're still having trouble using this please let me know and I'll make and example app. for you. Br's, Marius On Aug 19, 5:42 am, g-man gregor...@gmail.com wrote: OK, seems like I have to learn a little more about Scala so I can override the ajaxText method, right? Here it is in the docs: def ajaxText(value: String, func: String = JsCmd): Elem = ajaxText_* (value, SFuncHolder(func)) When I fumble around, it won't compile, because I'm just not doing it right. My project is a hobby, not mission-critical, so I'm under no pressure. For now, I will change to an ajaxForm, but the learning is all good, and if you want to keep teaching, I will listen! Thanks for your patience... On Aug 18, 12:41 pm, marius d. marius.dan...@gmail.com wrote: Having def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) jsFunc parameter is a Call which is defined as: case class Call(function: String, params: JsExp*) extends JsExp So by this you represent a javascript function invocations. So assuming somewhere you have a javascript function like: function myFunc(myParam, callback) { // do some logic callback() } in the snippet we have something like: ajaxText(task.dueOn.toString, Call(myFunc, Str(some_param_value)) v = { task.dueOn(v.toLong).save; reDrawTasks();}) As you can see we called Call(myFunc, Str (some_param_value)) .. .we provided the JS function name and one parameter. Lift will add the second parameter which is the callback function. This callback function represents the actual ajax call and since it is a callback you can invoke it whenever you want inside 'myFunc' javascript function. In other words you can defer the actual ajax call as you see fit. Now myFunc function declaration can be: 1. In your own .js file 2. Written in the script tag inside your html 3. Generate using Lifts' JS absctrations using JsCmds.Function() object such as: JsCmds.Function(MyFunc, List(myParam, callback), a_JsCmd_expression_which_is_the_function_body) The main point in all this is that you can defer the actual ajax call. You know better if this fits your case. Br's, Marius On Aug 18, 10:21 pm, g-man gregor...@gmail.com wrote: No, this is the old way ...I am unsure how to invoke the ajax method -- could you enlighten me? On Aug 17, 12:26 pm, marius d. marius.dan...@gmail.com wrote: I don't see in your code the use of the overloaded ajaxText that I posted. Have you tried it? Marius On Aug 17, 10:20 pm, g-man gregor...@gmail.com wrote: OK, thanks for checking back... Snippet: swappable(span class='dueon'{task.dueOn.toString}/span, span class='chgDueon'{ajaxText(task.dueOn.toString, v = { task.dueOn(v.toLong).save; reDrawTasks(); }) % (size - 10)}/span) JS: $chgDueon // jQuery selection for text field .datepicker({dateFormat:'m-d-yy', minDate: +1}) .blur(function(){$chgDueon.val(parseDate($chgDueon.val()));}); // works well to pick a new date and change it to millis for save Emitted XHTML: span span class=dueon id=F111290299287IBE
[Lift] Re: slow down ajax?
No, this is the old way ...I am unsure how to invoke the ajax method -- could you enlighten me? On Aug 17, 12:26 pm, marius d. marius.dan...@gmail.com wrote: I don't see in your code the use of the overloaded ajaxText that I posted. Have you tried it? Marius On Aug 17, 10:20 pm, g-man gregor...@gmail.com wrote: OK, thanks for checking back... Snippet: swappable(span class='dueon'{task.dueOn.toString}/span, span class='chgDueon'{ajaxText(task.dueOn.toString, v = { task.dueOn(v.toLong).save; reDrawTasks(); }) % (size - 10)}/span) JS: $chgDueon // jQuery selection for text field .datepicker({dateFormat:'m-d-yy', minDate: +1}) .blur(function(){$chgDueon.val(parseDate($chgDueon.val()));}); // works well to pick a new date and change it to millis for save Emitted XHTML: span span class=dueon id=F111290299287IBE onclick=jQuery('#'+'F111290299287IBE').hide(); jQuery('#'+'F1112902992880KN').show().each(function(i) { var t = this; setTimeout(function() { t.focus(); }, 200);});return false;; 1248493271843/span span style=display: none id=F1112902992880KN onblur=jQuery('#'+'F111290299287IBE').show(); jQuery('#'+'F1112902992880KN').hide(); input onblur=lift_ajaxHandler('F111290299286DL1=' + encodeURIComponent(this.value), null, null) type=text value=1248493271843 onkeypress=lift_blurIfReturn(event) size=10 / /span /span So, all the parts work well together, but Lift's ajax just takes off too quickly, and cannot read the new value. On Aug 16, 11:02 pm, marius d. marius.dan...@gmail.com wrote: You can probably use this definition of ajaxText: def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) See the jsFunc parameter. Essentially you are specifying your function call that may have one parameter. To your parameter list List we'll add a new parameter which is the ajax invocation function. In other words your code gets that function that does the ajax call meaning that you have the control over when the ajax call is made. Br's, Marius On Aug 17, 8:55 am, marius d. marius.dan...@gmail.com wrote: Would you please post a code snippet with what you're doing? (a minimalistic example) Br's, Marius On Aug 17, 7:41 am, g-man gregor...@gmail.com wrote: I am moving nicely with my 'save all dates as millis and let the client localize for display' project, learning while enhancing the ToDo sample app. I have added a 'dueOn' field, and that is displayed as swappable ajaxText, similar to the other fields in the tutorial. I have enabled datepicker for the ajaxText field via jQuery, and have a parsing function attached an event listener, so when datepicker finishes, the date is converted to millis, ready for Lift to send back to the server and save. So far, all good. The problem is that Lift's ajax starts ('onblur') before it has a chance to see the new date value, so the new value is never saved. What I need is a way to tell Lift to wait until after my parser has had a chance to write the changed value. I like the ajax style, so I don't want to make a 'submit' form, and 'onchange' won't do it either, because the value is actually changed twice (once to a formatted date, once to millis). What I need is some way to say, 'OK to start ajax now'! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: slow down ajax?
OK, seems like I have to learn a little more about Scala so I can override the ajaxText method, right? Here it is in the docs: def ajaxText(value: String, func: String = JsCmd): Elem = ajaxText_* (value, SFuncHolder(func)) When I fumble around, it won't compile, because I'm just not doing it right. My project is a hobby, not mission-critical, so I'm under no pressure. For now, I will change to an ajaxForm, but the learning is all good, and if you want to keep teaching, I will listen! Thanks for your patience... On Aug 18, 12:41 pm, marius d. marius.dan...@gmail.com wrote: Having def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) jsFunc parameter is a Call which is defined as: case class Call(function: String, params: JsExp*) extends JsExp So by this you represent a javascript function invocations. So assuming somewhere you have a javascript function like: function myFunc(myParam, callback) { // do some logic callback() } in the snippet we have something like: ajaxText(task.dueOn.toString, Call(myFunc, Str(some_param_value)) v = { task.dueOn(v.toLong).save; reDrawTasks();}) As you can see we called Call(myFunc, Str (some_param_value)) .. .we provided the JS function name and one parameter. Lift will add the second parameter which is the callback function. This callback function represents the actual ajax call and since it is a callback you can invoke it whenever you want inside 'myFunc' javascript function. In other words you can defer the actual ajax call as you see fit. Now myFunc function declaration can be: 1. In your own .js file 2. Written in the script tag inside your html 3. Generate using Lifts' JS absctrations using JsCmds.Function() object such as: JsCmds.Function(MyFunc, List(myParam, callback), a_JsCmd_expression_which_is_the_function_body) The main point in all this is that you can defer the actual ajax call. You know better if this fits your case. Br's, Marius On Aug 18, 10:21 pm, g-man gregor...@gmail.com wrote: No, this is the old way ...I am unsure how to invoke the ajax method -- could you enlighten me? On Aug 17, 12:26 pm, marius d. marius.dan...@gmail.com wrote: I don't see in your code the use of the overloaded ajaxText that I posted. Have you tried it? Marius On Aug 17, 10:20 pm, g-man gregor...@gmail.com wrote: OK, thanks for checking back... Snippet: swappable(span class='dueon'{task.dueOn.toString}/span, span class='chgDueon'{ajaxText(task.dueOn.toString, v = { task.dueOn(v.toLong).save; reDrawTasks(); }) % (size - 10)}/span) JS: $chgDueon // jQuery selection for text field .datepicker({dateFormat:'m-d-yy', minDate: +1}) .blur(function(){$chgDueon.val(parseDate($chgDueon.val()));}); // works well to pick a new date and change it to millis for save Emitted XHTML: span span class=dueon id=F111290299287IBE onclick=jQuery('#'+'F111290299287IBE').hide(); jQuery('#'+'F1112902992880KN').show().each(function(i) { var t = this; setTimeout(function() { t.focus(); }, 200);});return false;; 1248493271843/span span style=display: none id=F1112902992880KN onblur=jQuery('#'+'F111290299287IBE').show(); jQuery('#'+'F1112902992880KN').hide(); input onblur=lift_ajaxHandler('F111290299286DL1=' + encodeURIComponent(this.value), null, null) type=text value=1248493271843 onkeypress=lift_blurIfReturn(event) size=10 / /span /span So, all the parts work well together, but Lift's ajax just takes off too quickly, and cannot read the new value. On Aug 16, 11:02 pm, marius d. marius.dan...@gmail.com wrote: You can probably use this definition of ajaxText: def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) See the jsFunc parameter. Essentially you are specifying your function call that may have one parameter. To your parameter list List we'll add a new parameter which is the ajax invocation function. In other words your code gets that function that does the ajax call meaning that you have the control over when the ajax call is made. Br's, Marius On Aug 17, 8:55 am, marius d. marius.dan...@gmail.com wrote: Would you please post a code snippet with what you're doing? (a minimalistic example) Br's, Marius On Aug 17, 7:41 am, g-man gregor...@gmail.com wrote: I am moving nicely with my 'save all dates as millis and let the client localize for display' project, learning while enhancing the ToDo sample app. I have added a 'dueOn' field, and that is displayed as swappable ajaxText, similar to the other fields in the tutorial. I have enabled datepicker for the ajaxText
[Lift] Re: slow down ajax?
OK, thanks for checking back... Snippet: swappable(span class='dueon'{task.dueOn.toString}/span, span class='chgDueon'{ajaxText(task.dueOn.toString, v = { task.dueOn(v.toLong).save; reDrawTasks(); }) % (size - 10)}/span) JS: $chgDueon // jQuery selection for text field .datepicker({dateFormat:'m-d-yy', minDate: +1}) .blur(function(){$chgDueon.val(parseDate($chgDueon.val()));}); // works well to pick a new date and change it to millis for save Emitted XHTML: span span class=dueon id=F111290299287IBE onclick=jQuery('#'+'F111290299287IBE').hide(); jQuery('#'+'F1112902992880KN').show().each(function(i) { var t = this; setTimeout(function() { t.focus(); }, 200);});return false;; 1248493271843/span span style=display: none id=F1112902992880KN onblur=jQuery('#'+'F111290299287IBE').show(); jQuery('#'+'F1112902992880KN').hide(); input onblur=lift_ajaxHandler('F111290299286DL1=' + encodeURIComponent(this.value), null, null) type=text value=1248493271843 onkeypress=lift_blurIfReturn(event) size=10 / /span /span So, all the parts work well together, but Lift's ajax just takes off too quickly, and cannot read the new value. On Aug 16, 11:02 pm, marius d. marius.dan...@gmail.com wrote: You can probably use this definition of ajaxText: def ajaxText(value: String, jsFunc: Call, func: String = JsCmd) See the jsFunc parameter. Essentially you are specifying your function call that may have one parameter. To your parameter list List we'll add a new parameter which is the ajax invocation function. In other words your code gets that function that does the ajax call meaning that you have the control over when the ajax call is made. Br's, Marius On Aug 17, 8:55 am, marius d. marius.dan...@gmail.com wrote: Would you please post a code snippet with what you're doing? (a minimalistic example) Br's, Marius On Aug 17, 7:41 am, g-man gregor...@gmail.com wrote: I am moving nicely with my 'save all dates as millis and let the client localize for display' project, learning while enhancing the ToDo sample app. I have added a 'dueOn' field, and that is displayed as swappable ajaxText, similar to the other fields in the tutorial. I have enabled datepicker for the ajaxText field via jQuery, and have a parsing function attached an event listener, so when datepicker finishes, the date is converted to millis, ready for Lift to send back to the server and save. So far, all good. The problem is that Lift's ajax starts ('onblur') before it has a chance to see the new date value, so the new value is never saved. What I need is a way to tell Lift to wait until after my parser has had a chance to write the changed value. I like the ajax style, so I don't want to make a 'submit' form, and 'onchange' won't do it either, because the value is actually changed twice (once to a formatted date, once to millis). What I need is some way to say, 'OK to start ajax now'! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] slow down ajax?
I am moving nicely with my 'save all dates as millis and let the client localize for display' project, learning while enhancing the ToDo sample app. I have added a 'dueOn' field, and that is displayed as swappable ajaxText, similar to the other fields in the tutorial. I have enabled datepicker for the ajaxText field via jQuery, and have a parsing function attached an event listener, so when datepicker finishes, the date is converted to millis, ready for Lift to send back to the server and save. So far, all good. The problem is that Lift's ajax starts ('onblur') before it has a chance to see the new date value, so the new value is never saved. What I need is a way to tell Lift to wait until after my parser has had a chance to write the changed value. I like the ajax style, so I don't want to make a 'submit' form, and 'onchange' won't do it either, because the value is actually changed twice (once to a formatted date, once to millis). What I need is some way to say, 'OK to start ajax now'! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: New Mapped Fields (MappedTimestamp and MappedMac)
I've been working on implementing a better Date solution in my apps, and the best one I have found is to use a Long to store the instant in millis, then pass that down the line in response, let JavaScript do all the conversions to display and validations for submission client- side, and then send back millis in a request. It's just an world-wide instant in time, after all, with no time zone (UTC), and I can do all my date math easily with millis. True, it's not human-readable in the database, but so what? True, relying on JS may not be a universal solution, but how many users don't have JavaScript turned on? This approach would fit in well with your idea, being a Long, but I see no need to bring in the Date object at all. Even if you want to let the Java Date do any work, it can still use the millis perfectly, and mySQL strips off the milli-portion of its timestamp data type anyway, which is why it's useless. Walks like a Date, talks like a Date, but it's a milli... On Jul 30, 5:53 pm, Peter Robinett pe...@bubblefoundry.com wrote: Hi all, As some of you may have noticed, I have been playing around with timestamps[1] and mac addresses[2] in my models. I really like Mapper's specialized fields, both to make it easier for people to read model definitions and to better ensure that only valid values are used along all levels of the service, from the persistence to the presentation layers. So, I would like to propose an effort to develop more specialized fields, starting with MappedTimestamp and MappedMac. I talked to David today and he is willing to provide some advice. Hopefully this will prove a useful way for me to improve my Scala knowledge and contribute to Lift. Focusing just on the two mapped fields I mentioned, do you have any comments how that should be implemented? My thinking is that MappedTimestamp would be stored as a java.util.date and MappedMac as a String, converting both of them to Longs for the database in the interest of saving space. Are there any other mapped fields you'd like to see? I'll add that I think using the units compiler plugin[3] looks cool[4] but probably would be considered to create an unacceptable dependency. Peter Robinett [1]:http://groups.google.com/group/liftweb/browse_thread/thread/b4bdedfb7... [2]:http://groups.google.com/group/liftweb/browse_thread/thread/41650fc1e... [3]:https://lampsvn.epfl.ch/trac/scala/browser/compiler-plugins/units/trunk [4]:http://www.michaelnygard.com/blog/2009/05/units_of_measure_in_scala.html --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Timestamps, Mapper, and MySQL
I, too, want to get a better grip on managment of dates and times, and for me the first step is to record everything as a UTC instance in my DB (MySQL). What I need to do is to have a way to make the client browser include a 'Date' HTTP Header in every request. From that, I can get the timezone and set a SessionVar to use in translating the particular data back to the correct timezone in the response. As it is now, it looks like only: GET /ajax_request/liftAjax.js HTTP/1.1 Host: User-Agent: Accept: Accept-Language: Accept-Encoding: Accept-Charset: Keep-Alive: Connection: Referer: Cookie: are sent over. Lift and Scala are fun! On Jul 15, 12:30 pm, Peter Robinett pe...@bubblefoundry.com wrote: As others have encountered before[1], MappedDateTime has some limitations. Unlike others I'm not losing my time information: in my MySQL database correct datetimes are stored. However, the datetimes are in my local timezone, not GMT. I could change the MySQL timezone but I'd rather not rely on that. Given this and because I would like to store millisecond timestamps and MySQL's native timestamp column type only stores timestamps to the second, I figure using an unsigned BIGINT would be best. Assuming that is a reasonable decision (please tell me if you think it isn't), what is the best way to map to this database column? One solution I see is to just use a MappedLong. However, then I would have to manually convert to and from usable Dates and so on. I see that Joda Time is a popular replacement for java.util.Date but I don't know how to beginning using it as a MappedField. Could someone advise me? Finally, given the common need for timestamp fields, would it make sense to create a MappedTimestamp MappedField? If so, how would I go about doing this? As you can tell, I am quite new to Lift and Scala but this would be a good way to improve my knowledge and to contribute to Lift. What do you think? I look forward to your thoughts! Peter Robinett [1]:http://groups.google.com/group/liftweb/browse_thread/thread/a3755d82f... --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Creating a project
I have been working on a project for a while, so I haven't needed to use it, but I found this in my collection of .bat files: cd C:\Liftweb mvn archetype:generate -DarchetypeCatalog=http://scala-tools.org/ ... that way, you get a bunch of choices during the creation process, as I recall. Yes, Lift is young, and is in more of the 'for programmers' phase than the 'for everyone' phase as far as books and instructional websites go, but things are moving fast! Try it out and see what you can create, then report back with what you have learned, as many here do... On Jul 3, 4:00 pm, Douglas Quaid lee.ami...@gmail.com wrote: I heard some good vibes about Lift and then I saw this gem in the Getting Started documentation for creating a project: From a command prompt, type: mvn archetype:generate -U \ -DarchetypeGroupId=net.liftweb \ -DarchetypeArtifactId=lift-archetype-basic \ -DarchetypeVersion=1.0 \ -DremoteRepositories=http://scala-tools.org/repo-releases\ -DgroupId=com.liftworkshop \ -DartifactId=todo \ -Dversion=0.1-SNAPSHOT Perhaps you guys could innovate and wrap this crap (rhyme!) in a shell script. Good day! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: can a Snippet call a Snippet?
The open_! came right from the 'Getting Started' Todo tutorial I am enhancing: Listing 17: list method in TD class def list(html: NodeSeq) = { val id = S.attr(all_id).open_! Nevertheless, the question remains: How can I filter the Todo items by a Tag and render the list? I guess I could always link to a new page and let the template drive the snippet, but I kind of wanted to keep one page open and just do AJAX stuff within div elements. Thanks again.. On Jul 2, 5:46 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Jul 1, 2009 at 10:43 PM, g-man gregor...@gmail.com wrote: I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr (todos).open_! Don't use open_! It's dangerous. That's why Boxes exist. They contain (or don't) something that may or may not exist. If you use open_! in your code, it is a major mistake (a logic error) unless the line before the open contains if (thing.isDefined) { Thanks, David Here's my layout: todo.html template lift:TD.listTodos todos=todos --- Todo list table stuff --- lift:TD.listTags tags=tags --- Tag list table stuff (where the selection to filter comes from) --- TD.scala snippet = // this arity is for the default 'show all Todos' condition def list(html: NodeSeq) = { val id = S.attr(todos).open_! // this arity is for the 'filter by Tag' case def list(filterTag: Long)(html: NodeSeq) = { val id = S.attr(todos).open_! The two snippet methods could probably be combined with a (param: Long*) signature, but Scala does not seem to care right now. The default works perfectly, but when a Tag is selected to filter by, the 'todos' id Box cannot be seen when attempting to open. Is this because it is probably out of scope? I am using an ajaxbutton to make the call and pass in the tag.id, but it is hard to see how an S.attr could exist for one request, then be gone for the next, unless I am confusing this with a stateful attribute. On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote: I will look into the nested snippets. For expediency, I folded all the snippets that interact with my template into one file, so I can concentrate on the business logic. For my Todo app enhancement, I need to pass the id of my selected Tag (which I have confirmed is correctly gathered from the page request) in to the TD.list method, so that the filtered Todos (those bearing the required Tag) will be found and rendered. My problem is that if I try to pass an additional argument (tagId: Long), the TD.list method is not happy and will not even render the template. I have tried both paired (html: NodeSeq, tagId: Long) as well as curried style (html: NodeSeq)(tagId: Long), but neither works. Try: list(tagId: Long)(html: NodeSeq): NodeSeq That way list(44L) _ becomes a NodeSeq = NodeSeq There must be a simple way to accomplish such a common task! Thanks to all the members for commenting... On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote: Or you can use S.locateMappedSnippet ... but first try to see if nested snippet won't do the trick for you ... On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote: Can you paste some code? Essentially we support nested snippets so your snippet can simply return a markup containing another snippet and it will be invoked. If you really want to manually invoke a snippet from another snippet and if you are not using StatefulSnippets you can just instantiate the class and call your function and pass it the right NodeSeq. Br's, Marius On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote: I am enhancing the Todo app by adding tags. I have retained the TD.scala snippet to manage the Todos on my page, and added a TG.scala snippet to handle tags on the same page, which works well for creating new and listing in both cases. Now I want to filter my Todos list by a Tag instance I select from my list, and therefore need to pass the id of the selected tag over from the TG snippet to the TD snippet, where it can be used as a filter argument for a find method. The problem is that scala says it cannot find snippet TD, whose method I am calling as TD.list from the TG.scala snippet. I have tried all kinds of explicit importing, but no luck. So, can a snippet call a snippet, or is that controlled only from the web page?- Hide quoted text - - Show quoted text - -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp -- Lift
[Lift] Re: can a Snippet call a Snippet?
I will look into the nested snippets. For expediency, I folded all the snippets that interact with my template into one file, so I can concentrate on the business logic. For my Todo app enhancement, I need to pass the id of my selected Tag (which I have confirmed is correctly gathered from the page request) in to the TD.list method, so that the filtered Todos (those bearing the required Tag) will be found and rendered. My problem is that if I try to pass an additional argument (tagId: Long), the TD.list method is not happy and will not even render the template. I have tried both paired (html: NodeSeq, tagId: Long) as well as curried style (html: NodeSeq)(tagId: Long), but neither works. There must be a simple way to accomplish such a common task! Thanks to all the members for commenting... On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote: Or you can use S.locateMappedSnippet ... but first try to see if nested snippet won't do the trick for you ... On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote: Can you paste some code? Essentially we support nested snippets so your snippet can simply return a markup containing another snippet and it will be invoked. If you really want to manually invoke a snippet from another snippet and if you are not using StatefulSnippets you can just instantiate the class and call your function and pass it the right NodeSeq. Br's, Marius On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote: I am enhancing the Todo app by adding tags. I have retained the TD.scala snippet to manage the Todos on my page, and added a TG.scala snippet to handle tags on the same page, which works well for creating new and listing in both cases. Now I want to filter my Todos list by a Tag instance I select from my list, and therefore need to pass the id of the selected tag over from the TG snippet to the TD snippet, where it can be used as a filter argument for a find method. The problem is that scala says it cannot find snippet TD, whose method I am calling as TD.list from the TG.scala snippet. I have tried all kinds of explicit importing, but no luck. So, can a snippet call a snippet, or is that controlled only from the web page?- Hide quoted text - - Show quoted text - --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: can a Snippet call a Snippet?
I'm getting a Null Pointer: 'Trying to open an empty box', from S.attr (todos).open_! Here's my layout: todo.html template lift:TD.listTodos todos=todos --- Todo list table stuff --- lift:TD.listTags tags=tags --- Tag list table stuff (where the selection to filter comes from) --- TD.scala snippet = // this arity is for the default 'show all Todos' condition def list(html: NodeSeq) = { val id = S.attr(todos).open_! // this arity is for the 'filter by Tag' case def list(filterTag: Long)(html: NodeSeq) = { val id = S.attr(todos).open_! The two snippet methods could probably be combined with a (param: Long*) signature, but Scala does not seem to care right now. The default works perfectly, but when a Tag is selected to filter by, the 'todos' id Box cannot be seen when attempting to open. Is this because it is probably out of scope? I am using an ajaxbutton to make the call and pass in the tag.id, but it is hard to see how an S.attr could exist for one request, then be gone for the next, unless I am confusing this with a stateful attribute. On Jul 1, 2:42 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Jul 1, 2009 at 2:28 PM, g-man gregor...@gmail.com wrote: I will look into the nested snippets. For expediency, I folded all the snippets that interact with my template into one file, so I can concentrate on the business logic. For my Todo app enhancement, I need to pass the id of my selected Tag (which I have confirmed is correctly gathered from the page request) in to the TD.list method, so that the filtered Todos (those bearing the required Tag) will be found and rendered. My problem is that if I try to pass an additional argument (tagId: Long), the TD.list method is not happy and will not even render the template. I have tried both paired (html: NodeSeq, tagId: Long) as well as curried style (html: NodeSeq)(tagId: Long), but neither works. Try: list(tagId: Long)(html: NodeSeq): NodeSeq That way list(44L) _ becomes a NodeSeq = NodeSeq There must be a simple way to accomplish such a common task! Thanks to all the members for commenting... On Jun 29, 11:25 pm, marius d. marius.dan...@gmail.com wrote: Or you can use S.locateMappedSnippet ... but first try to see if nested snippet won't do the trick for you ... On Jun 30, 10:17 am, marius d. marius.dan...@gmail.com wrote: Can you paste some code? Essentially we support nested snippets so your snippet can simply return a markup containing another snippet and it will be invoked. If you really want to manually invoke a snippet from another snippet and if you are not using StatefulSnippets you can just instantiate the class and call your function and pass it the right NodeSeq. Br's, Marius On Jun 30, 5:36 am, g-man gregor...@gmail.com wrote: I am enhancing the Todo app by adding tags. I have retained the TD.scala snippet to manage the Todos on my page, and added a TG.scala snippet to handle tags on the same page, which works well for creating new and listing in both cases. Now I want to filter my Todos list by a Tag instance I select from my list, and therefore need to pass the id of the selected tag over from the TG snippet to the TD snippet, where it can be used as a filter argument for a find method. The problem is that scala says it cannot find snippet TD, whose method I am calling as TD.list from the TG.scala snippet. I have tried all kinds of explicit importing, but no luck. So, can a snippet call a snippet, or is that controlled only from the web page?- Hide quoted text - - Show quoted text - -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] can a Snippet call a Snippet?
I am enhancing the Todo app by adding tags. I have retained the TD.scala snippet to manage the Todos on my page, and added a TG.scala snippet to handle tags on the same page, which works well for creating new and listing in both cases. Now I want to filter my Todos list by a Tag instance I select from my list, and therefore need to pass the id of the selected tag over from the TG snippet to the TD snippet, where it can be used as a filter argument for a find method. The problem is that scala says it cannot find snippet TD, whose method I am calling as TD.list from the TG.scala snippet. I have tried all kinds of explicit importing, but no luck. So, can a snippet call a snippet, or is that controlled only from the web page? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
OK, things are working well with RequestVar, but now I need to know how to kill it! After I create and save my record, if I refresh the browser, I get another record created. I did a temporary hack-fix with: if(! myRecord.saved_?) but I would just like to kill the RequestVar after the first round of record creation-saving. In terms of your example above, how would I do that? On Jun 8, 7:18 am, Derek Chen-Becker dchenbec...@gmail.com wrote: Generally you can either use RequestVars or a StatefulSnippet class to keep the values around on form resubmission. If you're using a Mapper class, you really just need one RequestVar to hold your Mapper instance. For example, if I had a Mapper class for a person with first name, last name and email, I could do something like this in my snippet class: ... // Set the up the RequstVar to initialize a new MyUserClass by default object userVar extends RequestVar[MyUserClass](MyUserClass.create) def editMyUser (xhtml : NodeSeq) : NodeSeq = { // We define a val to capture the current value of the userVar. This will be used to reinject later, as well // as for current access val current = userVar.is ... def saveMyUser () { current.validate match { ... ... current.save } } bind(user, xhtml, // First we re-inject the current MyUserClass instance using a hidden field current - SHtml.hidden(() = userVar(current)) // normal fields follow, e.g. name - SHtml.text(current.name.is, current.name(_)) // alternatively, you could do both steps in the first form field: name - SHtml.text(current.name.is, { in = userVar(current); current.name(in) }) ... ) } ... Let me know if you have any questions on that. Derek On Fri, Jun 5, 2009 at 9:47 PM, g-man gregor...@gmail.com wrote: I now have the due date arriving OK from the jQuery datepicker, and I cobbled together some ugliness to give days left until the ToDo due date, so that is good. My problem now is since we are not using the 'magic' of the _toForm methods for the form elements, I have to set each var value for the model field from the input SHtml data, as was done in the PocketChange app AddEntry.scala file. What is happening is that the initialization for each var is resetting the form if validation fails, so I guess I need to institute some RequestVars to remember the form values for resubmission, right? All my questions will take take the form of 'how to' recipes of foundational webapp elements, as you can see. My plan is to develop them for a 'cookbook' section of the wiki, so that's why I am asking one simple conceptual thing at a time. Therefore, what I have to learn now is all about form binding and recalling form value state if validation fails, so please break that down for me. Thanks as always! On Jun 3, 10:25 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: Box is the base class. What you want is Full(2). Derek On Wed, Jun 3, 2009 at 8:53 PM, g-man gregor...@gmail.com wrote: Very good! I did a little homework, rearranged some things, and am getting some nice results with the 'manual method'... Since I am following the PocketChange app now rather than the ToDo example, there is no 'todo' val in scope to bind, so the todo.priority.toForm method will not work. I have SHtml.select working with a mapping for my choices, and I can use Empty for my default, but how do I get a Box[2] as my default? On Jun 3, 7:21 am, Derek Chen-Becker dchenbec...@gmail.com wrote: The only issue I would mention is that there's currently an open ticket because MappedDateTime won't save the time portion when you use Derby. I haven't had time to triage this yet. Derek On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett timo...@getintheloop.eu wrote: Greg, I dont really use toForm; have you explored doing it manually? It seems like that would be able to tell you if there is a problem with toForm on MappedDateTime. I use mapped date time quite a bit and have no problems at all persisting the dates :-) Cheers, Tim On Jun 3, 3:09 am, g-man gregor...@gmail.com wrote: Are there no ideas for my problem? I have many more questions saved up, but would like to clear each out before starting a new one. Thanks again! On May 31, 1:57 pm, g-man gregor...@gmail.com wrote: As I proceed to enhance the ToDo example, I have added a new field to the ToDo.scala model: object dueOn extends MappedDateTime(this) { final val dateFormat = DateFormat.getDateInstance (DateFormat.SHORT) override def asHtml = Text(dateFormat.format(is))} Next, I added a binding in the TD.scala snippet within the add
[Lift] Re: Deployment questions and little Java web dev experience
I came from a similar background, but with some detours after Rails through Erlang, GAE w/ Django, and web2py. It took me about 2 months to finally start having fun with Lift and Scala, but I can tell you now it's really nice to just sit down, write something, and watch it work! I'm no expert yet, and I'm constantly reading all the books I can find, but the rewards and power are definitely there. Where I needed dozens of files with Rails, I only need 3 models, 3 snippets, and 2 templates now, and they are far cleaner! My advice is to slow down, do the 'ToDo' app tutorial, and then start adding functionality to it. As you add features, you will research and learn about new things and how to do them. As a study aid, I keep the 'PocketChange' app from the book open, and look to see how similar problems were solved there. As they say, almost everything you need to know is contained in those two examples. As to all the niceties of the servers and deployment to a VPS, I suggest you leave that for later. The little Jetty thing running on localhost will give you a taste of how Maven sets up things, and how to tweak them (adding logging, comments, debugging messages, etc), plus you always have the Group here for help. Lift (and Scala) are both very young, so it will take a while for all the books, websites, tutorials, and videos to come out. Imagine Rails 5 years ago and you have some idea of where we are, and that's not even considering the new 'Goat Rodeo' project... No worries -- have fun! On Jun 19, 1:09 pm, Nolan Darilek no...@thewordnerd.info wrote: Hi, all. I'm new to Lift and have a few questions about using it. For background, I'm coming from Ruby to Scala, having finally been frustrated by some aspects of the former enough to try jumping ship. I know Java syntax, but the simplicity of Ruby has always been a powerful draw for me, so when I used Java I always stayed away from Maven and other cornerstones of the Java tool community. I say all of this not to stir up Ruby vs. Scala drama (because we just don't have enough of that already :P ) but to explain that I'm mistified by much of the Java ecosystem, and a lot of what's out there seems to take it for granted that I know all of this. So please pardon my newbie questions, and feel free to point me to the FM on the subject if there is one, because I've certainly been *trying* to RTFM. :) I also recognize that these topics aren't specific to Lift, but I figure I'm likely to find more proponents of low ceremony in the Scala community than I'd find if I seeked out some more general purpose Java enterprise deployment resource. First...servlets? Web containers? App servers? Oh my. I want to write a few hobbyist apps with Lift and deploy them to my VPS. They may or may not take off, in which case I'd like a solution that can scale to real-world use. Not heavy real-world use, mind you, but I figure a separate VM/port for every app instance is overkill. So what do I need for this? I gather the app server is what handles arranging web apps in a single VM instance, but it's tough cutting through all the enterprise language to figure out which one of these is best for my circumstances, especially since I'm not dealing with legacy code and just want to launch hobbyist/personal projects. And I can't for the life of me figure out whether Tomcat is an app server or something else entirely. This seems so much more complicated than just throwing up a few Mongrels and a load balancer, or reading through the nicely-written Passenger manual and following the step-by-step instructions. I'm sure it has its advantages, I just can't get a grip on how it works. I've also been reading a lot about OSGi and it looks really nice. Am I correct in assuming that OSGi is to Java web apps what Rack is to Ruby ones? OK, maybe not exactly, and I know it's a more general-purpose mechanism (I'm toying with ScalaModules in a desktop app for providing pluggable UIs and other services) but in poking through OSGi articles, I've read a few statements hinting that this is probably the best way to deploy new apps with no legacy dependencies. Is this true? Is an app server actually needed here, or do I just create an OSGi execution environment and start adding bundles? It seems like the way to deploy an app is to build a war file and drop it into a specific directory of your servlet/app server/doohicky-whatamajig serverletcontainerthingie. It also looks as if all apps are installed into the same HTTP namespace, with URL path collisions resolved by editing web.xml and prepending something to the /* for the map elements. Is this accurate? Or is it possible to have the server prepend /myapp or /myapp.war based on the name of the deployed app, then handle the mappings via ProxyPass in the front-end server? That's closer to what I'm used to in Ruby, where the app takes over the URL namespace beneath whatever path you assign it, but it's not clear
[Lift] Scala learning tool
All the Scala books and tutorials recommend using the Scala interactive shell to set up scenarios and learn how Scala works. I agree, but my problem was the (apparent) lack of something like Python's dir(object) call, which gives you all the 'names' available; Ruby and Erlang have similar commands, but not, as far as I know, Scala. I did find a little script that does just that at: http://lousycoder.com/blog/index.php?/archives/91-Scala-Querying-an-objects-fields-and-methods-with-reflection.html with the source at: http://gist.github.com/87519 I compiled it, and when I import it, it works just dandy: scala import ScalaReflection._ import ScalaReflection._ scala 3.methods__ hashCode reverseBytes(int) compareTo(Object) compareTo(Integer) equals(Object) toString(int,int) toString(int) ... scala 3.fields__ MIN_VALUE MAX_VALUE TYPE digits DigitTens DigitOnes sizeTable value SIZE serialVersionUID Perhaps there is something like this already built-in to Scala, but I can't find it... if not, it may be worthwhile adding. Now, what I want to know is: is there a way to load an actual Lift session into the interactive command interpreter, so I can create and check out out functions, etc? I remember doing that with Ruby and Rails back in the day. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Mapper record deletion
Thanks, I'm working on it. It seems, after reading the Lift book, since we have 'Alert' in the list of basic JsCmds in Table 8.2, a companion 'Confirm' (and perhaps even 'Prompt') command would be logical to have, since these are basic and popular user interface elements. On Jun 16, 6:46 am, Magnus Alvestad magnus.alves...@gmail.com wrote: As I move deeper into learning Lift, I now want to start deleting Mapper records in the ToDo example. Here's how I did it (based on suggestions in this group, I think): bind ( question, html, text - .., delete - ajaxButton(Text(Remove), Call(dialog, Str(Do you want to delete the question?)), () = {q.delete_!; S.notice( Deleted the question!); reDraw ()}) ) .. and then in the template (default.html) .. script type=javascript function dialog(text, theCall) { if (confirm(text)) theCall(); } /script -Magnus --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Mapper record deletion
As I move deeper into learning Lift, I now want to start deleting Mapper records in the ToDo example. My first problem is how to get an ECMAscript or jQuery 'Confirm delete' dialog to actually delegate an affirmative 'OK' button click to the deletion, and conversely, to do nothing for the 'Cancel' action. Right now, both just fall through to the default: toShow.flatMap(td = bind(todo, html, delete - link(/todo, () = td.delete_!, img src=../images/cross.png/)% (onclick - confirm();) , check - ... Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
Nice! Things are moving now, thanks to your guidance. It's a matter of: 1) knowing what you want to do, and 2) knowing how to do things with Scala... duh, yea. I will post my results in a few days after I get everything working well, but the RequestVar is doing its job. On Jun 8, 7:18 am, Derek Chen-Becker dchenbec...@gmail.com wrote: Generally you can either use RequestVars or a StatefulSnippet class to keep the values around on form resubmission. If you're using a Mapper class, you really just need one RequestVar to hold your Mapper instance. For example, if I had a Mapper class for a person with first name, last name and email, I could do something like this in my snippet class: ... // Set the up the RequstVar to initialize a new MyUserClass by default object userVar extends RequestVar[MyUserClass](MyUserClass.create) def editMyUser (xhtml : NodeSeq) : NodeSeq = { // We define a val to capture the current value of the userVar. This will be used to reinject later, as well // as for current access val current = userVar.is ... def saveMyUser () { current.validate match { ... ... current.save } } bind(user, xhtml, // First we re-inject the current MyUserClass instance using a hidden field current - SHtml.hidden(() = userVar(current)) // normal fields follow, e.g. name - SHtml.text(current.name.is, current.name(_)) // alternatively, you could do both steps in the first form field: name - SHtml.text(current.name.is, { in = userVar(current); current.name(in) }) ... ) } ... Let me know if you have any questions on that. Derek On Fri, Jun 5, 2009 at 9:47 PM, g-man gregor...@gmail.com wrote: I now have the due date arriving OK from the jQuery datepicker, and I cobbled together some ugliness to give days left until the ToDo due date, so that is good. My problem now is since we are not using the 'magic' of the _toForm methods for the form elements, I have to set each var value for the model field from the input SHtml data, as was done in the PocketChange app AddEntry.scala file. What is happening is that the initialization for each var is resetting the form if validation fails, so I guess I need to institute some RequestVars to remember the form values for resubmission, right? All my questions will take take the form of 'how to' recipes of foundational webapp elements, as you can see. My plan is to develop them for a 'cookbook' section of the wiki, so that's why I am asking one simple conceptual thing at a time. Therefore, what I have to learn now is all about form binding and recalling form value state if validation fails, so please break that down for me. Thanks as always! On Jun 3, 10:25 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: Box is the base class. What you want is Full(2). Derek On Wed, Jun 3, 2009 at 8:53 PM, g-man gregor...@gmail.com wrote: Very good! I did a little homework, rearranged some things, and am getting some nice results with the 'manual method'... Since I am following the PocketChange app now rather than the ToDo example, there is no 'todo' val in scope to bind, so the todo.priority.toForm method will not work. I have SHtml.select working with a mapping for my choices, and I can use Empty for my default, but how do I get a Box[2] as my default? On Jun 3, 7:21 am, Derek Chen-Becker dchenbec...@gmail.com wrote: The only issue I would mention is that there's currently an open ticket because MappedDateTime won't save the time portion when you use Derby. I haven't had time to triage this yet. Derek On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett timo...@getintheloop.eu wrote: Greg, I dont really use toForm; have you explored doing it manually? It seems like that would be able to tell you if there is a problem with toForm on MappedDateTime. I use mapped date time quite a bit and have no problems at all persisting the dates :-) Cheers, Tim On Jun 3, 3:09 am, g-man gregor...@gmail.com wrote: Are there no ideas for my problem? I have many more questions saved up, but would like to clear each out before starting a new one. Thanks again! On May 31, 1:57 pm, g-man gregor...@gmail.com wrote: As I proceed to enhance the ToDo example, I have added a new field to the ToDo.scala model: object dueOn extends MappedDateTime(this) { final val dateFormat = DateFormat.getDateInstance (DateFormat.SHORT) override def asHtml = Text(dateFormat.format(is))} Next, I added a binding in the TD.scala snippet within the add method of the TD class: def doBind(form: NodeSeq) = { bind(todo, form
[Lift] Re: date management
I now have the due date arriving OK from the jQuery datepicker, and I cobbled together some ugliness to give days left until the ToDo due date, so that is good. My problem now is since we are not using the 'magic' of the _toForm methods for the form elements, I have to set each var value for the model field from the input SHtml data, as was done in the PocketChange app AddEntry.scala file. What is happening is that the initialization for each var is resetting the form if validation fails, so I guess I need to institute some RequestVars to remember the form values for resubmission, right? All my questions will take take the form of 'how to' recipes of foundational webapp elements, as you can see. My plan is to develop them for a 'cookbook' section of the wiki, so that's why I am asking one simple conceptual thing at a time. Therefore, what I have to learn now is all about form binding and recalling form value state if validation fails, so please break that down for me. Thanks as always! On Jun 3, 10:25 pm, Derek Chen-Becker dchenbec...@gmail.com wrote: Box is the base class. What you want is Full(2). Derek On Wed, Jun 3, 2009 at 8:53 PM, g-man gregor...@gmail.com wrote: Very good! I did a little homework, rearranged some things, and am getting some nice results with the 'manual method'... Since I am following the PocketChange app now rather than the ToDo example, there is no 'todo' val in scope to bind, so the todo.priority.toForm method will not work. I have SHtml.select working with a mapping for my choices, and I can use Empty for my default, but how do I get a Box[2] as my default? On Jun 3, 7:21 am, Derek Chen-Becker dchenbec...@gmail.com wrote: The only issue I would mention is that there's currently an open ticket because MappedDateTime won't save the time portion when you use Derby. I haven't had time to triage this yet. Derek On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett timo...@getintheloop.eu wrote: Greg, I dont really use toForm; have you explored doing it manually? It seems like that would be able to tell you if there is a problem with toForm on MappedDateTime. I use mapped date time quite a bit and have no problems at all persisting the dates :-) Cheers, Tim On Jun 3, 3:09 am, g-man gregor...@gmail.com wrote: Are there no ideas for my problem? I have many more questions saved up, but would like to clear each out before starting a new one. Thanks again! On May 31, 1:57 pm, g-man gregor...@gmail.com wrote: As I proceed to enhance the ToDo example, I have added a new field to the ToDo.scala model: object dueOn extends MappedDateTime(this) { final val dateFormat = DateFormat.getDateInstance (DateFormat.SHORT) override def asHtml = Text(dateFormat.format(is))} Next, I added a binding in the TD.scala snippet within the add method of the TD class: def doBind(form: NodeSeq) = { bind(todo, form, desc - todo.desc.toForm, priority - todo.priority.toForm, dueOn - todo.dueOn.toForm, submit - submit(create new Task, checkAndSave)} Then, the todo.html template gets a bind point: lift:TD.add form=post ... todo:dueOn/ todo:submitbutton//todo:submit /lift:TD.add When I check the database, the record does save, and all the other fields are OK, but the date itself is null. Somehow, it seems the text of the input field is not getting changed into a Date object for the database to handle, right? When I look at the PocketChange app from the book, everything is done completely differently from the ToDo example (no use of _toForm, for instance). I know dates and times are convoluted in Java, so what am I missing? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
Very good! I did a little homework, rearranged some things, and am getting some nice results with the 'manual method'... Since I am following the PocketChange app now rather than the ToDo example, there is no 'todo' val in scope to bind, so the todo.priority.toForm method will not work. I have SHtml.select working with a mapping for my choices, and I can use Empty for my default, but how do I get a Box[2] as my default? On Jun 3, 7:21 am, Derek Chen-Becker dchenbec...@gmail.com wrote: The only issue I would mention is that there's currently an open ticket because MappedDateTime won't save the time portion when you use Derby. I haven't had time to triage this yet. Derek On Wed, Jun 3, 2009 at 3:01 AM, Timothy Perrett timo...@getintheloop.euwrote: Greg, I dont really use toForm; have you explored doing it manually? It seems like that would be able to tell you if there is a problem with toForm on MappedDateTime. I use mapped date time quite a bit and have no problems at all persisting the dates :-) Cheers, Tim On Jun 3, 3:09 am, g-man gregor...@gmail.com wrote: Are there no ideas for my problem? I have many more questions saved up, but would like to clear each out before starting a new one. Thanks again! On May 31, 1:57 pm, g-man gregor...@gmail.com wrote: As I proceed to enhance the ToDo example, I have added a new field to the ToDo.scala model: object dueOn extends MappedDateTime(this) { final val dateFormat = DateFormat.getDateInstance (DateFormat.SHORT) override def asHtml = Text(dateFormat.format(is))} Next, I added a binding in the TD.scala snippet within the add method of the TD class: def doBind(form: NodeSeq) = { bind(todo, form, desc - todo.desc.toForm, priority - todo.priority.toForm, dueOn - todo.dueOn.toForm, submit - submit(create new Task, checkAndSave)} Then, the todo.html template gets a bind point: lift:TD.add form=post ... todo:dueOn/ todo:submitbutton//todo:submit /lift:TD.add When I check the database, the record does save, and all the other fields are OK, but the date itself is null. Somehow, it seems the text of the input field is not getting changed into a Date object for the database to handle, right? When I look at the PocketChange app from the book, everything is done completely differently from the ToDo example (no use of _toForm, for instance). I know dates and times are convoluted in Java, so what am I missing? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: date management
Are there no ideas for my problem? I have many more questions saved up, but would like to clear each out before starting a new one. Thanks again! On May 31, 1:57 pm, g-man gregor...@gmail.com wrote: As I proceed to enhance the ToDo example, I have added a new field to the ToDo.scala model: object dueOn extends MappedDateTime(this) { final val dateFormat = DateFormat.getDateInstance (DateFormat.SHORT) override def asHtml = Text(dateFormat.format(is))} Next, I added a binding in the TD.scala snippet within the add method of the TD class: def doBind(form: NodeSeq) = { bind(todo, form, desc - todo.desc.toForm, priority - todo.priority.toForm, dueOn - todo.dueOn.toForm, submit - submit(create new Task, checkAndSave)} Then, the todo.html template gets a bind point: lift:TD.add form=post ... todo:dueOn/ todo:submitbutton//todo:submit /lift:TD.add When I check the database, the record does save, and all the other fields are OK, but the date itself is null. Somehow, it seems the text of the input field is not getting changed into a Date object for the database to handle, right? When I look at the PocketChange app from the book, everything is done completely differently from the ToDo example (no use of _toForm, for instance). I know dates and times are convoluted in Java, so what am I missing? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Future of the Lift wiki
Having gone through Rails, the Google App Engine with Django, and web2py over the last four years, I have seen it all as far as learning new frameworks goes, and I have posted a few ideas on that subject both here and on the book group. For those of us spoiled by the wealth of learning material on Rails, and to a lesser degree Django and web2py, all I can say is: 'Lift is a new framework, and a sophisticated one at that, which uses a new language derived from a convoluted one, and is at a relatively early stage of development, so therefore the designers are forging ahead to completion of the foundation, and thus there are few who can devote the time to creating the documentation we newcomers need.' My post on the book group defined the three classes of useful documents to be the Guidebook, the Encyclopedia, and the Cookbook. My role for the wiki is to hold Cookbook recipes which answer the most common 'how to' questions we encounter when building a website. In my personal learning quest, I am extending the 'ToDo' app by adding pieces of functionality, like many-to-many tagging, date manipulation, deletion, an admin interface, etc. As I come across solutions or questions, I post those on the group in order to help others and to get improvements and refinements from the members. David is right... Lift and Scala together are taking web applications to a whole new level of performance, so naturally it will take a little time to make things happen. By the way, today my copies of David's and Martin's Scala books arrived, and I urge all to purchase them yourselves! On Jun 1, 3:35 pm, Charles F. Munat c...@munat.com wrote: Hi, Xavi, One of my tasks is to come up with a good organization for the wiki and a site map, as well as a list of things we'd like to add to it. Unfortunately, with the coming Scala/Liftoff and OSB conferences, I've been swamped with other things. But I am working on it, albeit slowly. If you have any specific recommendations, please post them. Thanks! Chas. Xavi Ramirez wrote: Hello, I'm a bit confused about the future of the lift wiki. What's the end goal? In an ideal world is it supposed to be the main repository of lift knowledge, or just another documentation source? I personally feel that having one repository of knowledge is much more noob friendly. Currently new members have to navigate through started guides, books, e-mail threads, scala docs, and personal blogs to find relative information. Though the get started guided and book provide a good introduction, it's hard to progress from novice to intermediate with these fragmented resources. Thanks, Xavi --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] date management
As I proceed to enhance the ToDo example, I have added a new field to the ToDo.scala model: object dueOn extends MappedDateTime(this) { final val dateFormat = DateFormat.getDateInstance (DateFormat.SHORT) override def asHtml = Text(dateFormat.format(is))} Next, I added a binding in the TD.scala snippet within the add method of the TD class: def doBind(form: NodeSeq) = { bind(todo, form, desc - todo.desc.toForm, priority - todo.priority.toForm, dueOn - todo.dueOn.toForm, submit - submit(create new Task, checkAndSave)} Then, the todo.html template gets a bind point: lift:TD.add form=post ... todo:dueOn/ todo:submitbutton//todo:submit /lift:TD.add When I check the database, the record does save, and all the other fields are OK, but the date itself is null. Somehow, it seems the text of the input field is not getting changed into a Date object for the database to handle, right? When I look at the PocketChange app from the book, everything is done completely differently from the ToDo example (no use of _toForm, for instance). I know dates and times are convoluted in Java, so what am I missing? Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Tutorial incremental enhancements
As a learning project for myself, I'm adding incremental enhancements to the ToDo app, which could lead to further tutorial chapters: 1. 'Due Date' and reset via datepicker.js, with countdown and warning color when past due. 2. 'Tagging' (many-to-many) with editing, filtering, addition, and removal. 3. 'Sorting by Due Date' and back to 'by Priority'. 4. 'Date Completed' when 'Done' is checked, and undo of 'Done' status with consequent date nullification. 5. 'Deletion of Records' and cascading dependencies. 6. 'Admin Interface' with SuperUser who can delete any records or user and dependent records. Based on experience, it seems a shame for others to have to suffer through the old java Date, Calendar, and other time manipulation classes, so it would be nice to be able to integrate Joda and Scala- Time into Lift, but I'm not that advanced. These elements cover many of the main attributes of practical webapps, and I'm sure many group members have explored them already. I've got a few of these elements partially working, but I don't necessarily want to clog up the group if this is not the place to share information -- is the wiki better? Thanks for all your hard work, David -- there's a lot to chew on in Lift! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Model methods in either Class or Object?
Thanks... Being a hobbyist rather than a professional, my questions will be more conceptual in nature, and may help others learn what I hope to find of the essence of Lift, which includes a little of its java-like heritage, as in the 'static' analogy. I see Lift as a vehicle with 'legs' for the future, meaning it can scale well and handle almost any type of web app, so I want to concentrate on it fully and master it, and I want my understanding to be rock-solid. Therefore, I'm starting with what I see as the foundation of any app, which is the Model, hence my question, which I see now I understood totally backwards! On May 18, 3:05 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Sat, May 16, 2009 at 2:39 PM, g-man gregor...@gmail.com wrote: As I create the Models to define the real-world things of interest to my webapp, I'm wondering what to put into either the class or the object. Here is some pseudocode as I understand the Model table definition pattern: // first comes the class, which defines fields and creates the singleton: class Thing extends LongKeyedMapper[Thing] with IdPK { def getSingleton = Thing // define a field... object field extends mappedWhatever(this) { // and define some constraints and validations for the field... } // global class methods here plus xml, json, etc output... } // then the object: object Thing extends Thing with LongKeyedMetaMapper[Thing] { // define an instance method: def instanceMethod() = { doSomething } // more instance methods, etc... } My question is: how do I know what kinds of methods and other goodies should go into either the class or the object, that is, into each 'half' of the Model specification? The object Thing is a singleton object in your system. It is a good place for methods associated with the model, but not a particular instance of the model. If you're a java programmer, this is the place to put methods that would be static in Java. The class Thing is an instance that contains one model object. Methods on the instance should operate on the instance data. Hope this helps. Thanks, David -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Model methods in either Class or Object?
As I create the Models to define the real-world things of interest to my webapp, I'm wondering what to put into either the class or the object. Here is some pseudocode as I understand the Model table definition pattern: // first comes the class, which defines fields and creates the singleton: class Thing extends LongKeyedMapper[Thing] with IdPK { def getSingleton = Thing // define a field... object field extends mappedWhatever(this) { // and define some constraints and validations for the field... } // global class methods here plus xml, json, etc output... } // then the object: object Thing extends Thing with LongKeyedMetaMapper[Thing] { // define an instance method: def instanceMethod() = { doSomething } // more instance methods, etc... } My question is: how do I know what kinds of methods and other goodies should go into either the class or the object, that is, into each 'half' of the Model specification? --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Fwd: New basketball court(s) near you: 'Mosswood Park'...
A little off-topic perhaps, but have you read how 37signals is using erlang for a little piece of the puzzle?... a href=http://www.37signals.com/svn/posts/1728-nuts-bolts-campfire- loves-erlangCampfire loves Erlang/a Looks like scala's Actors may play a similar role for us! On May 14, 8:40 am, David Pollak feeder.of.the.be...@gmail.com wrote: Folks, Just a reminder about nofouls.com... a Lift powered site. Thanks, David -- Forwarded message -- From: Nofouls nofo...@nofouls.com Date: Wed, May 13, 2009 at 7:41 PM Subject: New basketball court(s) near you: 'Mosswood Park'... To: feeder.of.the.be...@gmail.com The following court(s) have been added to Nofouls: 'Mosswood Park' -http://nofouls.com/court/2717 Remember, your login is: feeder.of.the.be...@gmail.com --- Want to control what emails you receive? Go to:http://nofouls.com/user/me -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: error tickets?
The idea is that the user never sees any internal errors -- if one does happen, it gets ticketed to '/templates-hidden', a redirect occurs, and stuff like this: XML Parsing Error: prefix not bound to a namespace Location: http://localhost:8080/ Line Number 29, Column 15: biTest:user.email/Test:user.email/ibr / ---^ ...is never seen in public. I realize testing will catch most of these, but there are also database errors to be handled, and other unforseen events as well. On May 7, 9:26 am, Timothy Perrett timo...@getintheloop.eu wrote: lol - now i see that also! been out of the loop today Examples wise, it would probally be a good idea for us to do an example implementation of each of the LiftRules PF's as they do tend to provoke a lot of questions on list. Cheers, Tim Yep... this is much like the other exception handling question that came up this morning. If you guys need an example of a handler, please let me know and I'll work something up. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] error tickets?
I'm having a great time learning Lift, and am happy to read all the excellent posts by the growing community of developers... As I experiment and create my app, I naturally get errors, and I was wondering if Lift has, or has considered, an 'error ticket' system like web2py has, where the user never sees an error, but a ticket is created, which is a link to an admin directory (templates-hidden?) where the actual error stack trace is saved. Otherwise, all is well! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: optional validation
Nice -- I'm getting the spirit of Lift now; it's kind of a way of saying 'NULL or Validate', right? On Apr 23, 10:39 am, David Pollak feeder.of.the.be...@gmail.com wrote: How about: class MappedBlankableEmail[T:Mapper[T]](owner: T, maxLen: Int) extends MappedString[T](owner, maxLen) { override def setFilter = notNull _ :: toLower _ :: trim _ :: super.setFilter override def validate = (if (*i_is_!.length == 0 || *MappedEmail.emailPattern.matcher(i_is_!).matches) Nil else List(FieldError(this, Text(S.??(invalid.email.address) ::: super.validate } On Wed, Apr 22, 2009 at 8:10 PM, g-man gregor...@gmail.com wrote: All is going well with my Lift learning... The form field validations are working well, and I especially like the field object types that know what they are, like 'email'. My question is: How do I tell Lift that a Contact's email is optional (empty string is OK), but if it is provided, then validate it? This is not for the regular User model, but only for Contacts I am entering in an address book. Thanks! -- Lift, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow me:http://twitter.com/dpp Git some:http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] optional validation
All is going well with my Lift learning... The form field validations are working well, and I especially like the field object types that know what they are, like 'email'. My question is: How do I tell Lift that a Contact's email is optional (empty string is OK), but if it is provided, then validate it? This is not for the regular User model, but only for Contacts I am entering in an address book. Thanks! --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: developing Scala/Lift using Eclipse
Since Scala is a dialect of Java, and Lift is an extension of that, I went the Netbeans route because NB is basically part of Java, and I am happy so far: - Netbeans is quicker to load than Eclipse, and doesn't create all those zillions of files behind; - Netbeams handles all the moving parts well, and Maven is happy; - Lift and Scala are not that complex that you need any heavy lifting for debugging (I have found) - it's mostly learning the Lift magic about how to make the Derby db, Jetty, and Maven all work together. I agree Eclipse has some nice features, but the light weight of Netbeans tipped the scales for me... Programming is fun again, thanks to Lift! On Apr 20, 2:40 pm, kmed k...@meder.info wrote: Hello all, I just started learning Scala and came across Lift. I am using Eclipse Ganymede with the Scala-Plugin. How do I fully include the Lift- sources to navigate (Strg+Click) into the Lift-Classes? Currently Eclipse does not even understand the absolute _root_-package- thingy. It's pretty annoying if everything is red and only maven knows if it compiles correctly :( Any Hint? Thanks in advance, Kai --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---