[Lift] Re: RequestVar copy /clone ?
IMHO you have three options: 1. Use statefull snippet 2. Use SessionVar. 3. User RequestVar. I went for third option. Because I don't need to retain this value between multiple requests. In my code i use something like: object Index { object postidVar extends RequestVar(S.param(postid).map(_.toLong) openOr 0L) def postid: Long = postidVar.is } This gives me global access to RequestVar. Then i use it with something like: /** * Renders post in details. * @param in * @return */ def show(in: NodeSeq): NodeSeq = { Post.find(Index.postid) match { case Full(post) = bind(post,in, title-post.title, text - post.text, date - (new SimpleDateFormat(Const.format) format post.date.get)) case Empty = Text(No such post) case Failure(_,_,_) = S.redirectTo(/failure.html) } } I set it with: if(User.loggedIn_?) SHtml.link(/edit, ()= Index.postidVar(post.id), Text(Edit)) else Text() Or with: SHtml.link(/details.html,()=Index.postidVar(post.id),Text(Read more)) And in another snipped I use it like: def edit(in: NodeSeq): NodeSeq = { var title = var text = var tags = var post = Post.find(Index.postid) def submit() = { if(title==) S.error(Title musn't be empty) else { post.open_!.title(title).text(text).save S.redirectTo(/index) } } post match { case Full(p) = bind(post,in, title - SHtml.text(p.title, parm = title=parm, (size,55)), tags - SHtml.text(, parm = tags=parm), text - SHtml.textarea(p.text, parm = text=parm), submit - SHtml.submit(Save, submit) ) case Empty = S.error(Post to edit not found); S.redirectTo(/ index) } You can check the code here: http://github.com/kukems/lift-blog What i would suggest to change clientBox definition from object currentClient extends RequestVar [Box [Client]] (Empty) to: object currentClient extends RequestVar(S.param(client_id).map(_.toLong) openOr -1L) I assume that you don't have anything in database that match Client.id == -1 Then you can use currentClient as: Client findByKey currentClient.is map inInvoice.client (_) On Mar 9, 7:13 am, hexa hex...@gmail.com wrote: Hi, I have a RequestVar that I send to a snippet which will then do a post... But I would like the RequestVar to persist between the moment it it received in the post snippet and the post itself... The only way I found of doing it right now is like : Source Snippet : object ViewClient extends ViewClient class ViewClient { object currentClient extends RequestVar [Box [Client]] (Empty) bind (... addInvoice - SHtml.link (/invoice/create, () = currentClient (Full (c)), Text (Ajouter Facture))) Destination Post Snippet : def add (inhtml: NodeSeq) : NodeSeq = { val inInvoice = Invoice.create val clientBox = ViewClient.currentClient val client_id = clientBox map (_.id.toLong) def processEntry () { Client.findByKey (client_id openOr 0) map (inInvoice.client (_)) inInvoice.save S.notice (Entre : Description + inInvoice.description + Montant : + inInvoice.amount) } bind (e, inhtml, description - inInvoice.description.toForm, amount - inInvoice.amount.toForm, submit - SHtml.submit (Ajouter Facture, processEntry)) If I try to access the clientBox in processEntry, even with the closure it should generate.. I get an empty box... Is there any way to copy / ref or anything or make a new RequestVar with a copy of the preceding one ? Would have been nice not to be obligated to do the client_id toLong code... And juste do inInvoice.client (client) , inInvoice.save You have to check it because it might be null/empty. Lift can't figure out what to do when there is no value inside the Box. In Java typical idiom is to return null which impose getting NullPointerException at some point OR checking explicitly for null value which you do exactly with openOr method. Thanks a lot hexa -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: More dynamic Lift
But on the other hand it happens not too often. I'm personally very very happy with current productiveness using Lift + Jetty + JRebel. But what happens when Zeroturnaround will turn back to Scala ? It is quite possible that Scala will go mainstream. It might be viable solution then. Simple solution would be putting Menu building just before page rendering in development mode. But i can live perfectly without that as well (using JRebel). On Mar 9, 9:37 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: On Tue, Mar 9, 2010 at 9:33 AM, Timothy Perrett timo...@getintheloop.eu wrote: I'm afraid I agree with Marius... I'm just not sure on the benefit here over JRebel? My main pain point was changes to Sitemap. JRebel doesn't help you here as it's fixed once Lift is booted... /Jeppe -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: RequestVar copy /clone ?
Ok i think I see the bug. It is the magic which i don't understand yet that if you change your client_id from val to var it will be auto promoted into Heap and live out Snippet. Try this out. Change: val client_id = clientBox map (_.id.toLong) To: var client_id = clientBox map (_.id.toLong) On Mar 9, 3:34 pm, hexa hex...@gmail.com wrote: Hi, thanks for the suggestions I like that match {} code.. will try that.. But what you suggest but the post_id is similar to what I'm doing now.. since this id is a long it will be copied by value and I can pass it to multiple requests using a closure... I'll try to clarify a bit : A have a ViewClient snippet and an AddInvoice snippet In the ViewClient I add the action AddInvoice which must be bound to a client.. Now passing the client to the AddInvoice form is ok .. I can send the whole client object to the form snippet using a RequestVar.. which I find kinda neet not having to go trough thoses ids... (maybe i'm wrong thinking that) But the trick is now that i'm in the AddInvoice snipped and that I have my RequestVar... I would like to form a closure on it.. an keep it for the post request so that it gets to ProcesssEntry and I do just : inInvoice.client (client) inInvoice.save As so no ids are involved... I would need to make a new RequestVar for the post submit with a copy of the input RequestVar I got in the AddInvoice from the ViewClient snippet But a SessionVar is out it's way overkill and a statefull snippet might be an idea ... would the RequestVar persist in the statefull snippet? Also I'm having trouble understanding how that scoping is done for the RequestVar if anyone could shed some light on it... like why a closure won't ref it... (I'm new to scala) Thanks hexa -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: More dynamic Lift
I see almost any difference with JRebel On Mar 9, 6:13 pm, David Pollak feeder.of.the.be...@gmail.com wrote: My development cycle has never worked well with JRebel. First, I've got so many machines I do development on (5, 3 of which get wiped each time Ubuntu releases a new version), getting all of those machines set up with JRebel is something of a pain. Further, having JRebel run in some cases is *very bad* (e.g., any compilation takes 10x longer with JRebel). So, when I do use JRebel, it is generally a bad experience for me. This is based on the way I code. First, I use a whole lot of for comprehensions in my code. The problem with for comprehensions is that they create a bunch of anonymous inner classes that are named based on the order they appear in the code. This means that the classes for a given thing change and that leads to incompatible class change issues. Further, I write a lot of code in traits that I mix into lots of different classes. This also leads to less than optimal results in JRebel (more incompatible class change issues.) The JRebel folks and Martin have worked to address the former issue, have not completely eliminated it. There's a further issue... JRebel doesn't work automatically with Lift. Technically, it's costless, but you have to register it with ZeroTurnaround, etc. This means you start using JRebel after you've made a commitment to Lift rather than during the early stages of using Lift. So, based on our recent discussion about onboarding, some discussions Jeppe and I have been having, and my non-JRebel-friendly development style, I thought that there might be a way to address all of these issues at once. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] lift-blog - lift based blogging app
Hi Folks. I've spawned very simple blog app on lift. This is alpha version and code base is not clean (i'm quite new to scala and lift). You can pull it from github: git://github.com/kukems/lift-blog.git And there is even demo ;) http://www.acidbits.org/lift-blog/ I need your assistance in choosing name for project and licence type. I want it open source, but dunno current most fancy licence on the street. I've you want to join and help me improving drop me an email and i'll give you commit access. If you want to use it just pull out from github customize with taste and deploy on your favorite app server. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: lift-blog - lift based blogging app
It is some issue with name based virtual hosting in apache. If i try to connect using ip address it doesn't work. http://87.204.87.110/lift-blog Fortunately its on internet facing host. Try this one: http://gates.itigo.pl:8080/lift-blog On Mar 8, 2:14 pm, Timothy Perrett timo...@getintheloop.eu wrote: http://www.acidbits.org/lift-blog/gives a 404 error? Cheers, Tim On 8 Mar 2010, at 12:51, Lukasz Kuczera wrote: Hi Folks. I've spawned very simple blog app on lift. This is alpha version and code base is not clean (i'm quite new to scala and lift). You can pull it from github: git://github.com/kukems/lift-blog.git And there is even demo ;)http://www.acidbits.org/lift-blog/ I need your assistance in choosing name for project and licence type. I want it open source, but dunno current most fancy licence on the street. I've you want to join and help me improving drop me an email and i'll give you commit access. If you want to use it just pull out from github customize with taste and deploy on your favorite app server. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.com. For more options, visit this group athttp://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] Newbie Q: how to append html on ajaxForm submission
Hi Folks, I've hard time to figure out how to append html snippet after ajaxForm is submitted. I know how to make it in jQuery but i would prefer to have it in one place. My code is: http://pastebin.com/wgAXd2ag I would love to have AppendHtml(afterId: String, body: NodeSeq) method. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: Newbie Q: how to append html on ajaxForm submission
So i've solved it on my own :D Using jQuery in Lift :D Lift is so complex but once you wrap your head around it is so easy :D http://pastebin.com/J5msUQ56 On Mar 5, 9:57 am, Lukasz Kuczera kuk...@gmail.com wrote: Hi Folks, I've hard time to figure out how to append html snippet after ajaxForm is submitted. I know how to make it in jQuery but i would prefer to have it in one place. My code is:http://pastebin.com/wgAXd2ag I would love to have AppendHtml(afterId: String, body: NodeSeq) method. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: Newbie Q: how to append html on ajaxForm submission
Thanks ced, I've used something like: JqId(new-comment) JqAppend(pPosted By: {author}br/{text}/p) But AppendHtml is more eye pleasant :) On Mar 5, 11:04 am, ced docpom...@googlemail.com wrote: There is an AppendHtml object in net.liftweb.http.js.jquery.JqJsCmds that generates a JsCmd. AppendHtml(my-element-id, spanappend me/span) Is this what you're looking for? On 5 Mrz., 09:57, Lukasz Kuczera kuk...@gmail.com wrote: Hi Folks, I've hard time to figure out how to append html snippet after ajaxForm is submitted. I know how to make it in jQuery but i would prefer to have it in one place. My code is:http://pastebin.com/wgAXd2ag I would love to have AppendHtml(afterId: String, body: NodeSeq) method. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: Lift or Scala first?
As i posted in other thread lift is uber complex until you wrap your head around it then its stupid simple. Scala is static so there is not as much magic happening around as in groovy/ruby. But on the other hand if you have any functional background it might be the good option. On Mar 5, 6:19 pm, Mini Naim minin...@gmail.com wrote: Hi guys: I have a simple question, it's necessary to learn Scala first? or i can go with Lift framework, without learn Scala language? Thanks -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] non snapshot version of lift for scala 2.8
Hi Folks. I'm working on lift 2.0-scala280-SNAPSHOT. What is current recommended stable version for scala 2.8 ? -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: non snapshot version of lift for scala 2.8
I'm developing blog app on 280 and so far no problems yet. Only one weird thing i see is that CRUDify shuffles columns, data is misplaced with header in tables, but I didn't have time yet to look at it closer. BTW is there any public blog app available for Lift ? If there is i'm wasting my time i hope not so i could publish it as a give back ;) On Mar 4, 12:32 pm, Jeppe Nejsum Madsen je...@ingolfs.dk wrote: On Thu, Mar 4, 2010 at 12:27 PM, Indrajit Raychaudhuri indraj...@gmail.com wrote: On 04/03/10 3:26 PM, Jeppe Nejsum Madsen wrote: On Thu, Mar 4, 2010 at 10:39 AM, Indrajit Raychaudhuri indraj...@gmail.com wrote: Lukasz, We don't have non-SNAPSHOT version of Lift for scala 2.8 branch yet. You are encouraged to use 2.0-scala280-SNAPSHOT and report any issue that you encounter. Is there a status of the 2.8 branch somewhere on what works and what doesn't? (Ie. are some modules missing, known things that don't work) Or is everything ported and stuff that doesn't work is a defect? The only module missing at the moment is lift-osgi and related ones because it is dependent on 2.8 port of scalamodules. Heiko said one is on its way as an Eclipse project (www.eclipse.org/proposals/scalamodules). The rest are either of: - defects - non-functional because of API change - sub-optimal design - combination of the above (look for the comment FIXME: 280 in the code-base) I would love to get to the 2.8 Eclipse plugin and I've just started a new Lift project where I can accept some bumps along the road, but I've held off until now because I wasn't really sure of the status If you can accept the bumps, you are welcome to give scala 2.8 port a shot. This would be great in fact. Cool! Thanks for the update, I think I'll try it... /Jeppe -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] JRebel not reloading with new snapshot archetype
Hello. I've encountered strange problem. I had stable lift app compiled against 2.7.7 then i've moved to 2.8.1beta, everything worked perfect. Yesterday i've pulled clean project using -DarchetypeVersion=2.0- scala280-SNAPSHOT and after running mvn jetty:run rebel doesn't see changes made by eclipse. First project (converted one) works, jrebel reloads classes as eclipse compiles them. I've managed to get running with mvn scala:cc but it is not desired solution for me. Anyone has idea what is going on ? Cheers Lukasz -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: JRebel not reloading with new snapshot archetype
It seems like pom.xml had wrong version of specs. I'm not shure if it is a bug but had to change artifact id from: specs_2.8.0.Beta1 to: specs_2.8.0.Beta1-RC8 -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: JRebel not reloading with new snapshot archetype
Eclipse was shouting at me that it can't find spec_2.8.0.Beta1 at first glance I didn't see it either. It is ok now. Still jrebel is not reloading those classes. On Feb 8, 11:29 am, Indrajit Raychaudhuri indraj...@gmail.com wrote: Hmm, specs_2.8.0.Beta1 is the appropriate version aligned with Scala 2.8.0Beta1. If you really find the expected behavior with specs_2.8.0.Beta1-RC8 but not with specs_2.8.0.Beta1, we have an interesting behavior at hand. Cheers, Indrajit On 08/02/10 3:41 PM, Lukasz Kuczera wrote: It seems like pom.xml had wrong version of specs. I'm not shure if it is a bug but had to change artifact id from: specs_2.8.0.Beta1 to: specs_2.8.0.Beta1-RC8 -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: Lift and Scala 2.8 Beta1
Works for me. Only code that i had to change was in snippet where new compiler couldn't infer types for functions arguments when using palceholder syntax. Simple project without rocket science. Thanks for release as new eclipse plugin is much much better. On Jan 29, 10:23 am, Francois fan...@gmail.com wrote: Le 29/01/2010 06:04, Indrajit Raychaudhuri a écrit : You can change Lift artifact dependencies version to 2.0-scala280-SNAPSHOT in you application pom and proceed to build as usual. Amazing :) -- Francois ARMANDhttp://fanf42.blogspot.com -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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: HTML table links
This does exactly what I wanted. Thank you, and AttrBindParam is even not mentioned in the Lift book. I found this post usefull: http://www.mail-archive.com/liftweb@googlegroups.com/msg14476.html On Jan 25, 10:30 pm, Naftoli Gugenheim naftoli...@gmail.com wrote: If you want to put a url bound to a function in a custom place like the javascript handler, one option is something like this. def func() { ... } val pageurl = ... // the detail url val url = fmapFunc( (a: List[String]) = {func(); true} )(key = pageurl + ? + key + =_ ) To get the url into the html, use an AttrBindParam IIRC (not sure exact usage offhand). Then in func load the item into a RequestVar, which will be used by the detail page. On Mon, Jan 25, 2010 at 2:20 PM, Lukasz Kuczera kuk...@gmail.com wrote: Could you please point me, I can't find it. Also im using onclick attribute, can i fit link there ? I'm thinking of using some css hacking to get a over whole row but can't remember if it is possible. On Jan 25, 5:04 pm, Adam Warski a...@warski.org wrote: Hello, table cellpadding=7px title=User summary thFirst Name/th thLast Name/th thHours Summary/th thWage/th lift:Users.list tr onmouseover=this.bgColor='#ee'; onmouseout=this.bgColor='#FF'; onclick=window.location ='URL_TO_USER_DETAILS'; tdu:fname //td tdu:lname //td tdu:hours //td tdu:money //td /tr /lift:Users.list /table What I want to achieve is that users clicks on table row and gets redirected to details about selected row (user in this case). I would like to implement this in View First pattern so i thought about replacing 'onclick' attribute inside Users.list method but I don't know the easy way to do this. The naive way would be using regular expressions, but i've got feeling that i'm reinventing wheel here. Please help. There are several ways to do it. I think the easiest one is to bind the view link to a SHtml.link, something like: users.flatMap { user = bind(..., ..., view - link(view.html, () = SelectedUser(user), Text(View user)) } where view.html is a template where you can view the user, SelectedUser is a RequestVar that holds the selection after you've clicked. You will also need to add the view.html to your sitemap. If you want a persistent URL for viewing users, you can add a rewrite rule. The use-case you are writing about is quite well described in the lift book (available in pdf for free), so I would also recommend looking there. -- Adam -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@googlegroups.com. To unsubscribe from this group, send email to liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com . For more options, visit this group at http://groups.google.com/group/liftweb?hl=en. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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] HTML table links
Hi Folks. I'm Lift newbe so please be patient :) I've tried to implement table in master-detail fashion. In template I have something like: table cellpadding=7px title=User summary thFirst Name/th thLast Name/th thHours Summary/th thWage/th lift:Users.list tr onmouseover=this.bgColor='#ee'; onmouseout=this.bgColor='#FF'; onclick=window.location ='URL_TO_USER_DETAILS'; tdu:fname //td tdu:lname //td tdu:hours //td tdu:money //td /tr /lift:Users.list /table What I want to achieve is that users clicks on table row and gets redirected to details about selected row (user in this case). I would like to implement this in View First pattern so i thought about replacing 'onclick' attribute inside Users.list method but I don't know the easy way to do this. The naive way would be using regular expressions, but i've got feeling that i'm reinventing wheel here. Please help. -- You received this message because you are subscribed to the Google Groups Lift group. To post to this group, send email to lift...@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.