Re: [Lift] Re: WebSockets are Coming

2009-12-23 Thread Heiko Seeberger
> > I could start an experimental branch for all this. > Yeah, go for it, man, go for it! Heiko My job: weiglewilczek.com My blog: heikoseeberger.name Follow me: twitter.com/hseeberger OSGi on Scala: scalamodules.org Lift, the simply functional web framework: liftweb.net -- You received this m

[Lift] Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Adam Warski
Hello, I'm just starting with Lift, and there's one thing I can't figure out. I want to modify the ToDo example from the tutorial so that the "Add" button makes an ajax call, adds the element to a list and displays the modified result. The problem is that I don't know how to redraw the list aft

[Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Marius
With SetHtml you just provide the parent element ID and the NodeSeq you want to render as a child of that parent. You're saying you don;t have the NodeSeq Corresponding to the List but I assume you do have the list right? So assume this Ajax function: def myCallback(): JsCmd = { val myList = ...

[Lift] Call lift function from html

2009-12-23 Thread dominikgr
Hallo I won't mix scala code with html code. So first I have a binding bind("hotel", template,"starRating" -> {getStars (elem.hotelInfo.stars)}) and function def getStars(stars : String) : NodeSeq = { if(stars.length >0) { var style = "width: " + (stars.toInt * 10) + "px;"

[Lift] Re: SHtml.link should work like Shtml.submit

2009-12-23 Thread dominikgr
It works fine. Thanks a lot. On 11 Dez., 10:50, Marius wrote: > well if you want to use the approach below you can simply have in your > html: > > >   >      // put your fields here >   > > > In this approach we don't tell lift to generate a form but we wrap the > snippet into a form. Nonethe

[Lift] Re: Call lift function from html

2009-12-23 Thread Marius
No but you can use snippets as attributes (something like): Br's, Marius On Dec 23, 12:10 pm, dominikgr wrote: > Hallo >  I won't mix scala code with html code. So first I have a binding > bind("hotel", template,"starRating" -> {getStars > (elem.hotelInfo.stars)}) > > and function > def getS

Re: [Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Adam Warski
Hello, > With SetHtml you just provide the parent element ID and the NodeSeq > you want to render as a child of that parent. You're saying you don;t > have the NodeSeq Corresponding to the List but I assume you do have > the list right? So assume this Ajax function: > > def myCallback(): JsCmd =

Re: [Lift] Re: The future of lift-core

2009-12-23 Thread David Bernard
Tips : in your project call : mvn dependency:analyze you should see the list of dependencies useless and used throught transitive path and to list directly in your pom.xml (may be in place of lift-core). /davidB On Wed, Dec 23, 2009 at 02:31, Peter Robinett wrote: > Indrajit, your post made me

[Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Marius
On Dec 23, 1:51 pm, Adam Warski wrote: > Hello, > > > With SetHtml you just provide the parent element ID and the NodeSeq > > you want to render as a child of that parent. You're saying you don;t > > have the NodeSeq Corresponding to the List but I assume you do have > > the list right? So assum

[Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Marius
Oh an I hope you're using Lift 1.1 cause RequestVar's scope for Ajax functions is preserved after rendering the page. If not you can just use a SessioVar instead. On Dec 23, 4:06 pm, Marius wrote: > On Dec 23, 1:51 pm, Adam Warski wrote: > > > > > Hello, > > > > With SetHtml you just provide the

Re: [Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Adam Warski
Hello, > object MyMarkupVar extends RequestVar[NodeSeq](NodeSeq.empty) ah, that's much better then my solution. Thanks! :) Maybe you could also write, how to submit a whole form using AJAX? :) So far my attempts are futile. I get an ajax request, but the value of the field isn't bound to the mo

[Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Marius
This thread http://groups.google.com/group/liftweb/browse_thread/thread/9d333465ca18eb15/47cac2543737dcb9?lnk=gst&q=ajax+form#47cac2543737dcb9 I believe discusses the same problem you're seeing. Use a hidden field that binds checkAndSave function. There is an alternative approach that I described i

[Lift] Reserved words in templates/snippets?

2009-12-23 Thread Erkki Lindpere
I couldn't figure out why my snippet was not being called, then renamed my class (it was named Msg) and it started working. Is Lift possibly resolving to another class called Msg? -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, s

Re: [Lift] Reserved words in templates/snippets?

2009-12-23 Thread Ross Mellgren
There is a built in snippet called "Msg" (it's in net.liftweb.builtin.snippet). It is wired into LiftRules.snippetDispatch by default, which I believe will run before automatic snippet resolution via class name. If you want to use a snippet called "Msg", I think you might have to wire it i

[Lift] Re: Reserved words in templates/snippets?

2009-12-23 Thread Marius
Yes lift:Msg is a builtin snippet. We should describe this here: http://wiki.github.com/dpp/liftweb/about-lift-tags Br's, Marius On Dec 23, 6:38 pm, Erkki Lindpere wrote: > I couldn't figure out why my snippet was not being called, then > renamed my class (it was named Msg) and it started workin

Re: [Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread David Pollak
A couple of observations... First, having some XHTML in your Scala code is not a bad thing. When the XHTML declares the meaning (not the layout) of the information, it's my opinion that it's okay. This means that: {list.map(i => {i}} Simply defines an unordered list. It does not declare how to

Re: [Lift] Re: The future of lift-core

2009-12-23 Thread Indrajit Raychaudhuri
Hey Peter, lift-base is just a parent model for lift-common, lift-actor, lift-util and lift-webkit. It's not a real dependency that can be used in a project. Since you are using lift-mapper, just using lift-mapper as dependency should suffice. Rest of the dependencies would be pulled down auto

[Lift] Re: The future of lift-core

2009-12-23 Thread Peter Robinett
Thanks guys, that helps a lot. Peter On Dec 23, 9:05 am, Indrajit Raychaudhuri wrote: > Hey Peter, > > lift-base is just a parent model for lift-common, lift-actor, lift-util > and lift-webkit. It's not a real dependency that can be used in a > project. Since you are using lift-mapper, just usin

[Lift] Foreach-like snippet: am I doing it right?

2009-12-23 Thread Erkki Lindpere
This has probably come up previously, but I couldn't find anything even though I think a couple of days ago I read about something similar: I want to do a snippet that behaves similarly to JSTL-s forEach tag. Not exactly the same, but the idea is that it gets some list of model objects, then goes

Re: [Lift] Foreach-like snippet: am I doing it right?

2009-12-23 Thread Ross Mellgren
S.session.get.processSurroundAndInclude has a couple issues, first is that it seems to be a much larger stick than you need, and the other reason is that you are using "get" (which is for Option, I presume you mean open_!, since S.session is a box) which is not safe -- it will throw NPE in

[Lift] Re: Foreach-like snippet: am I doing it right?

2009-12-23 Thread Erkki Lindpere
Well, I'd prefer to keep different concerns separated. Iterating over that list is not the only case where I render those objects, that's why I want the rendering of these objects to be separated into their own template. But maybe I'll change my mind. Doing it like you suggested is probably faster

Re: [Lift] Re: Foreach-like snippet: am I doing it right?

2009-12-23 Thread Ross Mellgren
Well, if that's the case then you could do it something like this: object MySnippet { /** Function that binds fields of a single ModelObj */ def bindModelObj(ns: NodeSeq)(model: ModelObj) = bind("model", ns, "field1" -> model.field1, "field2" -> model.field2) } class MySnipp

[Lift] Re: Foreach-like snippet: am I doing it right?

2009-12-23 Thread Erkki Lindpere
Thanks! I'll try that. On Dec 23, 8:59 pm, Ross Mellgren wrote: > Well, if that's the case then you could do it something like this: > > object MySnippet { >      /** Function that binds fields of a single ModelObj */ >      def bindModelObj(ns: NodeSeq)(model: ModelObj) = >          bind("model"

[Lift] Re: Foreach-like snippet: am I doing it right?

2009-12-23 Thread Erkki Lindpere
Thanks again for the advice, this was about 25 times faster than what I originally showed! Erkki On Dec 23, 8:59 pm, Ross Mellgren wrote: > Well, if that's the case then you could do it something like this: > > object MySnippet { >      /** Function that binds fields of a single ModelObj */ >  

[Lift] Re: Sitemap - rendering "title" attributes for the links

2009-12-23 Thread Alex Black
Hi Xuefeng, I think will produce 1 tooltip for the entire sitemap, what i'm looking for is a tooltip for each link in the sitemap. On Dec 21, 11:39 pm, Xuefeng Wu wrote: > Sorry I misunderstand you. > > And I do not know how to too. > > Maybe you should use > > instead of > > > > On Tue, Dec 22

Re: [Lift] Re: Foreach-like snippet: am I doing it right?

2009-12-23 Thread Naftoli Gugenheim
Also if you need to do a foreach in the middle of a snippet (say in the previous example there was a header row that is also bound by the snippet), the right side of a binding (the part after the arrow) can be a function from NodeSeq to NodeSeq, so you can nest binds, and make that function do a

[Lift] Re: Problem with LiftFilter in 2.8.0

2009-12-23 Thread Alan M
So the 2.8 port branch(I'm used to subversion lingo) is broken right now? Ouch, the only netbeans plugin for scala that works on the current release of netbeans requires 2.8xx.. Oh and I'm not mixing lift versions in the same webapp, I was mixing in the same container. But now I moved both webap

[Lift] Lift binding: is ChooseTemplate always necessary with nested tags?

2009-12-23 Thread Alex Black
I've got this xhtml in my template: Also known as: with this snippet code: def alsoKnownAs( xhtml: NodeSeq, product: Product): NodeSeq = { def list( xhtml: NodeSeq, product: Product): NodeSeq = { product .alternateLabels .flatMap( l =>

[Lift] Re: Lift binding: is ChooseTemplate always necessary with nested tags?

2009-12-23 Thread Alex Black
I missed a bit of code, probably not relevant, but just in case someone notices the issue: def loserAlsoKnownAs( xhtml: NodeSeq ): NodeSeq = { alsoKnownAs(xhtml, loser) } -- You received this message because you are subscribed to the Google Groups "Lift" group. To post to this group, se

[Lift] Advanced lift binding, parameters?

2009-12-23 Thread Alex Black
I've got some xhtml blocks in one of my templates that are basically identical, and I'd like to avoid the duplication, by either writing the block once in my template and using a snippet to write it out twice (with different values) or put it in its own template. Items First Second

Re: [Lift] Lift binding: is ChooseTemplate always necessary with nested tags?

2009-12-23 Thread Ross Mellgren
bind("alsoKnownAs", in, "list" -> { (ns: NodeSeq) => bind("list", ns, "label" -> ... ) }) -Ross On Dec 23, 2009, at 3:59 PM, Alex Black wrote: > I've got this xhtml in my template: > > > Also known as: > > > > > > > > with this snippet code: > > def alsoKnownAs( xhtml: Nod

Re: [Lift] Advanced lift binding, parameters?

2009-12-23 Thread Ross Mellgren
S.attr gives you attributes of the current snippet calling tag, e.g. class Item extends DispatchSnippet { val dispatch: DispatchIt = { case "points" => points } def points(ns: NodeSeq): NodeSeq = { val points = S.attr("item") match { case Full("first"

[Lift] Recursive bind within the same snippet

2009-12-23 Thread Jim Wise
So, I'm working on a simple image gallery, and I can make a link from an image in the gallery to a page for that image with this: (additional content omitted for clarity). This is simple enough to bind: "imgLink" -> link("/viewImage", () => selected(i.id), ) but this a.) put

[Lift] Re: Lift binding: is ChooseTemplate always necessary with nested tags?

2009-12-23 Thread Alex Black
Slick, thats perfect, thanks. On Dec 23, 4:16 pm, Ross Mellgren wrote: > bind("alsoKnownAs", in, "list" -> { (ns: NodeSeq) => bind("list", ns,   > "label" -> ... ) }) > > -Ross > > On Dec 23, 2009, at 3:59 PM, Alex Black wrote: > > > I've got this xhtml in my template: > > > > >  Also known as:

Re: [Lift] Recursive bind within the same snippet

2009-12-23 Thread Ross Mellgren
Move the bind to an inner function, and call that function recursively, for example: class Image extends DispatchSnippet { val dispatch: DispatchIt = { case "showAll" => showAll } def showAll(ns: NodeSeq): NodeSeq = { def doBinding(ns: NodeSeq): NodeSeq =

[Lift] Re: Advanced lift binding, parameters?

2009-12-23 Thread Alex Black
Thanks Ross, I think I get that.. I'm not seeing the full picture yet, let me show a bit more of my thinking: So, extending my previous example, I'd like to write it like this: Items // Emit the block twice, once for each item (first,second). def firstAndSecond(xhtml: NodeSeq):

Re: [Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Adam Warski
Hello, > This thread > http://groups.google.com/group/liftweb/browse_thread/thread/9d333465ca18eb15/47cac2543737dcb9?lnk=gst&q=ajax+form#47cac2543737dcb9 > I believe discusses the same problem you're seeing. Use a hidden field > that binds checkAndSave function. There is an alternative approach >

Re: [Lift] Recursive bind within the same snippet

2009-12-23 Thread Jim Wise
Ross Mellgren writes: > Move the bind to an inner function, and call that function > recursively, for example: Aha! This gets me to: def doShowAll(in: NodeSeq): NodeSeq = { def doBinding(ns: NodeSeq, i: ImageInfo): NodeSeq = bind("showAll", ns, "name" -> i.name.is,

Re: [Lift] Recursive bind within the same snippet

2009-12-23 Thread Jim Wise
Jim Wise writes: > "category" -> >i.category.obj.open_!.name, // XXX safe unless key rel is corrupt > ? > AttrBindParam("imgUrl", i.url, "src") And, since I'm looking at this code, what's the safe way to do this (i.e. can I avoid the open_!)? --

[Lift] Duplicate divs in tutorial

2009-12-23 Thread Adam Warski
Hello, just a note to the snippets written in the tutorial. The elements of the todo list, when changed (e.g. the "done" checkbox), submit and redraw the list. The code for that is (Listing 17): def list(html: NodeSeq) = { val id = S.attr("all_id").open_! def inner(): NodeSeq = { def

Re: [Lift] Re: Beginner Ajax question - redrawing a page fragment

2009-12-23 Thread Adam Warski
Hello, > A couple of observations... > > First, having some XHTML in your Scala code is not a bad thing. When the > XHTML declares the meaning (not the layout) of the information, it's my > opinion that it's okay. This means that: > {list.map(i => {i}} > Simply defines an unordered list. It

Re: [Lift] Re: Advanced lift binding, parameters?

2009-12-23 Thread Ross Mellgren
So, with nested snippets you have two basic execution model options: 1) the default, the inner snippets get executed after the outer snippet has executed completely. the outer snippet sees as it's content the original content from the template, complete with lift:Item.points tags and so o

Re: [Lift] Recursive bind within the same snippet

2009-12-23 Thread Ross Mellgren
Normally you'd probably do something like i.category.obj.map(_.name).openOr("unknown category!") That is, if I have a category object give me its name, otherwise give me "unknown category!" Also, if you have to collect the result a bunch of possibly-failing computations (like looking up the

Re: [Lift] Recursive bind within the same snippet

2009-12-23 Thread Timothy Perrett
Try: i.category.obj.map(_.name).openOr("Default name") Cheers, Tim On 23 Dec 2009, at 21:45, Jim Wise wrote: > Jim Wise writes: > >> "category" -> >> i.category.obj.open_!.name, // XXX safe unless key rel is corrupt >> ? >> AttrBindParam("imgUrl", i.url, "src") >

[Lift] Re: Duplicate divs in tutorial

2009-12-23 Thread Marius
Why not something like: ... Br's, Marius On Dec 23, 11:46 pm, Adam Warski wrote: > Hello, > > just a note to the snippets written in the tutorial. The elements of the todo > list, when changed (e.g. the "done" checkbox), submit and redraw the list. > The code for that is (Listing 1

Re: [Lift] Recursive bind within the same snippet

2009-12-23 Thread Jim Wise
Oh, I see -- because x.map(foo) where x is a Box returns a Box which is Empty/Error or Full(foo(a.open)) depending on whether x was Full. Thank you! Sent from my iPhone On Dec 23, 2009, at 17:06, Ross Mellgren wrote: > Normally you'd probably do something like > > i.category.obj.map(_.name).

Re: [Lift] Recursive bind within the same snippet

2009-12-23 Thread Timothy Perrett
whatever.map().openOr(..) is the usual idiom, however, you could of course use parameter extraction if that floats your boat / is appropriate. Cheers, Tim On 23 Dec 2009, at 23:11, Jim Wise wrote: > Oh, I see -- because x.map(foo) where x is a Box returns a Box which > is Empty/Error or

Re: [Lift] Re: Problem with LiftFilter in 2.8.0

2009-12-23 Thread David Pollak
On Wed, Dec 23, 2009 at 12:29 PM, Alan M wrote: > So the 2.8 port branch(I'm used to subversion lingo) is broken right > now? No. Until Scala 2.8. RC6, the Scala compiler had problems compiling Lift code. We have been actively working with EPFL to make sure Lift and Scala 2.8 together and EPF

[Lift] Re: Advanced lift binding, parameters?

2009-12-23 Thread Alex Black
Hi Ross, I am learning more about Lift every day :) Reflecting that last point back to you, if I make it just one snippet call, then that snippet call can pass parameters to inner snippet functions, e.g. first or second. So, that works, but I as you mentioned, I think that snippet will get comple

Re: [Lift] Re: Advanced lift binding, parameters?

2009-12-23 Thread Ross Mellgren
I guess I could see something that keeps track of which item to show and advances it each time, but I think it's still a good idea to pass the item explicitly down to subsidiary "snippets". You can still break up each of the sub snippets, the only difference is you call them without the lift: pr

Re: [Lift] Re: How do I go about implementing my own auth?

2009-12-23 Thread Xuefeng Wu
Could SiteMap authorize the editable text? I use swappable some where and do not know how to authorize it. On Tue, Dec 8, 2009 at 5:38 AM, Marius wrote: > I'm not really sure why you're saying that SiteMap is out of the > question. Note that SiteMap does NOT equate with the Menu. You can use >

Re: [Lift] re: trying to get minimum needed for unit test to work using LIFT 1.1 and JPA

2009-12-23 Thread Derek Chen-Becker
This line is troubling: [PersistenceUnit: jpaweb] Unable to build EntityManagerFactory But I'm not sure why that would be happening and not throwing some sort of exception or logging. I'm not going to be around much over the holidays, but I can definitely help next week if you're still running in

[Lift] findAll and inner/outer joins

2009-12-23 Thread Dmitry Olyenyov
Hi! Help me, please, with example of inner and outer relations in findAll query. Is it possible to do without manual BySQL()? I want to do following select: select * from payment_order o join client c on o.client_id = c.id where c.type = 'xxx' => PaymentOrder.findAll(...) I had a lot of goog