[Lift] Re: Re-factored Archetypes
Thanks Tim, good job! On Tue, Aug 25, 2009 at 1:17 AM, Timothy Perrett timo...@getintheloop.euwrote: Guys, As promised, i've re-factored the archetypes (now in their own submodule and building as part of master) however their maven group and artifactId's are the same, so all commands etc will continue to work (its purely a code base organization change) Moreover, i've fixed the various issues with velocity in the jpa-basic archetype (its late here, i'll fix the others 2mro) and i've also fixed the Jetty version in all the pom.xml to a sensible range. Enjoy... Cheers, Tim On Aug 25, 12:02 am, Derek Chen-Becker dchenbec...@gmail.com wrote: Sorry about that. It's a one line commit, so hopefully Git will be able to figure out a sane merge. Derek 2009/8/24 Timothy Perrett timo...@getintheloop.eu Doh... I see you already committed it... (obviously didn’t see my other post); I’ll attempt to do a merge with my local reorganized and fixed archetypes. Tim On 24/08/2009 23:43, Derek Chen-Becker dchenbec...@gmail.com wrote: OK, that seems to have been it. I just pushed a commit and I'll verify once hudson builds it that it's working. Derek On Mon, Aug 24, 2009 at 4:36 PM, Derek Chen-Becker dchenbec...@gmail.com wrote: I think I may have found the issue. I had a packaging element in the pom (none of the other archetypes do, as far as I can tell), so I've removed that and I'm doing a local build to see if that fixes it. Derek 2009/8/24 Timothy Perrett timo...@getintheloop.eu Derek, Im currently reorganizing the lift archetype codebase as we speak, so I’ll look at it now... Cheers, Tim On 24/08/2009 23:03, Derek Chen-Becker dchenbec...@gmail.com http://dchenbec...@gmail.com wrote: OK, anyone with some maven-fu know what's going on here? It looks like the build is fine, but the jar is being copied to a .archetype file instead of .jar: [INFO] Installing /home/scalatools/hudson/.hudson/jobs/Lift/workspace/lift-archetype-jpa-blan k/target/lift-archetype-jpa-blank-1.1-SNAPSHOT.jar to /home/scalatools/hudson/.hudson/jobs/Lift/workspace/.repository/net/liftweb /lift-archetype-jpa-blank/1.1-SNAPSHOT/lift-archetype-jpa-blank-1.1-SNAPSHO T.maven-archetype Is this a problem with the pom packaging maybe? Derek On Mon, Aug 24, 2009 at 3:14 PM, Derek Chen-Becker dchenbec...@gmail.com http://dchenbec...@gmail.com wrote: Well. Bad news. I fixed the checksums only to find that somehow hudson is still generating archetypes with old sources. I'm at a loss as to how this is happening at this point... Derek On Mon, Aug 24, 2009 at 2:47 PM, Charles F. Munat c...@munat.com http://c...@munat.com wrote: Ah, so the errors were connected after all. I was curious about the checksum, but I didn't realize that would make it grab an earlier version. Derek Chen-Becker wrote: OK, I think I've found an issue here. The sha1 checksum file for the archetype was last updated on August 1st, and haven't been updated since then. That's what your original error was, and it's why it's grabbing an older version of the jar :(. Let me see if I can figure out why hudson won't recalculate the checksums. Derek On Mon, Aug 24, 2009 at 2:13 PM, Charles F. Munat c...@munat.com http://c...@munat.com mailto:c...@munat.com c...@munat.com mailto:c...@munat.com%3e c...@munat.com%3e wrote: ? ? Thanks for all your help, Indrajit. I'm using the blank JPA app anyway, ? ? so it didn't affect me, but I thought Derek, et al should know. ? ? Especially since I was using the Maven command from his book... ? ? Chas. ? ? Indrajit Raychaudhuri wrote: ? ? ? Chas, ? ? ? ? ? ? The problem is quite likely with the archetype jar in the scala-tools ? ? ? repo. Derek is probably looking into it. ? ? ? Yes, your being confused about the master reference is ? ? ? understandable :) ? ? ? ? ? ? Good that it compiles through. For now, you can set the dependencies ? ? ? to lift-core and lift-jpa to 1.1-M4 and proceed merrily. ? ? ? ? ? ? Cheers, Indrajit ? ? ? ? ? ? On Aug 24, 11:09 pm, Charles F. Munat c...@munat.com http://c...@munat.com ? ? mailto:c...@munat.com c...@munat.com mailto:c...@munat.com %3Ec...@munat.com%3e wrote: ? ? ? I'm on a new laptop. I didn't do any git pulls of Lift stuff. I just ? ? ? installed Scala with the IZ installer and then Maven, then I ran the ? ? ? archetype command to create a basic JPA app and let it build the m2 ? ? ? repository on my machine. When that didn't work, I blew away m2 and ? ? ? tried it again. ? ? ? ? ? ? Changing the lift-core dependency worked. So the problem is ? ? definitely ? ? ? with 1.1-SNAPSHOT -- at least the one I
[Lift] Submit to different page
Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
Well you can put a regular lift form that submits to itself in terms or URI, do the computation in your processing function and redirect- with-state to your new page. So this would imply a redirect which one can say that it is suboptimal as it implies one additional request. Personally I see no reason why not allowing for non-ajax form to have a different user-specified action attribute. So IMO we could add this support quite easily. If someone thinks that we shouldn't do this, I'd love to see the arguments. Br's, Marius On Aug 25, 10:38 am, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
Marius, So to clarify, your proposing: lift:MySnippet form=post action=??? Cheers, Tim On 25/08/2009 10:24, marius d. marius.dan...@gmail.com wrote: Well you can put a regular lift form that submits to itself in terms or URI, do the computation in your processing function and redirect- with-state to your new page. So this would imply a redirect which one can say that it is suboptimal as it implies one additional request. Personally I see no reason why not allowing for non-ajax form to have a different user-specified action attribute. So IMO we could add this support quite easily. If someone thinks that we shouldn't do this, I'd love to see the arguments. Br's, Marius On Aug 25, 10:38 am, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises --~--~-~--~~~---~--~~ 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: Comet Chat
Thanks for your answers David and Wilson. mvh Bjarte On Mon, Aug 24, 2009 at 9:39 PM, David Pollakfeeder.of.the.be...@gmail.com wrote: On Mon, Aug 24, 2009 at 12:20 PM, Wilson MacGyver wmacgy...@gmail.com wrote: Hi Bjarte, I am the one who wrote that post. It came out of a 1 hour presentation that I did for my local java user group to show what lift can do. So it was very minimal. Since most people attending are new to both Scala and Lift. I second David's suggestion. For a more full featured version check out http://demo.liftweb.net/chat In fact http://demo.liftweb.net/ has quite a bit of example. And I believe all the code are also available from David Pollak's github repo. All the demo.liftweb.net code is part of the Lift source distribution found at http://github.com/dpp/liftweb/tree/master Thanks, Mac On Mon, Aug 24, 2009 at 12:05 PM, Bjarte Stien Karlsenbjarte.stien.karl...@gmail.com wrote: Hello lifted, I am playing around with the 50ish line based comet example that dpp has talked about in several talks and that is written more about here: http://m.3wa.com/?p=304 Today I showed this to a friend and it looks like the focus of the input box is lost when an update is received. Does anybody have a clue on how this can be fixed? Is it not possible to just update part of the DOM without having to steal the focus from the input field? -- Bjarte Stien Karlsen Ronatoppen 6a, 4638 Kristiansand 95219547 MSN: m...@ibjarte.com -- Omnem crede diem tibi diluxisse supremum. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Bjarte Stien Karlsen Ronatoppen 6a, 4638 Kristiansand 95219547 MSN: m...@ibjarte.com --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Linking URLs in Lift
I really love the Lift framework. It handles a lot of things for you and it makes web programming really easy! I was reading The Definitive guide to Lift though I just finished the SiteMap chapter (ie chapter 5), I tried to link to another URL, a html document I created in the same directory but I kept getting the following error: Exception occured while processing /next Message: java.lang.IllegalArgumentException: line 5 does not exist scala.io.Source.getLine(Source.scala:280) scala.io.Source.report(Source.scala:368) scala.io.Source.reportError(Source.scala:355) scala.io.Source.reportError(Source.scala:344) scala.xml.parsing.MarkupParser$class.reportSyntaxError (MarkupParser.scala:1113) ... Where next.html is the name of the html document. The Html tag that links is: ... Link f:link/ ... The code that controls the snippet is: ... bind(f, tag,link - SHtml.link(/next, () = println (Linked...), Text(lint to next)),) ... Can anyone help me with this please? I'll also appreciate it with lots of explanations and/or better ways of linking URLs with and without maintaining state. Thanks in advance. --~--~-~--~~~---~--~~ 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: Submit to different page
Something like that yes. Of course if action is missing current behavior will apply. Br's, Marius On Aug 25, 12:34 pm, Timothy Perrett timo...@getintheloop.eu wrote: Marius, So to clarify, your proposing: lift:MySnippet form=post action=??? Cheers, Tim On 25/08/2009 10:24, marius d. marius.dan...@gmail.com wrote: Well you can put a regular lift form that submits to itself in terms or URI, do the computation in your processing function and redirect- with-state to your new page. So this would imply a redirect which one can say that it is suboptimal as it implies one additional request. Personally I see no reason why not allowing for non-ajax form to have a different user-specified action attribute. So IMO we could add this support quite easily. If someone thinks that we shouldn't do this, I'd love to see the arguments. Br's, Marius On Aug 25, 10:38 am, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
Sounds good to me :-) On Aug 25, 11:06 am, marius d. marius.dan...@gmail.com wrote: Something like that yes. Of course if action is missing current behavior will apply. Br's, Marius On Aug 25, 12:34 pm, Timothy Perrett timo...@getintheloop.eu wrote: Marius, So to clarify, your proposing: lift:MySnippet form=post action=??? Cheers, Tim On 25/08/2009 10:24, marius d. marius.dan...@gmail.com wrote: Well you can put a regular lift form that submits to itself in terms or URI, do the computation in your processing function and redirect- with-state to your new page. So this would imply a redirect which one can say that it is suboptimal as it implies one additional request. Personally I see no reason why not allowing for non-ajax form to have a different user-specified action attribute. So IMO we could add this support quite easily. If someone thinks that we shouldn't do this, I'd love to see the arguments. Br's, Marius On Aug 25, 10:38 am, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
lift:MySnippet form=post action=??? Interestingly enough that's the first thing I tried. I'm sure that there are good reasons for the restriction that I'm overlooking. As for the redirection solution, I did think about that and that would equate (someone please correct me) to a GET with parameters which (apparently) is the way to deal with search form submissions (because of reloads, blah blah). If my vote counts for anything lift:MyClass form=post|get action=other_url would get my +1 Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
Ulises, Am I missing something? There is nothing stopping you making a URL like: /search?for=Some+Term You can do that as it stands today... Just read in the parameter using S.param(for) //= Box[String] Seems like this would be the easiest route, no? Cheers, Tim On 25/08/2009 11:15, Ulises ulises.cerv...@gmail.com wrote: lift:MySnippet form=post action=??? Interestingly enough that's the first thing I tried. I'm sure that there are good reasons for the restriction that I'm overlooking. As for the redirection solution, I did think about that and that would equate (someone please correct me) to a GET with parameters which (apparently) is the way to deal with search form submissions (because of reloads, blah blah). If my vote counts for anything lift:MyClass form=post|get action=other_url would get my +1 Cheers, Ulises --~--~-~--~~~---~--~~ 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: MappedDateTime losing time?
Derek Chen-Becker dchenbec...@gmail.com writes: OK, the fix has been pushed to 1.0.1-SNAPSHOT and it's in master (1.1-SNAPSHOT). Derek Excellent! Thanks /Jeppe --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: New features
Anyone have code showing this in action as it were? On Aug 6, 8:39 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Oh, I think I know what the problem is. I think I should classify it as a bug. Since you're adding a Role that isn't saved yet, and ManyToMany tracks the children via the join table, it can't access the child. As a workaround save the Role before adding it, although the need to do so is against the idea of ManyToMany and OneToMany. I will see what I can do, G-d willing. - glenngl...@exmbly.com wrote: Naftoli, Hate to do this to you, but I'm getting the following error using ManyToMany for Users to Roles: Message: java.lang.RuntimeException: Broken join scala.Predef$.error(Predef.scala:76) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.util.EmptyBox.openOr(Box.scala:372) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) scala.List.map(List.scala:812) net.liftweb.mapper.ManyToMany$MappedManyToMany.children (ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany.elements (ManyToMany.scala:96) scala.Seq$class.flatMap(Seq.scala:293) net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap (ManyToMany.scala:44) def edit(ns: NodeSeq): NodeSeq = { val theUser = view.entity val addRole = TheBindParam(insert, view.snippet.link(edit, () = theUser.roles += new Role, Text(S?(Add Role bind(user, ns, firstname - text(theUser.firstName.is, theUser.firstName (_), (size,20)), lastname - text(theUser.lastName.is,theUser.lastName(_), (size, 30)), roles - theUser.roles.flatMap{role = bind(role, ns, name - role.name.toForm, remove - SHtml.submit(S?(Remove), ()= theUser.roles -= role) ) }, addRole, submit - SHtml.submit(S?(Save), ()=view.save) ) } The offending code seems to be the line: roles - theUser.roles.flatMap{ in the above bind method when I click on the addRole link. Here's my User class: class User extends MegaProtoUser[User] with ManyToMany[Long,User]{ def getSingleton = User // what's the meta server object roles extends MappedManyToMany(UserRole, UserRole.user, UserRole.role, Role) } What am I doing wrong? You can see how difficult it is to slog through this code, let alone just trying to explain the problem so I can get help. On Aug 5, 9:57 am, Naftoli Gugenheim naftoli...@gmail.com wrote: I'll try. By the way, as per my correction, you can implement list the regular way without ModelView, and just use ModelSnippet's load function in your edit link or button, passing it the User instance. - glenngl...@exmbly.com wrote: Naftoli, I fixed my code per your comments and now I can edit and remove users from a list, as long as I populate the list with ModelView instances, as you said. As for the docs, this step was not clear to me at all. I just assumed that the list was just populated with User entities and the view in the ModelSnippet was instantiated with the selected User on each request. It sounds like your plate is pretty full, so I won't expect much, but sometime soon, could you provide an example, or improved docs, for using TableEditor and its related ItemsList trait. Thanks for all. Glenn... On Aug 5, 9:18 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Correction: ModelSnippet.load takes the actual Mapper instance, not the ModelView wrapper. - Naftoli Gugenheimnaftoli...@gmail.com wrote: To answer your immediate question, the listing should not refer to the snippet's view but new ModelView instances for each entity. Then editAction is shorthand for the snippet's link method with a callback to call load on the ModelView. To set the snippet's view's entity, either call load on the snippet with the other ModelView, or call load on the other ModelView (or just set its entity directly). As far as documentation, please tell me what scaladocs need what clarification. Thanks. - glenngl...@exmbly.com wrote: Naftoli, Functional programming systems are notoriously difficult to document. The only way to really know what's going on is to meticulously trace through the source. But that requires time-consuming trial and error coding. So, without clear examples demonstrating exactly what
[Lift] Archetype Catalog on scala-tools.org
Guys, Can we please add this plugin to the Nexus deployment on scala-tools? https://docs.sonatype.org/display/Nexus/Nexus+Archetype+Plugin Seems that if we use this, we could simply get rid of the the need to manually update the archetype-catalog.xml file - which is frankly out of date. DavidB what do you think? Thoughts all? Cheers, Tim --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Submit to different page
Sure this is totally doable but I think we should be able to support the case above where a form can submit to a different page. Br's, Marius On Aug 25, 2:05 pm, Timothy Perrett timo...@getintheloop.eu wrote: Ulises, Am I missing something? There is nothing stopping you making a URL like: /search?for=Some+Term You can do that as it stands today... Just read in the parameter using S.param(for) //= Box[String] Seems like this would be the easiest route, no? Cheers, Tim On 25/08/2009 11:15, Ulises ulises.cerv...@gmail.com wrote: lift:MySnippet form=post action=??? Interestingly enough that's the first thing I tried. I'm sure that there are good reasons for the restriction that I'm overlooking. As for the redirection solution, I did think about that and that would equate (someone please correct me) to a GET with parameters which (apparently) is the way to deal with search form submissions (because of reloads, blah blah). If my vote counts for anything lift:MyClass form=post|get action=other_url would get my +1 Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
Am I missing something? There is nothing stopping you making a URL like: /search?for=Some+Term Seems like this would be the easiest route, no? Indeed! I posted to the list because I wasn't sure whether what I wanted to do was doable or not ... Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
Right, I agree we should do it - but I don't think its what he needs for this problem (it seems overkill) Cheers, Tim On 25/08/2009 12:33, marius d. marius.dan...@gmail.com wrote: Sure this is totally doable but I think we should be able to support the case above where a form can submit to a different page. Br's, Marius --~--~-~--~~~---~--~~ 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: Submit to different page
So you have everything you need now? Cheers, Tim On 25/08/2009 12:39, Ulises ulises.cerv...@gmail.com wrote: Indeed! I posted to the list because I wasn't sure whether what I wanted to do was doable or not ... Cheers, Ulises --~--~-~--~~~---~--~~ 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: Submit to different page
So you have everything you need now? Yes, thanks very much for your help :) U --~--~-~--~~~---~--~~ 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] Menu.builder li_item being applied to all?
I've been running mvn -o for a while, but didn't today and noticed a change in behaviour for the menu builder (1.1 SNAPSHOT). I'm seeing all my menus being given the selected item class, not just the one that's selected for the page you're on. I'm using... lift:Menu.builder li_item:class=current_tab / I've cut my site map down to this... val menus = Menu(Loc(one, new Link(index :: Nil, false), Page 1)) :: Menu(Loc(two, new Link(index2 :: Nil, false), Page 2)) :: Nil LiftRules.setSiteMap(SiteMap(menus:_*)) ...and I see the following output: ulli class=current_taba href=/indexPage 1/a/lili class=current_tabspanPage 2/span/li/ul I'd expect only one of the li elements to have the class attribute. Am I doing something wrong here? Thank you Richard --~--~-~--~~~---~--~~ 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 features
This meaning the problem, or meaning ManyToMany? It's pretty simple to use. You're mapper should extend ManyToMany, and you should have a field: object m2m extends MappedManyToMany(.../*the two MetaMappers and foreign keys, see the docs/source*/) Then you can treat m2m as a Buffer, adding and deleting children. Call save on the mapper or m2m to propogate the adding/deleting to the database, and refresh to reset its contents to reflect the database. However, as noted currently the children must be saved before they are added. This is not the case for OneToMany, and for ManyToMany it should not be a problem because usually the children exist independently of the parent--that's why they can have 0 or 1 or more parents. - Randinnrand...@gmail.com wrote: Anyone have code showing this in action as it were? On Aug 6, 8:39 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Oh, I think I know what the problem is. I think I should classify it as a bug. Since you're adding a Role that isn't saved yet, and ManyToMany tracks the children via the join table, it can't access the child. As a workaround save the Role before adding it, although the need to do so is against the idea of ManyToMany and OneToMany. I will see what I can do, G-d willing. - glenngl...@exmbly.com wrote: Naftoli, Hate to do this to you, but I'm getting the following error using ManyToMany for Users to Roles: Message: java.lang.RuntimeException: Broken join scala.Predef$.error(Predef.scala:76) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.util.EmptyBox.openOr(Box.scala:372) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) scala.List.map(List.scala:812) net.liftweb.mapper.ManyToMany$MappedManyToMany.children (ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany.elements (ManyToMany.scala:96) scala.Seq$class.flatMap(Seq.scala:293) net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap (ManyToMany.scala:44) def edit(ns: NodeSeq): NodeSeq = { val theUser = view.entity val addRole = TheBindParam(insert, view.snippet.link(edit, () = theUser.roles += new Role, Text(S?(Add Role bind(user, ns, firstname - text(theUser.firstName.is, theUser.firstName (_), (size,20)), lastname - text(theUser.lastName.is,theUser.lastName(_), (size, 30)), roles - theUser.roles.flatMap{role = bind(role, ns, name - role.name.toForm, remove - SHtml.submit(S?(Remove), ()= theUser.roles -= role) ) }, addRole, submit - SHtml.submit(S?(Save), ()=view.save) ) } The offending code seems to be the line: roles - theUser.roles.flatMap{ in the above bind method when I click on the addRole link. Here's my User class: class User extends MegaProtoUser[User] with ManyToMany[Long,User]{ def getSingleton = User // what's the meta server object roles extends MappedManyToMany(UserRole, UserRole.user, UserRole.role, Role) } What am I doing wrong? You can see how difficult it is to slog through this code, let alone just trying to explain the problem so I can get help. On Aug 5, 9:57 am, Naftoli Gugenheim naftoli...@gmail.com wrote: I'll try. By the way, as per my correction, you can implement list the regular way without ModelView, and just use ModelSnippet's load function in your edit link or button, passing it the User instance. - glenngl...@exmbly.com wrote: Naftoli, I fixed my code per your comments and now I can edit and remove users from a list, as long as I populate the list with ModelView instances, as you said. As for the docs, this step was not clear to me at all. I just assumed that the list was just populated with User entities and the view in the ModelSnippet was instantiated with the selected User on each request. It sounds like your plate is pretty full, so I won't expect much, but sometime soon, could you provide an example, or improved docs, for using TableEditor and its related ItemsList trait. Thanks for all. Glenn... On Aug 5, 9:18 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Correction: ModelSnippet.load takes the actual Mapper instance, not the ModelView wrapper. - Naftoli Gugenheimnaftoli...@gmail.com wrote: To answer your immediate question, the listing should not refer to the
[Lift] Re: Structuring Web Application
There are lift examples on GitHub under sites. It sounds like you have two questions, one about Scala, one about Lift. Both are very flexible--there isn't necessarily only one way. If you understand how snippets get invoked from html, the rest is up to you. - Georgios Z.hellectro...@gmail.com wrote: Hello Naftoli, thank you for taking the time. I am asking for understanding better how I can stucture my code, because I dont get the paradigm shift how to organize my code in modules with scala. I know I can build modules in scala with object. Another part is how to configure the glueing between a Lift component to my business logic. I Think I will have a module of a part of my business logic. As I wrote, my background is java with spring. Think I need a small example to get my paradigm shift :D But I do not find any examples. Thanks kind regards 2009/8/23 Naftoli Gugenheim naftoli...@gmail.com: Are you just asking for a basic overview of how all the pieces fit together in Lift? - greekscalahellectro...@gmail.com wrote: Hello Timothy, thank you. I know that I do not need Spring for Scala. I dont expressed it well. How do I glue my app parts together. And how do I glue the lift part with a facade or application service of my domain layer. Thanks for your help On 23 Aug., 13:12, Timothy Perrett timo...@getintheloop.eu wrote: Can you please be more specific about your app tier that you wish to access - im unfortunately not seeing what hurdle stops you from accessing it just as you would from Java? Cheers, Tim On Aug 22, 9:45 pm, greekscala hellectro...@gmail.com wrote: Hello Lift Community, I want to implement a new Project in Scala with Lift. I am new to Scala/Lift. Scala looks great and it expanded my horizon. FP is a new concept to me. My background is Java and a little bit of Spring. I read three Scala books and a lot on blogs. But there is a missing part for me on how to combine my classes. I read the Scalable Components Paper and I dont get it 100%. I need a little bit more input on structuring a web app and I hope to get the 100% with you guys. With Spring you let the container manage the classes. ok. I think my problem is, I dont know how you structured a web app in days without Spring. I would like to have Lift access my domain logic over an application layer (Domain Driven Design). In Wicket I would have my SpringBean annotation. So I hope to understand, how - can I access my app layer? - how could I organize my domain logic. I want to use DDD. I know I have to use object and class in a bigger sense...? I hope you guys can give me some hints. Thanks a lot -- Stay Tuned! --~--~-~--~~~---~--~~ 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 with custom id
I had seen that thread, but it doesn't make sense to add all that code to all of my mapper models when they're ordinary mappers with ordinary auto-increment primary keys, which I happen to be importing from the database used by the previous, PHP version of this app. The foreign keys have to match up properly. Meanwhile I changed it so that it keeps a Map in memory from old ids to mapper instances, and linked children to the mapper with the new id. But wouldn't the logic of saved_? make more sense the way I proposed? - Peter Robinettpe...@bubblefoundry.com wrote: You need to set the mapper id field as editable. Here is what I had to do to use a MappedStringIndex as a primary key that I can set manually: /* MAC address as primary key */ def primaryKeyField = mac object mac extends MappedStringIndex(this, 17) with IndexedField [String] { override def dbDisplay_? = true override lazy val defaultValue = randomString(maxLen) /* allow user-defined primary key */ override def writePermission_? = true override def dbAutogenerated_? = false private var myDirty = false override def dirty_? = myDirty override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?(b) } override def fieldCreatorString(dbType: DriverType, colName: String): String = colName+ CHAR(+maxLen+) NOT NULL } Peter On Aug 24, 5:30 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: I'm trying to import data from a non-mapper-based database to one that is. I'm reading data with DB.exec and trying to save it using Mapper, but it's not getting saved. I'm guessing that since I'm setting the id (in runSafe) it thinks it needs to do an update, not an insert. Is there a workaround? Also, doesn't this scenario break the logic of MetaMapper.saved_?() ? Wouldn't it make more sense to have a saved flag that is cleared by default and set when it's created as a result of a find, and after it's saved? --~--~-~--~~~---~--~~ 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: Notes from 8/19/09 Lift Committers Call - LIFT SESSION REPLICATION DISCUSSION
I understand your thoughts David ... but I'm not convinced that Java serialization is the way to go. A more efficient serialization of the dependency graph sounds more appropriate but also quite complex. Br's, Marius On Aug 25, 12:42 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Aug 24, 2009 at 12:58 PM, Meredith Gregory lgreg.mered...@gmail.com wrote: David, Can one leave proxies in place for things that are not actually serializable? Anything that's marked serializable should be... and it's up to the thing that marks itself as serialiable to create a proxy. Things that are not marked as serializable may or may not be... the issue is what kind of instance variables they have to determine if they could be serialized. Best wishes, --greg On Mon, Aug 24, 2009 at 12:55 PM, David Pollak feeder.of.the.be...@gmail.com wrote: On Mon, Aug 24, 2009 at 12:36 PM, marius d. marius.dan...@gmail.comwrote: Just a FYI. I briefly talked with Martin and he said this idea is possible but quite tricky. Stephane Micheloud did something similar and he may share some of his work. I'm waiting some feedback from him. I think we can do it at runtime in development mode. This is just for data gathering, not for actual implementation. We just need to calculate whether a given class is serializable once... so we don't have to worry about cyclic graphs or anything else... just... are the slots (instance variables) for each class serializable. Br's, Marius On Aug 24, 10:46 am, marius d. marius.dan...@gmail.com wrote: On Aug 24, 10:39 am, Viktor Klang viktor.kl...@gmail.com wrote: On Mon, Aug 24, 2009 at 8:13 AM, marius d. marius.dan...@gmail.com wrote: On Aug 24, 12:06 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Sun, Aug 23, 2009 at 10:45 AM, marius d. marius.dan...@gmail.com wrote: Hmmm .. I'm wondering if we can write aScalacompilerpluginthat transform functions provided to Lift's S/SHtml function etc. into a richer FunctionX implementation that knows how to serialize it's members. We could restrict the types that as LiftSerializable on top of primitives, Calenars, SessionVar/RequestVar etc. If users need their own classes to be LiftSerilizable they would have to implement LiftSerializable trait. I think we can do it without explicit traits. I think we just need to walk the graph for everything that's added to the LiftSession and see where it leads. Any graph we can walk is something that we can serialize... even without Java serialization. Any graph that ends in globals or some class that refers to native stuff (e.g., IO), then we're toast. Totally agree. The rationale for explicit LiftSerializable would be just for user defined types. Otherwise user's won't have to use it. Graphs may also have be cyclic paths ... it shouldn't be too big of a pain though. Furthermore if a dependency graph path leads say to an IO reference maybe that's unintentional user code doesn't really use that but compiler put it for whatever reason. If such cases are possible and could be determined maybe we could exclude that silently from the serialization operation and add a compile time warning. I guess we need to dig more intoscalacompilerpluginsystem. 1. Isn't there a problem with references _inside_ methods that are impure/sideeffecting? s = { Db.myCachedInfoNotInSession foo s } Regarding member references, a simple check for transient (sca...@transient == java *transient*) to forcve people to use transient members for non-serializable state. But IMHO the serialization problem is a (negative?) sideeffect of Lifts rich model GUID=Func approach. Perhpas there is a middle way, a way where we can replicate just enough to survive a node crash? That's exactly it. We probably don't need everything that Java Serialization does. Just enough to make it consistent ... the dependency graphs that is actually used by the user's function. Thoughts? Br's, Marius On Aug 23, 8:30 pm, marius d. marius.dan...@gmail.com wrote: At a first glace Java serialization is needed because of its awareness of the reference graph. But in the same time it does not perform well. One way might be the byte level instrumentation that would induce code to figure out the reference graph and know how to stream-ify it using a given efficient protocol. But that induces risks and it involves tons of work. I think would be doable though. The problem is not really the technology of propagating session information to other nodes. That's the easiest part, but tough one is figuring out the low level reference graph and
[Lift] Lift on Tomcat
I want to set up Lift with Tomcat. I set up lift on my local machine using Maven. Where are the Lift jars located? Are there any non- standard steps for setting up Lift on Tomcat? I am familiar with Tomcat. 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: Mapper with custom id
On Tue, Aug 25, 2009 at 7:08 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: I had seen that thread, but it doesn't make sense to add all that code to all of my mapper models when they're ordinary mappers with ordinary auto-increment primary keys, which I happen to be importing from the database used by the previous, PHP version of this app. The foreign keys have to match up properly. Meanwhile I changed it so that it keeps a Map in memory from old ids to mapper instances, and linked children to the mapper with the new id. But wouldn't the logic of saved_? make more sense the way I proposed? For the load operation where you're moving databases, why not just write some custom code to dump the data? - Peter Robinettpe...@bubblefoundry.com wrote: You need to set the mapper id field as editable. Here is what I had to do to use a MappedStringIndex as a primary key that I can set manually: /* MAC address as primary key */ def primaryKeyField = mac object mac extends MappedStringIndex(this, 17) with IndexedField [String] { override def dbDisplay_? = true override lazy val defaultValue = randomString(maxLen) /* allow user-defined primary key */ override def writePermission_? = true override def dbAutogenerated_? = false private var myDirty = false override def dirty_? = myDirty override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?(b) } override def fieldCreatorString(dbType: DriverType, colName: String): String = colName+ CHAR(+maxLen+) NOT NULL } Peter On Aug 24, 5:30 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: I'm trying to import data from a non-mapper-based database to one that is. I'm reading data with DB.exec and trying to save it using Mapper, but it's not getting saved. I'm guessing that since I'm setting the id (in runSafe) it thinks it needs to do an update, not an insert. Is there a workaround? Also, doesn't this scenario break the logic of MetaMapper.saved_?() ? Wouldn't it make more sense to have a saved flag that is cleared by default and set when it's created as a result of a find, and after it's saved? -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Linking URLs in Lift
You are right. I installed Scala version 2.7.5 and Lift builds with version 2.7.3. I use Netbeans IDE. I changed the POM.xml to reflect the version (ie from 2.7.3 to 2.7.5) and it kept downloading dependency each time I try to build. Do I need to download the scala 2.7.5 library again after I have set the dependency to the version that's local on my system? On Aug 25, 11:10 am, marius d. marius.dan...@gmail.com wrote: What Scala lift version are you using ? Are you compiling with one scala version and use a different one at runtime? The error also looks like an invalid xml provided. Can you paste you xml template where you have the snippet ? Br's, Marius On Aug 25, 12:45 pm, celestocalculus celestocalcu...@yahoo.co.uk wrote: I really love the Lift framework. It handles a lot of things for you and it makes web programming really easy! I was reading The Definitive guide to Lift though I just finished the SiteMap chapter (ie chapter 5), I tried to link to another URL, a html document I created in the same directory but I kept getting the following error: Exception occured while processing /next Message: java.lang.IllegalArgumentException: line 5 does not exist scala.io.Source.getLine(Source.scala:280) scala.io.Source.report(Source.scala:368) scala.io.Source.reportError(Source.scala:355) scala.io.Source.reportError(Source.scala:344) scala.xml.parsing.MarkupParser$class.reportSyntaxError (MarkupParser.scala:1113) ... Where next.html is the name of the html document. The Html tag that links is: ... Link f:link/ ... The code that controls the snippet is: ... bind(f, tag,link - SHtml.link(/next, () = println (Linked...), Text(lint to next)),) ... Can anyone help me with this please? I'll also appreciate it with lots of explanations and/or better ways of linking URLs with and without maintaining state. Thanks in advance. --~--~-~--~~~---~--~~ 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: Linking URLs in Lift
Still got the same error. The source files are: Form.scala: package com.celestine.learninglift.snippet import net.liftweb.http._ import S._ import net.liftweb.util._ import Helpers._ import scala.xml._ class Form { def show(tag: NodeSeq): NodeSeq = { var txtVal: String = var radval: String = var fileHolder: Box[FileParamHolder] = Empty import java.awt.Color val data = List(Color.RED, Color.BLACK, Color.GREEN) val all = data.map(e = (e, e.toString)).toSeq //val sel = data.keys.toList.toSeq val radio = SHtml.selectObj(all, Empty, (v:Color) = {println (Selected: Radio- + v); v}) def process() = { val okFile = fileHolder match { case Full(FileParamHolder(_,mime,_,data)) = { if(mime.startsWith(image/)) println(Image type.\nMime: +mime+\nData: +data.deepToString) else if(mime.startsWith(application/)) println(Application Type.\nMime: +mime+\nData: +data.deepToString) else println(Other type.\nMime: +mime +\nData: +data.deepToString) true } case _ = false } true } bind(f, tag, txt - SHtml.text(txtVal, txtVal = _), lnk - SHtml.link(/next, () = println(Linked...), Text(lint to next)), chk - SHtml.checkbox(false, println(_)), pass - SHtml.password(, println(_)), ta - SHtml.textarea(Enter Text, println(_), cols - 80, rows - 8), rb - radio, up - SHtml.fileUpload(p = {fileHolder = Full(p)}), submit - SHtml.submit(submit, process) ) } } pom.xml: project xmlns=http://maven.apache.org/POM/4.0.0; xmlns:xsi=http:// www.w3.org/2001/XMLSchema-instance xsi:schemaLocation=http:// maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd; modelVersion4.0.0/modelVersion groupIdcom.celestine/groupId artifactIdLearningLift/artifactId version1.0-SNAPSHOT/version packagingwar/packaging nameLearningLift/name inceptionYear2007/inceptionYear properties scala.version2.7.5/scala.version netbeans.hint.deploy.serverJ2EE/netbeans.hint.deploy.server /properties repositories repository idscala-tools.org/id nameScala-Tools Maven2 Repository/name urlhttp://scala-tools.org/repo-releases/url /repository /repositories pluginRepositories pluginRepository idscala-tools.org/id nameScala-Tools Maven2 Repository/name urlhttp://scala-tools.org/repo-releases/url /pluginRepository /pluginRepositories dependencies dependency groupIdorg.scala-lang/groupId artifactIdscala-library/artifactId version${scala.version}/version /dependency dependency groupIdnet.liftweb/groupId artifactIdlift-util/artifactId version1.0/version /dependency dependency groupIdnet.liftweb/groupId artifactIdlift-webkit/artifactId version1.0/version /dependency dependency groupIdnet.liftweb/groupId artifactIdlift-mapper/artifactId version1.0/version /dependency dependency groupIdjavax.servlet/groupId artifactIdservlet-api/artifactId version2.5/version scopeprovided/scope /dependency dependency groupIdjunit/groupId artifactIdjunit/artifactId version4.5/version scopetest/scope /dependency dependency groupIdorg.mortbay.jetty/groupId artifactIdjetty/artifactId version[6.1.6,)/version scopetest/scope /dependency !-- for LiftConsole -- dependency groupIdorg.scala-lang/groupId artifactIdscala-compiler/artifactId version${scala.version}/version scopetest/scope /dependency /dependencies build sourceDirectorysrc/main/scala/sourceDirectory testSourceDirectorysrc/test/scala/testSourceDirectory plugins plugin groupIdorg.scala-tools/groupId artifactIdmaven-scala-plugin/artifactId executions execution goals goalcompile/goal goaltestCompile/goal /goals /execution /executions configuration scalaVersion${scala.version}/scalaVersion /configuration /plugin plugin groupIdorg.mortbay.jetty/groupId artifactIdmaven-jetty-plugin/artifactId configuration contextPath//contextPath scanIntervalSeconds5/scanIntervalSeconds /configuration /plugin plugin groupIdnet.sf.alchim/groupId artifactIdyuicompressor-maven-plugin/artifactId executions execution goals goalcompress/goal /goals /execution /executions configuration nosuffixtrue/nosuffix
[Lift] Re: Linking URLs in Lift
On Tue, Aug 25, 2009 at 2:45 AM, celestocalculus celestocalcu...@yahoo.co.uk wrote: I really love the Lift framework. It handles a lot of things for you and it makes web programming really easy! I was reading The Definitive guide to Lift though I just finished the SiteMap chapter (ie chapter 5), I tried to link to another URL, a html document I created in the same directory but I kept getting the following error: Exception occured while processing /next Message: java.lang.IllegalArgumentException: line 5 does not exist scala.io.Source.getLine(Source.scala:280) scala.io.Source.report(Source.scala:368) scala.io.Source.reportError(Source.scala:355) scala.io.Source.reportError(Source.scala:344) scala.xml.parsing.MarkupParser$class.reportSyntaxError (MarkupParser.scala:1113) ... This indicates that there's a problem parsing the XHTML document. The error is super-unfriendly, but has been made much more friendly in Lift 1.1-SNAPSHOT. Please look at the next.html document and run it through a tools to make sure it's valid XML. Where next.html is the name of the html document. The Html tag that links is: ... Link f:link/ ... The code that controls the snippet is: ... bind(f, tag,link - SHtml.link(/next, () = println (Linked...), Text(lint to next)),) ... Can anyone help me with this please? I'll also appreciate it with lots of explanations and/or better ways of linking URLs with and without maintaining state. Thanks in advance. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Submit to different page
1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form In both cases you can use Lift's html abstractions such as SHtml.text etc. and bind your function. In the second example we used a snippet that has no idea about form ... it is just wrapped by a form. So in both cases you don't really need to call S.attr to manually get parameters. Br's, Marius On Aug 25, 6:24 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 12:38 AM, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself form method=post action=/searchinput type=text name=search value=/input type=submit value=Search//form In the snippet that handles the search page: val searchTerm = S.param(search) openOr {S.error(no search term); S.redirectTo(S.referer openOr /)} Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises -- 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: Submit to different page
On Tue, Aug 25, 2009 at 9:23 AM, marius d. marius.dan...@gmail.com wrote: 1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form I'm not overly keen on the change (I'm not asking for it to be removed). The reason for the form attribute was that it's common to do postbacks and the generation of S.uri as part of the URL was a bunch of boilerplate. That's the reason I made the exception to the snippets result in whatever is returned from the snippet rather than having magic intervention rule. In the future, let's not mutate what the snippet returns without a discussion and a very strong justification. Thanks, David In both cases you can use Lift's html abstractions such as SHtml.text etc. and bind your function. In the second example we used a snippet that has no idea about form ... it is just wrapped by a form. So in both cases you don't really need to call S.attr to manually get parameters. Br's, Marius On Aug 25, 6:24 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 12:38 AM, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself form method=post action=/searchinput type=text name=search value=/input type=submit value=Search//form In the snippet that handles the search page: val searchTerm = S.param(search) openOr {S.error(no search term); S.redirectTo(S.referer openOr /)} Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises -- 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, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Menu.builder li_item being applied to all?
Maybe the fix for this issue has caused the problem..? http://groups.google.com/group/liftweb/browse_thread/thread/aca3b12c397e3b87 http://github.com/dpp/liftweb/issues/closed/#issue/53 --~--~-~--~~~---~--~~ 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: Menu builder group and li_item
Thanks for looking into this so quickly. I haven't had a chance to test it yet, but I notice another user is now having a slightly different problem. Not sure if it's related. http://groups.google.com/group/liftweb/browse_thread/thread/12415c178ee7b1ee/75d38df3617f77b6#75d38df3617f77b6 --~--~-~--~~~---~--~~ 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 features
I have a working example of ManyToMany that adds roles to users. I would be happy to share my work but I have an aversion to github. I don't like it, It's a slower-than- molasses interface. It's buggy and user-hostile in my opinion. I'm looking for an alternative to make it public. Any suggestions would be appreciated. Glenn... On Aug 25, 7:08 am, Naftoli Gugenheim naftoli...@gmail.com wrote: This meaning the problem, or meaning ManyToMany? It's pretty simple to use. You're mapper should extend ManyToMany, and you should have a field: object m2m extends MappedManyToMany(.../*the two MetaMappers and foreign keys, see the docs/source*/) Then you can treat m2m as a Buffer, adding and deleting children. Call save on the mapper or m2m to propogate the adding/deleting to the database, and refresh to reset its contents to reflect the database. However, as noted currently the children must be saved before they are added. This is not the case for OneToMany, and for ManyToMany it should not be a problem because usually the children exist independently of the parent--that's why they can have 0 or 1 or more parents. - Randinnrand...@gmail.com wrote: Anyone have code showing this in action as it were? On Aug 6, 8:39 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Oh, I think I know what the problem is. I think I should classify it as a bug. Since you're adding a Role that isn't saved yet, and ManyToMany tracks the children via the join table, it can't access the child. As a workaround save the Role before adding it, although the need to do so is against the idea of ManyToMany and OneToMany. I will see what I can do, G-d willing. - glenngl...@exmbly.com wrote: Naftoli, Hate to do this to you, but I'm getting the following error using ManyToMany for Users to Roles: Message: java.lang.RuntimeException: Broken join scala.Predef$.error(Predef.scala:76) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.util.EmptyBox.openOr(Box.scala:372) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) scala.List.map(List.scala:812) net.liftweb.mapper.ManyToMany$MappedManyToMany.children (ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany.elements (ManyToMany.scala:96) scala.Seq$class.flatMap(Seq.scala:293) net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap (ManyToMany.scala:44) def edit(ns: NodeSeq): NodeSeq = { val theUser = view.entity val addRole = TheBindParam(insert, view.snippet.link(edit, () = theUser.roles += new Role, Text(S?(Add Role bind(user, ns, firstname - text(theUser.firstName.is, theUser.firstName (_), (size,20)), lastname - text(theUser.lastName.is,theUser.lastName(_), (size, 30)), roles - theUser.roles.flatMap{role = bind(role, ns, name - role.name.toForm, remove - SHtml.submit(S?(Remove), ()= theUser.roles -= role) ) }, addRole, submit - SHtml.submit(S?(Save), ()=view.save) ) } The offending code seems to be the line: roles - theUser.roles.flatMap{ in the above bind method when I click on the addRole link. Here's my User class: class User extends MegaProtoUser[User] with ManyToMany[Long,User]{ def getSingleton = User // what's the meta server object roles extends MappedManyToMany(UserRole, UserRole.user, UserRole.role, Role) } What am I doing wrong? You can see how difficult it is to slog through this code, let alone just trying to explain the problem so I can get help. On Aug 5, 9:57 am, Naftoli Gugenheim naftoli...@gmail.com wrote: I'll try. By the way, as per my correction, you can implement list the regular way without ModelView, and just use ModelSnippet's load function in your edit link or button, passing it the User instance. - glenngl...@exmbly.com wrote: Naftoli, I fixed my code per your comments and now I can edit and remove users from a list, as long as I populate the list with ModelView instances, as you said. As for the docs, this step was not clear to me at all. I just assumed that the list was just populated with User entities and the view in the ModelSnippet was instantiated with the selected User on each request. It sounds like your plate is pretty full, so I won't expect much, but
[Lift] Re: Multiple sites, same login
On Mon, Aug 24, 2009 at 3:23 PM, Charles F. Munat c...@munat.com wrote: I'm building two Lift applications that access the same back end database -- one is for the public site, and the other, which will use a subdomain, is for administration of the public site. A third application will access a separate database, but will be related to the previous two sites. Any suggestions as to how I might have one login that keeps the user logged in across all these sites? Obviously, OpenID would work, and there's complex stuff involving LDAP servers, etc., but I'd like to keep it fairly simple. Ideas? You could put a cookie at the top level for the domain that's an encrypted mix of the user's primary key and the current time. If the user comes to another one of the sites, it could examine the cookie and see if it should create a session for the user. Thanks! Chas. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Linking URLs in Lift
Thanks David. The next.html was not a valid xhtml file. The xml namespace was missing in the html header. I just inserted it an it linked successfully. Thanks again. On Aug 25, 5:15 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 2:45 AM, celestocalculus celestocalcu...@yahoo.co.uk wrote: I really love the Lift framework. It handles a lot of things for you and it makes web programming really easy! I was reading The Definitive guide to Lift though I just finished the SiteMap chapter (ie chapter 5), I tried to link to another URL, a html document I created in the same directory but I kept getting the following error: Exception occured while processing /next Message: java.lang.IllegalArgumentException: line 5 does not exist scala.io.Source.getLine(Source.scala:280) scala.io.Source.report(Source.scala:368) scala.io.Source.reportError(Source.scala:355) scala.io.Source.reportError(Source.scala:344) scala.xml.parsing.MarkupParser$class.reportSyntaxError (MarkupParser.scala:1113) ... This indicates that there's a problem parsing the XHTML document. The error is super-unfriendly, but has been made much more friendly in Lift 1.1-SNAPSHOT. Please look at the next.html document and run it through a tools to make sure it's valid XML. Where next.html is the name of the html document. The Html tag that links is: ... Link f:link/ ... The code that controls the snippet is: ... bind(f, tag,link - SHtml.link(/next, () = println (Linked...), Text(lint to next)),) ... Can anyone help me with this please? I'll also appreciate it with lots of explanations and/or better ways of linking URLs with and without maintaining state. Thanks in advance. -- 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: Submit to different page
The topic was brought up in the discussion. Br's, Marius On Aug 25, 7:32 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:23 AM, marius d. marius.dan...@gmail.com wrote: 1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form I'm not overly keen on the change (I'm not asking for it to be removed). The reason for the form attribute was that it's common to do postbacks and the generation of S.uri as part of the URL was a bunch of boilerplate. This commit does not contradict this rule. People can use action only if they really need to without the boiler plate of typing the form tag. That's the reason I made the exception to the snippets result in whatever is returned from the snippet rather than having magic intervention rule. I really don't see how this implies a magic intervention since all this applies only if user explicitly adds action attribute. I mean if users explicitly points to a new page they expect that page to be rendered naturally which is what is happening. In the future, let's not mutate what the snippet returns without a discussion and a very strong justification. I really don't see the problem. The form attribute tells the user that a form will be rendered. Since a form will be rendered why can't the user change the action in exceptional cases since this doesn't induce side effects. If it does please let me know what are those side effects. If you want to I have no problem removing it but I really don't see what the issue is. Thanks, David In both cases you can use Lift's html abstractions such as SHtml.text etc. and bind your function. In the second example we used a snippet that has no idea about form ... it is just wrapped by a form. So in both cases you don't really need to call S.attr to manually get parameters. Br's, Marius On Aug 25, 6:24 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 12:38 AM, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself form method=post action=/searchinput type=text name=search value=/input type=submit value=Search//form In the snippet that handles the search page: val searchTerm = S.param(search) openOr {S.error(no search term); S.redirectTo(S.referer openOr /)} Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises -- 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, 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: Multiple sites, same login
Now this is an interesting idea. I'll think about it... Thanks! Chas. David Pollak wrote: On Mon, Aug 24, 2009 at 3:23 PM, Charles F. Munat c...@munat.com mailto:c...@munat.com wrote: I'm building two Lift applications that access the same back end database -- one is for the public site, and the other, which will use a subdomain, is for administration of the public site. A third application will access a separate database, but will be related to the previous two sites. Any suggestions as to how I might have one login that keeps the user logged in across all these sites? Obviously, OpenID would work, and there's complex stuff involving LDAP servers, etc., but I'd like to keep it fairly simple. Ideas? You could put a cookie at the top level for the domain that's an encrypted mix of the user's primary key and the current time. If the user comes to another one of the sites, it could examine the cookie and see if it should create a session for the user. Thanks! Chas. -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Submit to different page
On Tue, Aug 25, 2009 at 9:46 AM, marius d. marius.dan...@gmail.com wrote: The topic was brought up in the discussion. Br's, Marius On Aug 25, 7:32 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:23 AM, marius d. marius.dan...@gmail.com wrote: 1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form I'm not overly keen on the change (I'm not asking for it to be removed). The reason for the form attribute was that it's common to do postbacks and the generation of S.uri as part of the URL was a bunch of boilerplate. This commit does not contradict this rule. People can use action only if they really need to without the boiler plate of typing the form tag. Right, but it's a place where Lift is mutating the result of the snippet call. This should only be done if there is a compelling reason. I see no compelling reason here. This case is a fringe case and can easily be handled with a static form tag. The reason for the form attribute is that it's the common case for wrapping a snippet in a post-back form and the URL of the postback would require yet another snippet to calculate... and the feature made it into Lift before attribute snippets. So, the rules are: (1) Lift does not mutate what the snippet returns except under extremely compelling situations and (2) we don't add reserved word attributes except under compelling situations. That's the reason I made the exception to the snippets result in whatever is returned from the snippet rather than having magic intervention rule. I really don't see how this implies a magic intervention since all this applies only if user explicitly adds action attribute. I mean if users explicitly points to a new page they expect that page to be rendered naturally which is what is happening. Except for the form='xxx' attribute, I know of no other attribute that's baked into Lift's snippet handling mechanism. The use of this attribute is the only time that I know of that Lift's snippet handler mutates the result of the snippet by putting a form/ tag around it. In all other cases, it's up to the snippet itself to interpret the attributes. If we keep adding attributes that cause something to happen if the attribute appears, it will reduce the attributes available for use by snippets themselves. In the future, let's not mutate what the snippet returns without a discussion and a very strong justification. I really don't see the problem. The form attribute tells the user that a form will be rendered. Since a form will be rendered why can't the user change the action in exceptional cases since this doesn't induce side effects. If it does please let me know what are those side effects. It removes an attribute that's available for generic use by snippets. If there's code out there that uses the action attribute as part of the snippet, what are the impacts on that snippet? If you want to I have no problem removing it but I really don't see what the issue is. Thanks, David In both cases you can use Lift's html abstractions such as SHtml.text etc. and bind your function. In the second example we used a snippet that has no idea about form ... it is just wrapped by a form. So in both cases you don't really need to call S.attr to manually get parameters. Br's, Marius On Aug 25, 6:24 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 12:38 AM, Ulises ulises.cerv...@gmail.com wrote: Hey people, I'm trying to have a form be submitted to a different page (so, not a POST/GET back). The scenario is a search form which renders on a front page as well as on the search page. E.g.: /index should include a form that submits to /search /search form that submits to itself form method=post action=/searchinput type=text name=search value=/input type=submit value=Search//form In the snippet that handles the search page: val searchTerm = S.param(search) openOr {S.error(no search term); S.redirectTo(S.referer openOr /)} Any hints on how to do this/were to look to learn how to do this? I guess that the form on the front page could be just static HTML however I'm not entirely sure how /search would deal with the form submission from a static form ... Cheers, Ulises -- 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, the simply functional web frameworkhttp://liftweb.net Beginning Scalahttp://www.apress.com/book/view/1430219890 Follow
[Lift] EARN MONEY $1000-25000 PER MONTH
EARN MONEY $1000-25000 PER MONTH TAKE SIMPLE ONLINE SURVEYS CREATE FREE ACCOUNT OTHER DETAILS LOG ON TO * http://www.AWSurveys.com/HomeMain.cfm?RefID=sangeethap77 * --~--~-~--~~~---~--~~ 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 features
Google code? Sourceforge? ProjectLocker? There are a lot of choices... On Tue, Aug 25, 2009 at 12:37 PM, glenngl...@exmbly.com wrote: I have a working example of ManyToMany that adds roles to users. I would be happy to share my work but I have an aversion to github. I don't like it, It's a slower-than- molasses interface. It's buggy and user-hostile in my opinion. I'm looking for an alternative to make it public. Any suggestions would be appreciated. Glenn... On Aug 25, 7:08 am, Naftoli Gugenheim naftoli...@gmail.com wrote: This meaning the problem, or meaning ManyToMany? It's pretty simple to use. You're mapper should extend ManyToMany, and you should have a field: object m2m extends MappedManyToMany(.../*the two MetaMappers and foreign keys, see the docs/source*/) Then you can treat m2m as a Buffer, adding and deleting children. Call save on the mapper or m2m to propogate the adding/deleting to the database, and refresh to reset its contents to reflect the database. However, as noted currently the children must be saved before they are added. This is not the case for OneToMany, and for ManyToMany it should not be a problem because usually the children exist independently of the parent--that's why they can have 0 or 1 or more parents. - Randinnrand...@gmail.com wrote: Anyone have code showing this in action as it were? On Aug 6, 8:39 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Oh, I think I know what the problem is. I think I should classify it as a bug. Since you're adding a Role that isn't saved yet, and ManyToMany tracks the children via the join table, it can't access the child. As a workaround save the Role before adding it, although the need to do so is against the idea of ManyToMany and OneToMany. I will see what I can do, G-d willing. - glenngl...@exmbly.com wrote: Naftoli, Hate to do this to you, but I'm getting the following error using ManyToMany for Users to Roles: Message: java.lang.RuntimeException: Broken join scala.Predef$.error(Predef.scala:76) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.util.EmptyBox.openOr(Box.scala:372) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) scala.List.map(List.scala:812) net.liftweb.mapper.ManyToMany$MappedManyToMany.children (ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany.elements (ManyToMany.scala:96) scala.Seq$class.flatMap(Seq.scala:293) net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap (ManyToMany.scala:44) def edit(ns: NodeSeq): NodeSeq = { val theUser = view.entity val addRole = TheBindParam(insert, view.snippet.link(edit, () = theUser.roles += new Role, Text(S?(Add Role bind(user, ns, firstname - text(theUser.firstName.is, theUser.firstName (_), (size,20)), lastname - text(theUser.lastName.is,theUser.lastName(_), (size, 30)), roles - theUser.roles.flatMap{role = bind(role, ns, name - role.name.toForm, remove - SHtml.submit(S?(Remove), ()= theUser.roles -= role) ) }, addRole, submit - SHtml.submit(S?(Save), ()=view.save) ) } The offending code seems to be the line: roles - theUser.roles.flatMap{ in the above bind method when I click on the addRole link. Here's my User class: class User extends MegaProtoUser[User] with ManyToMany[Long,User]{ def getSingleton = User // what's the meta server object roles extends MappedManyToMany(UserRole, UserRole.user, UserRole.role, Role) } What am I doing wrong? You can see how difficult it is to slog through this code, let alone just trying to explain the problem so I can get help. On Aug 5, 9:57 am, Naftoli Gugenheim naftoli...@gmail.com wrote: I'll try. By the way, as per my correction, you can implement list the regular way without ModelView, and just use ModelSnippet's load function in your edit link or button, passing it the User instance. - glenngl...@exmbly.com wrote: Naftoli, I fixed my code per your comments and now I can edit and remove users from a list, as long as I populate the list with ModelView instances, as you said. As for the docs, this step was not clear to me at all. I just assumed that the list was just populated with User entities and the view in the
[Lift] Re: Mapper with custom id
It definitely would have been an option, although it would have been more difficult due to the complex structure of the new database. But I want to understand why it can't work the way I thought it would. Anyway, here's the code that I used in the end. There may still be a few bugs but it demonstrates the approach. I attached the whole file but here's a little sample. val clients = scala.collection.mutable.Map[Long, Client]() ... DB.exec(sourceCon, select * from clients) {rs = import rs._ while(rs.next) { val c = Client.create.last(getString(last)).first(getString(first)). home(getString(home)).cell(getString(cell)).address(getString(address)). area(getString(area)).created(getDate(created)).modified(getDate(modified)) if(!c.save) println(Couldn't save: + c) clients += getLong(id) - c } } Then I have a Map from the old id to the Client, and when I process the Request which has a client_id I can write req.client(clients(getLong(client_id))) So I guess I could do this by writing direct SQL, but then after I wrote each client I would have to retrieve its new id. Now I know that some databases like MS Access don't let you specify a value for an autonumber field, and in most cases there's no reason to specify it, but I think that the use case is enough to question the logic of always assuming that if the id is 0 then it's not a new record, if there is a more straightforward and accurate way to determine that. On Tue, Aug 25, 2009 at 11:17 AM, David Pollakfeeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 7:08 AM, Naftoli Gugenheim naftoli...@gmail.com wrote: I had seen that thread, but it doesn't make sense to add all that code to all of my mapper models when they're ordinary mappers with ordinary auto-increment primary keys, which I happen to be importing from the database used by the previous, PHP version of this app. The foreign keys have to match up properly. Meanwhile I changed it so that it keeps a Map in memory from old ids to mapper instances, and linked children to the mapper with the new id. But wouldn't the logic of saved_? make more sense the way I proposed? For the load operation where you're moving databases, why not just write some custom code to dump the data? - Peter Robinettpe...@bubblefoundry.com wrote: You need to set the mapper id field as editable. Here is what I had to do to use a MappedStringIndex as a primary key that I can set manually: /* MAC address as primary key */ def primaryKeyField = mac object mac extends MappedStringIndex(this, 17) with IndexedField [String] { override def dbDisplay_? = true override lazy val defaultValue = randomString(maxLen) /* allow user-defined primary key */ override def writePermission_? = true override def dbAutogenerated_? = false private var myDirty = false override def dirty_? = myDirty override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?(b) } override def fieldCreatorString(dbType: DriverType, colName: String): String = colName+ CHAR(+maxLen+) NOT NULL } Peter On Aug 24, 5:30 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: I'm trying to import data from a non-mapper-based database to one that is. I'm reading data with DB.exec and trying to save it using Mapper, but it's not getting saved. I'm guessing that since I'm setting the id (in runSafe) it thinks it needs to do an update, not an insert. Is there a workaround? Also, doesn't this scenario break the logic of MetaMapper.saved_?() ? Wouldn't it make more sense to have a saved flag that is cleared by default and set when it's created as a result of a find, and after it's saved? -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~--- Import.scala Description: Binary data
[Lift] Re: Read context param
That doesn't seem to help. Here's the code from DbStarter: // This will get the setting from a context-param in web.xml if defined: ServletContext servletContext = servletContextEvent.getServletContext(); String url = getParameter(servletContext, db.url, jdbc:h2:~/test); String user = getParameter(servletContext, db.user, sa); String password = getParameter(servletContext, db.password, sa); conn = DriverManager.getConnection(url, user, password); servletContext.setAttribute(connection, conn); 2009/8/20 marius d. marius.dan...@gmail.com Ok ... HTTPContext now has: def initParam(name: String): Box[String] def initParams: List[(String, String)] HTTPRequest has def context: HTTPContext LiftRules has (this was supported since a while. Sonow in boot you have access to HTTPContext and init parameters.) def context: HTTPContext Br's, Marius On Aug 20, 8:53 am, Naftoli Gugenheim naftoli...@gmail.com wrote: H2's DbStarter reads the url/username/password and stores a connection object back in the servlet context. - marius d.marius.dan...@gmail.com wrote: I think that regardless of Naftoli's particular case he brought up a valid point such as if when initializing a servlet user has a ServletConfig ... we could easily abstract things here as well to make it available in Boot as well. I'll noodle on this and see what I can do. Of course I would not recommend using web.xml init params (unless there are really compelling reasons to do so) but rather a Lift config or an application config ... but that's just me. Br's, Marius On Aug 20, 1:15 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Aug 19, 2009 at 11:29 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: How can I read a context param (e.g. H2 sets connection param)? Why is the context necessary to figure out the DB connection parameter? -- 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: Submit to different page
David, The action attribute is no different than class, id and target attributes currently supported when lift is magically building the form tag around the snippet content. My other notes inline. Br's, Marius On Aug 25, 8:11 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:46 AM, marius d. marius.dan...@gmail.com wrote: The topic was brought up in the discussion. Br's, Marius On Aug 25, 7:32 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:23 AM, marius d. marius.dan...@gmail.com wrote: 1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form I'm not overly keen on the change (I'm not asking for it to be removed). The reason for the form attribute was that it's common to do postbacks and the generation of S.uri as part of the URL was a bunch of boilerplate. This commit does not contradict this rule. People can use action only if they really need to without the boiler plate of typing the form tag. Right, but it's a place where Lift is mutating the result of the snippet call. This should only be done if there is a compelling reason. I see no compelling reason here. This case is a fringe case and can easily be handled with a static form tag. The reason for the form attribute is that it's the common case for wrapping a snippet in a post-back form and the URL of the postback would require yet another snippet to calculate... and the feature made it into Lift before attribute snippets. So, the rules are: (1) Lift does not mutate what the snippet returns except under extremely compelling situations and (2) we don't add reserved word attributes except under compelling situations. That's the reason I made the exception to the snippets result in whatever is returned from the snippet rather than having magic intervention rule. I really don't see how this implies a magic intervention since all this applies only if user explicitly adds action attribute. I mean if users explicitly points to a new page they expect that page to be rendered naturally which is what is happening. Except for the form='xxx' attribute, I know of no other attribute that's baked into Lift's snippet handling mechanism. The use of this attribute is the only time that I know of that Lift's snippet handler mutates the result of the snippet by putting a form/ tag around it. In all other cases, it's up to the snippet itself to interpret the attributes. If we keep adding attributes that cause something to happen if the attribute appears, it will reduce the attributes available for use by snippets themselves. In the future, let's not mutate what the snippet returns without a discussion and a very strong justification. I really don't see the problem. The form attribute tells the user that a form will be rendered. Since a form will be rendered why can't the user change the action in exceptional cases since this doesn't induce side effects. If it does please let me know what are those side effects. It removes an attribute that's available for generic use by snippets. If there's code out there that uses the action attribute as part of the snippet, what are the impacts on that snippet? There is no impact really. Current behavior is not altered in any way. If user uses the action attribute he/she explicitly tells I just what to got to this URI instead of the default one. If user doesn't use action attribut it'll render S.uri as it currently does. If there are form snippets out there using the action attribute has no impact of the snippet per se but we'll put that value to the action of the form which indeed will not be ok. Still I really doubt that there are snippets using form attribute that uses action attribute for a different meaning that for a normal html form. Same question can apply for current supported attributed class, id and target and that's ok. I haven't seen people complaining that they use the class attribut expressing something else then a CSS class. I think people are very comfortable and knowledgeable in terms of HTML semantics and they just don't mix these semantics with something else. If you want to I have no problem removing it but I really don't see what the issue is. Thanks, David In both cases you can use Lift's html abstractions such as SHtml.text etc. and bind your function. In the second example we used a snippet that has no idea about form ... it is just wrapped by a form. So in both cases you don't really need to call S.attr to manually get parameters. Br's, Marius On Aug 25, 6:24 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 12:38 AM, Ulises
[Lift] Re: Submit to different page
On Tue, Aug 25, 2009 at 11:09 AM, marius d. marius.dan...@gmail.com wrote: David, The action attribute is no different than class, id and target attributes currently supported when lift is magically building the form tag around the snippet content. My other notes inline. Br's, Marius On Aug 25, 8:11 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:46 AM, marius d. marius.dan...@gmail.com wrote: The topic was brought up in the discussion. Br's, Marius On Aug 25, 7:32 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:23 AM, marius d. marius.dan...@gmail.com wrote: 1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form I'm not overly keen on the change (I'm not asking for it to be removed). The reason for the form attribute was that it's common to do postbacks and the generation of S.uri as part of the URL was a bunch of boilerplate. This commit does not contradict this rule. People can use action only if they really need to without the boiler plate of typing the form tag. Right, but it's a place where Lift is mutating the result of the snippet call. This should only be done if there is a compelling reason. I see no compelling reason here. This case is a fringe case and can easily be handled with a static form tag. The reason for the form attribute is that it's the common case for wrapping a snippet in a post-back form and the URL of the postback would require yet another snippet to calculate... and the feature made it into Lift before attribute snippets. So, the rules are: (1) Lift does not mutate what the snippet returns except under extremely compelling situations and (2) we don't add reserved word attributes except under compelling situations. That's the reason I made the exception to the snippets result in whatever is returned from the snippet rather than having magic intervention rule. I really don't see how this implies a magic intervention since all this applies only if user explicitly adds action attribute. I mean if users explicitly points to a new page they expect that page to be rendered naturally which is what is happening. Except for the form='xxx' attribute, I know of no other attribute that's baked into Lift's snippet handling mechanism. The use of this attribute is the only time that I know of that Lift's snippet handler mutates the result of the snippet by putting a form/ tag around it. In all other cases, it's up to the snippet itself to interpret the attributes. If we keep adding attributes that cause something to happen if the attribute appears, it will reduce the attributes available for use by snippets themselves. In the future, let's not mutate what the snippet returns without a discussion and a very strong justification. I really don't see the problem. The form attribute tells the user that a form will be rendered. Since a form will be rendered why can't the user change the action in exceptional cases since this doesn't induce side effects. If it does please let me know what are those side effects. It removes an attribute that's available for generic use by snippets. If there's code out there that uses the action attribute as part of the snippet, what are the impacts on that snippet? There is no impact really. Current behavior is not altered in any way. If user uses the action attribute he/she explicitly tells I just what to got to this URI instead of the default one. If user doesn't use action attribut it'll render S.uri as it currently does. If there are form snippets out there using the action attribute has no impact of the snippet per se but we'll put that value to the action of the form which indeed will not be ok. Still I really doubt that there are snippets using form attribute that uses action attribute for a different meaning that for a normal html form. Same question can apply for current supported attributed class, id and target and that's ok. I haven't seen people complaining that they use the class attribut expressing something else then a CSS class. I think people are very comfortable and knowledgeable in terms of HTML semantics and they just don't mix these semantics with something else. I was unaware of these attributes being co-opted by the form handler. Under the standard: (1) Lift does not mutate what the snippet returns except under extremely compelling situations and (2) we don't add reserved word attributes except under compelling situations. The copying of id and class (and probably style) would meet the test. It's extremely compelling because almost
[Lift] Re: Read context param
So you need access attributes not to context params (which are only init params). Should be no problem abstracting over those. Give me a little time. If you really need in certain cases the servlet-context here is how to get it LiftRules.context match { case context: HTTPServletContext = context.ctx // this is a ServletContext reference } ... although I wouldn't recommend adding such dependencies. Br's, Marius On Aug 25, 8:41 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: That doesn't seem to help. Here's the code from DbStarter: // This will get the setting from a context-param in web.xml if defined: ServletContext servletContext = servletContextEvent.getServletContext(); String url = getParameter(servletContext, db.url, jdbc:h2:~/test); String user = getParameter(servletContext, db.user, sa); String password = getParameter(servletContext, db.password, sa); conn = DriverManager.getConnection(url, user, password); servletContext.setAttribute(connection, conn); 2009/8/20 marius d. marius.dan...@gmail.com Ok ... HTTPContext now has: def initParam(name: String): Box[String] def initParams: List[(String, String)] HTTPRequest has def context: HTTPContext LiftRules has (this was supported since a while. Sonow in boot you have access to HTTPContext and init parameters.) def context: HTTPContext Br's, Marius On Aug 20, 8:53 am, Naftoli Gugenheim naftoli...@gmail.com wrote: H2's DbStarter reads the url/username/password and stores a connection object back in the servlet context. - marius d.marius.dan...@gmail.com wrote: I think that regardless of Naftoli's particular case he brought up a valid point such as if when initializing a servlet user has a ServletConfig ... we could easily abstract things here as well to make it available in Boot as well. I'll noodle on this and see what I can do. Of course I would not recommend using web.xml init params (unless there are really compelling reasons to do so) but rather a Lift config or an application config ... but that's just me. Br's, Marius On Aug 20, 1:15 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Aug 19, 2009 at 11:29 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: How can I read a context param (e.g. H2 sets connection param)? Why is the context necessary to figure out the DB connection parameter? -- 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: Mapper with custom id
On Tue, Aug 25, 2009 at 10:56 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: It definitely would have been an option, although it would have been more difficult due to the complex structure of the new database. But I want to understand why it can't work the way I thought it would. Peter provided code that allows you to override autogeneration of keys. Why does it work the way it does? Because in the nearly 3 year life of Mapper, you're the first person that's asked for the feature. Because the cost of changing Mapper to work differently (especially when there's a work-around) and testing it and making sure it doesn't break isn't worth it. Anyway, here's the code that I used in the end. There may still be a few bugs but it demonstrates the approach. I attached the whole file but here's a little sample. val clients = scala.collection.mutable.Map[Long, Client]() ... DB.exec(sourceCon, select * from clients) {rs = import rs._ while(rs.next) { val c = Client.create.last(getString(last)).first(getString(first)). home(getString(home)).cell(getString(cell)).address(getString(address)). area(getString(area)).created(getDate(created)).modified(getDate(modified)) if(!c.save) println(Couldn't save: + c) clients += getLong(id) - c } } Then I have a Map from the old id to the Client, and when I process the Request which has a client_id I can write req.client(clients(getLong(client_id))) So I guess I could do this by writing direct SQL, but then after I wrote each client I would have to retrieve its new id. Now I know that some databases like MS Access don't let you specify a value for an autonumber field, and in most cases there's no reason to specify it, but I think that the use case is enough to question the logic of always assuming that if the id is 0 then it's not a new record, if there is a more straightforward and accurate way to determine that. On Tue, Aug 25, 2009 at 11:17 AM, David Pollakfeeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 7:08 AM, Naftoli Gugenheim naftoli...@gmail.com wrote: I had seen that thread, but it doesn't make sense to add all that code to all of my mapper models when they're ordinary mappers with ordinary auto-increment primary keys, which I happen to be importing from the database used by the previous, PHP version of this app. The foreign keys have to match up properly. Meanwhile I changed it so that it keeps a Map in memory from old ids to mapper instances, and linked children to the mapper with the new id. But wouldn't the logic of saved_? make more sense the way I proposed? For the load operation where you're moving databases, why not just write some custom code to dump the data? - Peter Robinettpe...@bubblefoundry.com wrote: You need to set the mapper id field as editable. Here is what I had to do to use a MappedStringIndex as a primary key that I can set manually: /* MAC address as primary key */ def primaryKeyField = mac object mac extends MappedStringIndex(this, 17) with IndexedField [String] { override def dbDisplay_? = true override lazy val defaultValue = randomString(maxLen) /* allow user-defined primary key */ override def writePermission_? = true override def dbAutogenerated_? = false private var myDirty = false override def dirty_? = myDirty override def dirty_?(b : Boolean) = { myDirty = b; super.dirty_?(b) } override def fieldCreatorString(dbType: DriverType, colName: String): String = colName+ CHAR(+maxLen+) NOT NULL } Peter On Aug 24, 5:30 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: I'm trying to import data from a non-mapper-based database to one that is. I'm reading data with DB.exec and trying to save it using Mapper, but it's not getting saved. I'm guessing that since I'm setting the id (in runSafe) it thinks it needs to do an update, not an insert. Is there a workaround? Also, doesn't this scenario break the logic of MetaMapper.saved_?() ? Wouldn't it make more sense to have a saved flag that is cleared by default and set when it's created as a result of a find, and after it's saved? -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to
[Lift] Re: Mapper with custom id
On Tue, Aug 25, 2009 at 2:31 PM, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 10:56 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: It definitely would have been an option, although it would have been more difficult due to the complex structure of the new database. But I want to understand why it can't work the way I thought it would. Peter provided code that allows you to override autogeneration of keys. Like I said, it doesn't make sense to add 5 lines of code to 13 mappers each just to make importing simpler. That code is good for a non-autogenerated primary key. Why does it work the way it does? Because in the nearly 3 year life of Mapper, you're the first person that's asked for the feature. Because the cost of changing Mapper to work differently (especially when there's a work-around) and testing it and making sure it doesn't break isn't worth it. Well, I can't argue with that... But is it really so complicated to change? Would the following not cover all the bases? 1) A private var on the mapper, _saved_? etc., initialized to false 2) When find etc. creates an instance it uses reflection to set this variable to true 3) When save is successful it sets this variable to true 4) def saved_? returns the value of the var. Wouldn't that be more accurate from a logical standpoint? I'm not coming from the angle of, I have a use case for a feature, but from, doesn't this use case bring out a hole in the logic and demonstrate that the index can be nondefault and still represent a new record (aside from MSAccess)? Regards --~--~-~--~~~---~--~~ 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: Read context param
On Tue, Aug 25, 2009 at 2:29 PM, marius d. marius.dan...@gmail.com wrote: So you need access attributes not to context params (which are only init params). Should be no problem abstracting over those. Give me a little time. If you really need in certain cases the servlet-context here is how to get it LiftRules.context match { case context: HTTPServletContext = context.ctx // this is a ServletContext reference } ... although I wouldn't recommend adding such dependencies. In this case I'm not too worried, it's pretty small-scale. Anyway I guess I'll do this for now and update my code when you tell me the new way to do it. Thanks! Br's, Marius On Aug 25, 8:41 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: That doesn't seem to help. Here's the code from DbStarter: // This will get the setting from a context-param in web.xml if defined: ServletContext servletContext = servletContextEvent.getServletContext(); String url = getParameter(servletContext, db.url, jdbc:h2:~/test); String user = getParameter(servletContext, db.user, sa); String password = getParameter(servletContext, db.password, sa); conn = DriverManager.getConnection(url, user, password); servletContext.setAttribute(connection, conn); 2009/8/20 marius d. marius.dan...@gmail.com Ok ... HTTPContext now has: def initParam(name: String): Box[String] def initParams: List[(String, String)] HTTPRequest has def context: HTTPContext LiftRules has (this was supported since a while. Sonow in boot you have access to HTTPContext and init parameters.) def context: HTTPContext Br's, Marius On Aug 20, 8:53 am, Naftoli Gugenheim naftoli...@gmail.com wrote: H2's DbStarter reads the url/username/password and stores a connection object back in the servlet context. - marius d.marius.dan...@gmail.com wrote: I think that regardless of Naftoli's particular case he brought up a valid point such as if when initializing a servlet user has a ServletConfig ... we could easily abstract things here as well to make it available in Boot as well. I'll noodle on this and see what I can do. Of course I would not recommend using web.xml init params (unless there are really compelling reasons to do so) but rather a Lift config or an application config ... but that's just me. Br's, Marius On Aug 20, 1:15 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Aug 19, 2009 at 11:29 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: How can I read a context param (e.g. H2 sets connection param)? Why is the context necessary to figure out the DB connection parameter? -- 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: Submit to different page
On Aug 25, 9:26 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 11:09 AM, marius d. marius.dan...@gmail.com wrote: David, The action attribute is no different than class, id and target attributes currently supported when lift is magically building the form tag around the snippet content. My other notes inline. Br's, Marius On Aug 25, 8:11 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:46 AM, marius d. marius.dan...@gmail.com wrote: The topic was brought up in the discussion. Br's, Marius On Aug 25, 7:32 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:23 AM, marius d. marius.dan...@gmail.com wrote: 1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form I'm not overly keen on the change (I'm not asking for it to be removed). The reason for the form attribute was that it's common to do postbacks and the generation of S.uri as part of the URL was a bunch of boilerplate. This commit does not contradict this rule. People can use action only if they really need to without the boiler plate of typing the form tag. Right, but it's a place where Lift is mutating the result of the snippet call. This should only be done if there is a compelling reason. I see no compelling reason here. This case is a fringe case and can easily be handled with a static form tag. The reason for the form attribute is that it's the common case for wrapping a snippet in a post-back form and the URL of the postback would require yet another snippet to calculate... and the feature made it into Lift before attribute snippets. So, the rules are: (1) Lift does not mutate what the snippet returns except under extremely compelling situations and (2) we don't add reserved word attributes except under compelling situations. That's the reason I made the exception to the snippets result in whatever is returned from the snippet rather than having magic intervention rule. I really don't see how this implies a magic intervention since all this applies only if user explicitly adds action attribute. I mean if users explicitly points to a new page they expect that page to be rendered naturally which is what is happening. Except for the form='xxx' attribute, I know of no other attribute that's baked into Lift's snippet handling mechanism. The use of this attribute is the only time that I know of that Lift's snippet handler mutates the result of the snippet by putting a form/ tag around it. In all other cases, it's up to the snippet itself to interpret the attributes. If we keep adding attributes that cause something to happen if the attribute appears, it will reduce the attributes available for use by snippets themselves. In the future, let's not mutate what the snippet returns without a discussion and a very strong justification. I really don't see the problem. The form attribute tells the user that a form will be rendered. Since a form will be rendered why can't the user change the action in exceptional cases since this doesn't induce side effects. If it does please let me know what are those side effects. It removes an attribute that's available for generic use by snippets. If there's code out there that uses the action attribute as part of the snippet, what are the impacts on that snippet? There is no impact really. Current behavior is not altered in any way. If user uses the action attribute he/she explicitly tells I just what to got to this URI instead of the default one. If user doesn't use action attribut it'll render S.uri as it currently does. If there are form snippets out there using the action attribute has no impact of the snippet per se but we'll put that value to the action of the form which indeed will not be ok. Still I really doubt that there are snippets using form attribute that uses action attribute for a different meaning that for a normal html form. Same question can apply for current supported attributed class, id and target and that's ok. I haven't seen people complaining that they use the class attribut expressing something else then a CSS class. I think people are very comfortable and knowledgeable in terms of HTML semantics and they just don't mix these semantics with something else. I was unaware of these attributes being co-opted by the form handler. Under the standard: (1) Lift does not mutate what the snippet returns except under extremely compelling situations and (2) we don't add reserved word attributes except
[Lift] Re: keep showing user entered value in toForm when it doesn't validate?
Harry, What's going on is that the instance of your model class that's being validated is different from the instance of the model class that's used to render your form. There are two ways to deal with this: RequestVars and StatefulSnippets. For RequestVars: object MyThing extends RequestVar(Thing.create) class MySnippet { def render(xhtml: NodeSeq): NodeSeq = { val thing = MyThing.is bind(info, xhtml, name - SHtml.hidden(() = MyThing.set(thing)) ++ thing.name.toForm) } } For stateful snippets: class MySnippet extends StatefulSnippet { val thing = Thing.create def dispatch = { case _ = render _ } def render(xhtml: NodeSeq): NodeSeq = { bind(info, xhtml, name - thing.name.toForm) } } THanks, David On Tue, Aug 25, 2009 at 12:03 PM, harryh har...@gmail.com wrote: Let's say I have something like so: object name extends MappedString(this, 50) { override def validations = valMinLen(5, name must be at least 5 characters) _ :: super.validations } I can now easily use myObject.name.toForm to generate an input elements and deal with the results. But let's say the user enters Bob for their name so it doesn't validate (and they get an appropriate error message). When this happens, the field resets back to the original value. What I'd really like to do is keep the user entered value with the expectation that the user would change it before re-submitting. The same is true for all of the other fields on the form. When there is an error in one of them, they all reset back to the orignal state. (so an error in 1 field means the user has to re enter the data in all fields). Is there a trivial way to fix this? Planning to dive into the sourcecode if there isn't, but what I want kind of seems like what should maybe be default behavior for MappedFoo objects. -harryh -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Read context param
Try to do an update and see HttpContext attribute, setAttribute, removeAttribute functions. These functions are not typesafe as the value is an Any so you'd need to cast it yourself. I don't like this but then again HTTP web containers are not really typesafe in many cases. Br's, Marius On Aug 25, 9:44 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: On Tue, Aug 25, 2009 at 2:29 PM, marius d. marius.dan...@gmail.com wrote: So you need access attributes not to context params (which are only init params). Should be no problem abstracting over those. Give me a little time. If you really need in certain cases the servlet-context here is how to get it LiftRules.context match { case context: HTTPServletContext = context.ctx // this is a ServletContext reference } ... although I wouldn't recommend adding such dependencies. In this case I'm not too worried, it's pretty small-scale. Anyway I guess I'll do this for now and update my code when you tell me the new way to do it. Thanks! Br's, Marius On Aug 25, 8:41 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: That doesn't seem to help. Here's the code from DbStarter: // This will get the setting from a context-param in web.xml if defined: ServletContext servletContext = servletContextEvent.getServletContext(); String url = getParameter(servletContext, db.url, jdbc:h2:~/test); String user = getParameter(servletContext, db.user, sa); String password = getParameter(servletContext, db.password, sa); conn = DriverManager.getConnection(url, user, password); servletContext.setAttribute(connection, conn); 2009/8/20 marius d. marius.dan...@gmail.com Ok ... HTTPContext now has: def initParam(name: String): Box[String] def initParams: List[(String, String)] HTTPRequest has def context: HTTPContext LiftRules has (this was supported since a while. Sonow in boot you have access to HTTPContext and init parameters.) def context: HTTPContext Br's, Marius On Aug 20, 8:53 am, Naftoli Gugenheim naftoli...@gmail.com wrote: H2's DbStarter reads the url/username/password and stores a connection object back in the servlet context. - marius d.marius.dan...@gmail.com wrote: I think that regardless of Naftoli's particular case he brought up a valid point such as if when initializing a servlet user has a ServletConfig ... we could easily abstract things here as well to make it available in Boot as well. I'll noodle on this and see what I can do. Of course I would not recommend using web.xml init params (unless there are really compelling reasons to do so) but rather a Lift config or an application config ... but that's just me. Br's, Marius On Aug 20, 1:15 am, David Pollak feeder.of.the.be...@gmail.com wrote: On Wed, Aug 19, 2009 at 11:29 AM, Naftoli Gugenheim naftoli...@gmail.comwrote: How can I read a context param (e.g. H2 sets connection param)? Why is the context necessary to figure out the DB connection parameter? -- 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: Submit to different page
It's out :) Br's, Marius On Aug 25, 9:45 pm, marius d. marius.dan...@gmail.com wrote: On Aug 25, 9:26 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 11:09 AM, marius d. marius.dan...@gmail.com wrote: David, The action attribute is no different than class, id and target attributes currently supported when lift is magically building the form tag around the snippet content. My other notes inline. Br's, Marius On Aug 25, 8:11 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:46 AM, marius d. marius.dan...@gmail.com wrote: The topic was brought up in the discussion. Br's, Marius On Aug 25, 7:32 pm, David Pollak feeder.of.the.be...@gmail.com wrote: On Tue, Aug 25, 2009 at 9:23 AM, marius d. marius.dan...@gmail.com wrote: 1. I just pushed a little change that allows: lift:MySnippet form=post action=/search ... /lift:MySnippet 2. You can also do form method=post action=/search lift:mysnippet f:inputSearch/ f:submit/ /mysnippet /form I'm not overly keen on the change (I'm not asking for it to be removed). The reason for the form attribute was that it's common to do postbacks and the generation of S.uri as part of the URL was a bunch of boilerplate. This commit does not contradict this rule. People can use action only if they really need to without the boiler plate of typing the form tag. Right, but it's a place where Lift is mutating the result of the snippet call. This should only be done if there is a compelling reason. I see no compelling reason here. This case is a fringe case and can easily be handled with a static form tag. The reason for the form attribute is that it's the common case for wrapping a snippet in a post-back form and the URL of the postback would require yet another snippet to calculate... and the feature made it into Lift before attribute snippets. So, the rules are: (1) Lift does not mutate what the snippet returns except under extremely compelling situations and (2) we don't add reserved word attributes except under compelling situations. That's the reason I made the exception to the snippets result in whatever is returned from the snippet rather than having magic intervention rule. I really don't see how this implies a magic intervention since all this applies only if user explicitly adds action attribute. I mean if users explicitly points to a new page they expect that page to be rendered naturally which is what is happening. Except for the form='xxx' attribute, I know of no other attribute that's baked into Lift's snippet handling mechanism. The use of this attribute is the only time that I know of that Lift's snippet handler mutates the result of the snippet by putting a form/ tag around it. In all other cases, it's up to the snippet itself to interpret the attributes. If we keep adding attributes that cause something to happen if the attribute appears, it will reduce the attributes available for use by snippets themselves. In the future, let's not mutate what the snippet returns without a discussion and a very strong justification. I really don't see the problem. The form attribute tells the user that a form will be rendered. Since a form will be rendered why can't the user change the action in exceptional cases since this doesn't induce side effects. If it does please let me know what are those side effects. It removes an attribute that's available for generic use by snippets. If there's code out there that uses the action attribute as part of the snippet, what are the impacts on that snippet? There is no impact really. Current behavior is not altered in any way. If user uses the action attribute he/she explicitly tells I just what to got to this URI instead of the default one. If user doesn't use action attribut it'll render S.uri as it currently does. If there are form snippets out there using the action attribute has no impact of the snippet per se but we'll put that value to the action of the form which indeed will not be ok. Still I really doubt that there are snippets using form attribute that uses action attribute for a different meaning that for a normal html form. Same question can apply for current supported attributed class, id and target and that's ok. I haven't seen people complaining that they use the class attribut expressing something else then a CSS class. I think people are very comfortable and knowledgeable in terms of HTML semantics and they just don't mix these semantics with something else. I was unaware of these attributes
[Lift] Re: keep showing user entered value in toForm when it doesn't validate?
There are two ways to deal with this: RequestVars and StatefulSnippets. What about in cases where I'm not creating a new Thing, but editing an existing one. It seems like what maybe should be done is down in the guts of the toForm function it should be examining S.attr([the field guid]) it if that exists the input should get that value instead of the current state of the Thing. -harryh --~--~-~--~~~---~--~~ 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] Redirecting during snippet instantiation revisited
Two weeks ago I posted asking about redirection during snippet instantiation: in the current version of 1.1, if you try S.redirectTo (or StatefulSnippet.redirect) while constructing a snippet, it causes a SnippetFailure.InstantiationException rather than redirecting. Originally I thought it was more complicated to make this work, but I looked at it again because the work around I put in place bugged me, and it turns out it's a pretty small change. http://github.com/Dridus/liftweb/commit/3cb2596f502db37a5242eed9ff4127a08953d799 I've made the change in a fork, and I was hoping that if it wasn't thought to be a bad change that it could be pulled into 1.1? The original conversation which was essentially between myself and Naftoli is here: http://groups.google.com/group/liftweb/browse_thread/thread/1214840c7196f778/fe80f5a54423eafd -Ross --~--~-~--~~~---~--~~ 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] keep showing user entered value in toForm when it doesn't validate?
Let's say I have something like so: object name extends MappedString(this, 50) { override def validations = valMinLen(5, name must be at least 5 characters) _ :: super.validations } I can now easily use myObject.name.toForm to generate an input elements and deal with the results. But let's say the user enters Bob for their name so it doesn't validate (and they get an appropriate error message). When this happens, the field resets back to the original value. What I'd really like to do is keep the user entered value with the expectation that the user would change it before re-submitting. The same is true for all of the other fields on the form. When there is an error in one of them, they all reset back to the orignal state. (so an error in 1 field means the user has to re enter the data in all fields). Is there a trivial way to fix this? Planning to dive into the sourcecode if there isn't, but what I want kind of seems like what should maybe be default behavior for MappedFoo objects. -harryh --~--~-~--~~~---~--~~ 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: keep showing user entered value in toForm when it doesn't validate?
On Tue, Aug 25, 2009 at 12:36 PM, harryh har...@gmail.com wrote: There are two ways to deal with this: RequestVars and StatefulSnippets. What about in cases where I'm not creating a new Thing, but editing an existing one. In the RequestVar case, you could have a function associated with the link that brings you to the page that sets the RequestVar to an existing instance. In the case of the StatefulSnippet replace the Thing.create with calculateThing openOr Thing.create where calculateThing determines the instance. It seems like what maybe should be done is down in the guts of the toForm function it should be examining S.attr([the field guid]) it if that exists the input should get that value instead of the current state of the Thing. I'm not sure I understand what you're suggesting. Can you be a little more explicit about your suggestion? -harryh -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Redirecting during snippet instantiation revisited
I've just pushed a change that should satisfy your requirements. On Tue, Aug 25, 2009 at 11:59 AM, Ross Mellgren dri...@gmail.com wrote: Two weeks ago I posted asking about redirection during snippet instantiation: in the current version of 1.1, if you try S.redirectTo (or StatefulSnippet.redirect) while constructing a snippet, it causes a SnippetFailure.InstantiationException rather than redirecting. Originally I thought it was more complicated to make this work, but I looked at it again because the work around I put in place bugged me, and it turns out it's a pretty small change. http://github.com/Dridus/liftweb/commit/3cb2596f502db37a5242eed9ff4127a08953d799 I've made the change in a fork, and I was hoping that if it wasn't thought to be a bad change that it could be pulled into 1.1? The original conversation which was essentially between myself and Naftoli is here: http://groups.google.com/group/liftweb/browse_thread/thread/1214840c7196f778/fe80f5a54423eafd -Ross -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: keep showing user entered value in toForm when it doesn't validate?
I think what David is saying is that your misdiagnosing the problem. Validation is not resetting the value; it's just failing to save, and the next page load is fetching whatever's in the database, which is the old value.Could you post the could the generates the form, and the code that retrieves the mapper instance? On Tue, Aug 25, 2009 at 3:52 PM, harryh har...@gmail.com wrote: I'm not sure I understand what you're suggesting. Can you be a little more explicit about your suggestion? OK, so I'm editing an existing Thing with name currently = Harry (which is valid as it has = 5 chars) I do a GET /editThing?id=12 in return I get a form which contains (among other things): input type=text name=AGUID value=Harry / I change the value of the field to Bob and press submit which does a POST /editThing and down in the HTTP body is AGUID=Bob Up on the server this doesn't validate, so it doesn't save the Thing with this new value, so it sends back the form again. While rending the form, inside one of my snippets I call someThing.name.toForm. The implementation of this function, when it is creating the input element and setting it's value. Rather than blindly setting the value to to theThing.name (Harry) could check S.attr(AGUID) and, if it exists, set the value of the field to that instead. So a POST that resulted in errors would, by default, render the form with the user entered values (some of which could be invalid) still there making it easy for the user to make corrections and resubmit. -harryh --~--~-~--~~~---~--~~ 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: keep showing user entered value in toForm when it doesn't validate?
On Tue, Aug 25, 2009 at 12:52 PM, harryh har...@gmail.com wrote: I'm not sure I understand what you're suggesting. Can you be a little more explicit about your suggestion? OK, so I'm editing an existing Thing with name currently = Harry (which is valid as it has = 5 chars) I do a GET /editThing?id=12 in return I get a form which contains (among other things): input type=text name=AGUID value=Harry / I change the value of the field to Bob and press submit which does a POST /editThing and down in the HTTP body is AGUID=Bob Up on the server this doesn't validate, so it doesn't save the Thing with this new value, so it sends back the form again. While rending the form, inside one of my snippets I call someThing.name.toForm. The implementation of this function, when it is creating the input element and setting it's value. Rather than blindly setting the value to to theThing.name (Harry) could check S.attr(AGUID) and, if it exists, set the value of the field to that instead. So a POST that resulted in errors would, by default, render the form with the user entered values (some of which could be invalid) still there making it easy for the user to make corrections and resubmit. There are a bunch of reasons why that can't work. First, when you bind to the value thing in a snippet (not a StatefulSnippet), it's not possible to reach into the stack and replace the stack frame that represents thing with another reference. Second, even if you could replace the value of thing, the function that's bound to the form element doesn't know anything about stack frames. Thus, we've got stateful snippets that deal with the problem. -harryh -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: keep showing user entered value in toForm when it doesn't validate?
I think what David is saying is that your misdiagnosing the problem. Validation is not resetting the value; it's just failing to save, and the next page load is fetching whatever's in the database, which is the old value Ah yes. OK, this makes perfect sense now. I should have understood based on David's first message. Thx to both of you for your help, I think I know what I need to do now. -harryh --~--~-~--~~~---~--~~ 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 I do something like this with nested snippets?
That seems to make sense mostly. I'll give it a try. One thing I am not sure about is this: As the License.index is iterating over the licenses, when I call License.id how will the License snippet know which is the current object? Do I have to maintain a reference to it somewhere? 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: Menu builder group and li_item
Yeah... I broke things rather than fixing them... I've checked in something that I believe addresses your issue and fixes the other user's issue. On Tue, Aug 25, 2009 at 9:36 AM, george geo...@mattandgeorge.com wrote: Thanks for looking into this so quickly. I haven't had a chance to test it yet, but I notice another user is now having a slightly different problem. Not sure if it's related. http://groups.google.com/group/liftweb/browse_thread/thread/12415c178ee7b1ee/75d38df3617f77b6#75d38df3617f77b6 -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: can I do something like this with nested snippets?
Yes, either in a RequestVar or make License a StatefulSnippet and use a regular class var. On Tue, Aug 25, 2009 at 4:43 PM, george geo...@mattandgeorge.com wrote: That seems to make sense mostly. I'll give it a try. One thing I am not sure about is this: As the License.index is iterating over the licenses, when I call License.id how will the License snippet know which is the current object? Do I have to maintain a reference to it somewhere? 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: Menu.builder li_item being applied to all?
I think I've fixed my bone-headed attempt to fix another issue. On Tue, Aug 25, 2009 at 5:48 AM, Richard Dallaway dalla...@gmail.comwrote: I've been running mvn -o for a while, but didn't today and noticed a change in behaviour for the menu builder (1.1 SNAPSHOT). I'm seeing all my menus being given the selected item class, not just the one that's selected for the page you're on. I'm using... lift:Menu.builder li_item:class=current_tab / I've cut my site map down to this... val menus = Menu(Loc(one, new Link(index :: Nil, false), Page 1)) :: Menu(Loc(two, new Link(index2 :: Nil, false), Page 2)) :: Nil LiftRules.setSiteMap(SiteMap(menus:_*)) ...and I see the following output: ulli class=current_taba href=/indexPage 1/a/lili class=current_tabspanPage 2/span/li/ul I'd expect only one of the li elements to have the class attribute. Am I doing something wrong here? Thank you Richard -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: can I do something like this with nested snippets?
Try (not sure if this is the correct syntax for snippet attributes): lift:Licenses.index h3l:type //h3 table lift:Ratings.index lift:Licenses.id= tr tdr:rating //td /tr /lift:Ratings.index /table /lift:Licenses.index Then you need an attribute snippet Licenses.id which generates MetaData (xml attributes), and then Ratings.index needs to call S.attr to read the attribute. I haven't tried doing this but this is my understanding. On Tue, Aug 25, 2009 at 4:21 PM, george geo...@mattandgeorge.com wrote: lift:Licenses.index h3l:type //h3 table lift:Ratings.index tr tdr:rating //td /tr /lift:Ratings.index /table /lift:Licenses.index --~--~-~--~~~---~--~~ 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 I do something like this with nested snippets?
lift:Licenses.index h3l:type //h3 table lift:Ratings.index tr tdr:rating //td /tr /lift:Ratings.index /table /lift:Licenses.index and if so.. can I pass a parameter to the inner Ratings.index snippet - e.g the ID of the current license object being processed - so that the Ratings.index function can use it to find the ratings. the idea being that this way I could re-use my existing Rating snippet code to display ratings on the same page as licenses. or is this just a bad idea? --~--~-~--~~~---~--~~ 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: Menu.builder li_item being applied to all?
Whenever I find myself having thoughts such as these its categorically time to start writing better tests ;-) Cheers, Tim On Aug 25, 9:55 pm, David Pollak feeder.of.the.be...@gmail.com wrote: I think I've fixed my bone-headed attempt to fix another issue. --~--~-~--~~~---~--~~ 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 features
Well, I managed to upload to github. Here is the repository: git://github.com/glennSilverman/UserMon.git Any feedback is appreciated. Glenn... On Aug 25, 10:43 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Google code? Sourceforge? ProjectLocker? There are a lot of choices... On Tue, Aug 25, 2009 at 12:37 PM, glenngl...@exmbly.com wrote: I have a working example of ManyToMany that adds roles to users. I would be happy to share my work but I have an aversion to github. I don't like it, It's a slower-than- molasses interface. It's buggy and user-hostile in my opinion. I'm looking for an alternative to make it public. Any suggestions would be appreciated. Glenn... On Aug 25, 7:08 am, Naftoli Gugenheim naftoli...@gmail.com wrote: This meaning the problem, or meaning ManyToMany? It's pretty simple to use. You're mapper should extend ManyToMany, and you should have a field: object m2m extends MappedManyToMany(.../*the two MetaMappers and foreign keys, see the docs/source*/) Then you can treat m2m as a Buffer, adding and deleting children. Call save on the mapper or m2m to propogate the adding/deleting to the database, and refresh to reset its contents to reflect the database. However, as noted currently the children must be saved before they are added. This is not the case for OneToMany, and for ManyToMany it should not be a problem because usually the children exist independently of the parent--that's why they can have 0 or 1 or more parents. - Randinnrand...@gmail.com wrote: Anyone have code showing this in action as it were? On Aug 6, 8:39 am, Naftoli Gugenheim naftoli...@gmail.com wrote: Oh, I think I know what the problem is. I think I should classify it as a bug. Since you're adding a Role that isn't saved yet, and ManyToMany tracks the children via the join table, it can't access the child. As a workaround save the Role before adding it, although the need to do so is against the idea of ManyToMany and OneToMany. I will see what I can do, G-d willing. - glenngl...@exmbly.com wrote: Naftoli, Hate to do this to you, but I'm getting the following error using ManyToMany for Users to Roles: Message: java.lang.RuntimeException: Broken join scala.Predef$.error(Predef.scala:76) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children$1$ $anonfun$apply$1.apply(ManyToMany.scala:54) net.liftweb.util.EmptyBox.openOr(Box.scala:372) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany$$anonfun$children $1.apply(ManyToMany.scala:54) scala.List.map(List.scala:812) net.liftweb.mapper.ManyToMany$MappedManyToMany.children (ManyToMany.scala:54) net.liftweb.mapper.ManyToMany$MappedManyToMany.elements (ManyToMany.scala:96) scala.Seq$class.flatMap(Seq.scala:293) net.liftweb.mapper.ManyToMany$MappedManyToMany.flatMap (ManyToMany.scala:44) def edit(ns: NodeSeq): NodeSeq = { val theUser = view.entity val addRole = TheBindParam(insert, view.snippet.link(edit, () = theUser.roles += new Role, Text(S?(Add Role bind(user, ns, firstname - text(theUser.firstName.is, theUser.firstName (_), (size,20)), lastname - text(theUser.lastName.is,theUser.lastName(_), (size, 30)), roles - theUser.roles.flatMap{role = bind(role, ns, name - role.name.toForm, remove - SHtml.submit(S?(Remove), ()= theUser.roles -= role) ) }, addRole, submit - SHtml.submit(S?(Save), ()=view.save) ) } The offending code seems to be the line: roles - theUser.roles.flatMap{ in the above bind method when I click on the addRole link. Here's my User class: class User extends MegaProtoUser[User] with ManyToMany[Long,User]{ def getSingleton = User // what's the meta server object roles extends MappedManyToMany(UserRole, UserRole.user, UserRole.role, Role) } What am I doing wrong? You can see how difficult it is to slog through this code, let alone just trying to explain the problem so I can get help. On Aug 5, 9:57 am, Naftoli Gugenheim naftoli...@gmail.com wrote: I'll try. By the way, as per my correction, you can implement list the regular way without ModelView, and just use ModelSnippet's load function in your edit link or button, passing it the User instance. - glenngl...@exmbly.com wrote:
[Lift] Re: net.liftweb.mapper.PreCache doesn't work well as my expect
PreCache works as expected. Here's the data model: class RoomChoice extends LongKeyedMapper[RoomChoice] with IdPK { def getSingleton = RoomChoice object name extends MappedPoliteString(this, 512) object price extends MappedInt(this){ override def defaultValue = 0 } } object RoomChoice extends RoomChoice with LongKeyedMetaMapper[RoomChoice] class User extends LongKeyedMapper[User] with IdPK { def getSingleton = User object account extends MappedPoliteString(this, 10) object roomChoice extends MappedLongForeignKey(this, RoomChoice) } object User extends User with LongKeyedMetaMapper[User] And here's the test: for { i - 1 to 50 } { User.create.roomChoice(RoomChoice.create.name(Fog +i).saveMe).save } User.findAll(PreCache(User.roomChoice)).foreach{ u = if (!u.roomChoice.cached_?) error(Failed +u) } User.findAll().foreach{ u = if (u.roomChoice.cached_?) error(Failed +u) } val rooms = User.findAll(PreCache(User.roomChoice)).flatMap(_.roomChoice.obj) println(Rooms +rooms) I'm enclosing code the demonstrate the functionality. Please let us know if there's something missing. Thanks, David On Mon, Aug 24, 2009 at 9:16 PM, koji koji@gmail.com wrote: Oops, so sorry for pasting wrong part. And sorry i didnt show my model's code my code is as below class RoomChoice extends LongKeyedMapper[RoomChoice] with IdPK { def getSingleton = RoomChoice object travel extends MappedLongForeignKey(this, Travel) object name extends MappedPoliteString(this, 512) object price extends MappedInt(this){ override def defaultValue = 0 } } class User extends LongKeyedMapper[User] with IdPK { def getSingleton = User object travel extends MappedLongForeignKey(this, Travel) object account extends MappedPoliteString(this, 10) object roomChoice extends MappedLongForeignKey(this, RoomChoice) } val users = User.findAll(By(User.travel, travelId),PreCache (User.roomChoice), OrderBy(User.id, Ascending)) thank you On Aug 25, 6:40 am, Derek Chen-Becker dchenbec...@gmail.com wrote: Maybe I'm missing something, but you're telling Mapper to pre-cache User.roomChoice, but then you're accessing User.fromPlace. Are those two fields related somehow? Derek On Mon, Aug 24, 2009 at 12:25 AM, koji koji@gmail.com wrote: Hi all, I want to avoid n+1 problem so i try to write my code as val users = User.findAll(PreCache(User.roomChoice), By(User.travel, travelId)) and i saw the sql generated only once for querying roomChoice. but when i using the u.fromPlace.obj, it always become Empty(u.fromPace has correct value) thanks -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~--- precache.tgz Description: GNU Zip compressed data
[Lift] Re: Redirecting during snippet instantiation revisited
Neat, I like your change better, as it's more general. Thanks! As a matter of code review though, the new ControlHelpers function doc comment refers to ignore as a list, when it's now a PF. -Ross On Aug 25, 2009, at 3:46 PM, David Pollak wrote: I've just pushed a change that should satisfy your requirements. On Tue, Aug 25, 2009 at 11:59 AM, Ross Mellgren dri...@gmail.com wrote: Two weeks ago I posted asking about redirection during snippet instantiation: in the current version of 1.1, if you try S.redirectTo (or StatefulSnippet.redirect) while constructing a snippet, it causes a SnippetFailure.InstantiationException rather than redirecting. Originally I thought it was more complicated to make this work, but I looked at it again because the work around I put in place bugged me, and it turns out it's a pretty small change. http://github.com/Dridus/liftweb/commit/3cb2596f502db37a5242eed9ff4127a08953d799 I've made the change in a fork, and I was hoping that if it wasn't thought to be a bad change that it could be pulled into 1.1? The original conversation which was essentially between myself and Naftoli is here: http://groups.google.com/group/liftweb/browse_thread/thread/1214840c7196f778/fe80f5a54423eafd -Ross -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Actors and Sockets
I want to read data from multiple sockets (typically about three sockets) which can each send their data to a set of actors (also typically about three actors). Multiple actors is no problem. But how to handle varying numbers of sockets is not clear to me. (Feeding the actor results into Lift I'll deal with when I have this sorted out.) Do you guys have a sense of whether it's realistic to roll my own socket handling or use MINA or AKKA or some other library to do it? Mal. --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Re: Menu builder group and li_item
awesome 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: New features
Great! Thank you both for you help. --~--~-~--~~~---~--~~ 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 I do something like this with nested snippets?
David - thanks for this. I understand most of what is going on here. I've not come across DynamicVariable before, but having looked it up I think I see why you have used it. Please could you explain a bit more what is happening in this line: CurrentLicense.withValue(Full(currentLicense)) {session.processSurroundAndInclude(PageName get, bound)} What/where is PageName get ? --~--~-~--~~~---~--~~ 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 I do something like this with nested snippets?
On Tue, Aug 25, 2009 at 3:09 PM, george geo...@mattandgeorge.com wrote: David - thanks for this. I understand most of what is going on here. I've not come across DynamicVariable before, but having looked it up I think I see why you have used it. Please could you explain a bit more what is happening in this line: CurrentLicense.withValue(Full(currentLicense)) {session.processSurroundAndInclude(PageName get, bound)} What/where is PageName get ? It's a RequestVar in LiftSession.scala -- Lift, the simply functional web framework http://liftweb.net Beginning Scala http://www.apress.com/book/view/1430219890 Follow me: http://twitter.com/dpp Git some: http://github.com/dpp --~--~-~--~~~---~--~~ You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to liftweb@googlegroups.com To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/liftweb?hl=en -~--~~~~--~~--~--~---
[Lift] Wiki down?
Hi! Is wiki offline? --~--~-~--~~~---~--~~ 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: 1.1-SNAPSHOT broken in Google App Engine
Hi, On Wed, Aug 26, 2009 at 6:35 AM, David Pollakfeeder.of.the.be...@gmail.com wrote: Atsuhiko-san, Have you seen this note on the Lift list? I have not seen such a note on this list yet and I had not tried 1.1-SNAPSHOT on GAE/J in these days, but today I tried it and have also encountered the reported problem. I'll check the code and think of what we can. Sincerely, -- Atsuhiko Yamanaka JCraft,Inc. 1-14-20 HONCHO AOBA-KU, SENDAI, MIYAGI 980-0014 Japan. Tel +81-22-723-2150 +1-415-578-3454 Skype callto://jcraft/ --~--~-~--~~~---~--~~ 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: Wiki down?
We're transitioning to the Wiki hosted on GitHub. http://wiki.github.com/dpp/liftweb On Aug 25, 6:33 pm, _rogerio_ rogerio.ara...@gmail.com wrote: Hi! Is wiki offline? --~--~-~--~~~---~--~~ 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] Implementing new datatypes into metamapper
Hey guys, i've been successfull with lift so far, now i want to do some more in depth stuff. anyway, i am missing the postgresql cidr/ip datatypes. Since they mostly work like strings i did the following: import _root_.net.liftweb.mapper._ import _root_.net.liftweb.http.{S, FieldError} import _root_.java.sql.{ResultSet, Types} import _root_.java.util.regex._ import _root_.scala.xml.Text object MappedCIDR { val ipv4 = Pattern.compile(^25[0-5]|2[0-4]\\d|[01]\\d{2}|\\d{1,2})(\ \.(25[0-5]|2[0-4]\\d|[01]\\d{2}|\\d{1,2})){3}(/(3[012]|[12]\\d|\\d)$) val ipv6 = Pattern.compile(^\\w*\\:\\w*\\:\\w*$) def valid(ip: String): Boolean = ipv4.matcher(ip).matches || ipv6.matcher(ip).matches def validIPAddr_?(ip: String) = valid(ip) } class MappedCIDR[T:Mapper[T]](owner: T, maxLen: Int) extends MappedString[T](owner, maxLen) { /** * Get the JDBC SQL Type for this field */ def targetSQLType = Types.VARCHAR override def setFilter = notNull _ :: toLower _ :: trim _ :: super.setFilter override def validate = { ( if (MappedCIDR.ipv4.matcher(i_is_!).matches || MappedCIDR.ipv6.matcher(i_is_!).matches()) Nil else List(FieldError(this, Text(S.??(invalid.ip.address ) ::: super.validate } } The question is, how would one go about implementing a type which is not in sql.Types? ;) I found some jdbc driver extensions for that: http://oak.cats.ohiou.edu/~rf358197/jdbc/2/ Patching the current driver is painless, but i am still not sure how to go on. Can anyone gimme some advice at what code i should look which would give me the best example for this? 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 -~--~~~~--~~--~--~---