[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 googling and didn't found anything...

--

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.




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 into this issue.

Derek

On Fri, Dec 18, 2009 at 12:06 AM, James Black wrote:

> I am trying to test that my entities are working properly, but I get this
> at the end of the surefire output for the test:
> 1634 [main] INFO org.hibernate.cfg.annotations.CollectionBinder - Mapping
> collection: jblack.resumeapp.lift.model.Author.books -> Book
> 1639 [main] INFO org.hibernate.cfg.AnnotationConfiguration - Hibernate
> Validator not found: ignoring
> 1739 [main] INFO
> org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to
> find org.hibernate.search.event.FullTextIndexEventListener on the classpath.
> Hibernate Search is not enabled.
> [PersistenceUnit: jpaweb] Unable to build EntityManagerFactory
>
> I only have defined my classes in jblack.resumeapp.lift.model and created
> my unit test.
>
> The EntityManagerFactory seems to process my models properly.
>
>   I haven't done anything with the snippets, so there are no RequestVar
> implementations for my new models.
>
>   I had created the jpa sample so all I did was add my new classes there.
>
>   Do I need to finish the steps in chapter 10 of the lift book to get my
> unit tests to pass at all?
>
> In an unchanged jpa sample I am missing the next lines, and I am not
> certain what must be done to resolve this, as the driver information isn't
> being processed at all.
>
> I use 'mvn clean install' to run my tests from the top level of my project,
> but if I do 'cd spa' then 'mvn install' I get the same results.
> 1805 [main] INFO
> org.hibernate.cfg.search.HibernateSearchEventListenerRegister - Unable to
> find org.hibernate.search.event.FullTextIndexEventListener on the classpath.
> Hibernate Search is not enabled.
> 1977 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider -
> Using Hibernate built-in connection pool (not for production use!)
> 1977 [main] INFO org.hibernate.connection.DriverManagerConnectionProvider -
> Hibernate connection pool size: 20
>
>
> I am trying to get my test working so I can put back in my @OneToOne,
> @OneToMany and related columns and @PostLoad and related annotations, as I
> had another error when using these, so I have commented them out until I get
> the test working so far.
>
> Thank you.
>
> --
> 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.
>

--

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.




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
> SiteMap to define navigation rules, security semantics, etc. SiteMap
> is much more then just a menu.
>
> But at the end of the day it's your choice.
>
> Br's,
> Marius
>
> On Dec 7, 11:32 pm, DMB  wrote:
> > SiteMap is out of the question. I don't need it at all on my site, by
> > design.
> > I like the way this is done in RoR: you can basically say:
> >
> > before_filter :authorize, :except => :login
> >
> > And it will call "authorize" for all top level methods in the
> > controller class except "login". Not that any of this is applicable in
> > Lift, but I like this very simple, declarative approach. The current
> > auth infrastructure in Lift requires quite a bit of head scratching
> > the second you try to do something "custom".
> >
> > On Dec 7, 11:25 am, Timothy Perrett  wrote:
> >
> > > Ok, lets step back... I really, really wouldnt use the built in auth
> stuff for forms... its sole purpose in life (and lift!) is for basic auth as
> per the HTTP RFCs. If you want basic auth, then thats fine, but i think the
> way you are subclassing HttpAuthentication is wrong for purpose.
> >
> > > If you want login, do one of two things:
> >
> > > - use SiteMap (IMHO, this is the most appropriate route)
> > > - create a custom rewrite / dispatcher combo
> >
> > > You could look at MegaProtoUser, but personally, i'm not a huge fan of
> that approach and prefer to craft my own. That being said, a lot of people
> use it and it saves a lot of time.
> >
> > > Cheers, Tim
> >
> > > On 7 Dec 2009, at 14:14, Marius wrote:
> >
> > > > On Dec 7, 1:09 pm, DMB  wrote:
> > > >> Basically here's what I want to accomplish:
> > > >> 1. I want the user to login through a simple form on /index.html -
> > > >> this is the only unprotected page on the site. User does not have a
> > > >> user name, the only field is a password.
> > > >> 2. I want to store the user role (along with some other state data)
> in
> > > >> the user session
> > > >> 3. If user tries to access any page other than index.html, I want to
> > > >> redirect to /index.html
> >
> > > >> After stumbling for a while due to scarcity of documentation, I have
> > > >> done the following:
> >
> > > >> In Boot.scala:
> >
> > > >> LiftRules.httpAuthProtectedResource.prepend {
> > > >> case ParsePath("index" :: Nil, "html", true, false) =>
> > > >> Empty
> > > >> case _ => Full(AuthRole("admin"))
> > > >> }
> >
> > > >> LiftRules.authentication = SessionAuthentication()
> >
> > > >> InSessionAuthentication.scala:
> >
> > > >> case class SessionAuthentication extends HttpAuthentication {
> >
> > > >> def verified_? = { case(req) => {
> > > >> // TODO: Prefetch from DB here
> > > >> true
> > > >> }
> > > >> }
> >
> > > >> }
> >
> > > >> It is my understanding that this should not ask for auth at all. In
> > > >> reality, it doesn't ask for auth on /index.html, but DOES ask for
> > > >> Basic auth (through a browser popup) on any other page.
> >
> > > >> What am I doing wrong, and how do I make it right?
> >
> > > > Your are seeing the browser's credentials popup because of :
> >
> > > >  def unauthorizedResponse: UnauthorizedResponse =
> UnauthorizedResponse
> > > > (realm)
> >
> > > > from HttpAuthentication trait. You can override this and subclass
> > > > UnauthorizedResponse with your own LiftResponse if you want other
> type
> > > > of response than 401. You can also protect your resources using
> > > > HttpAuthProtected LocParam that you can use when you specify your
> > > > SiteMap in the Loc construction.
> >
> > > > This is one approach.
> >
> > > > Another one, probably more suitable for login forms, is to look into
> > > > Mapper support for that (I think it's called MetaMegaProtoUser ? )
> >
> > > > --
> >
> > > > 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.
>
>
>


-- 
Scala中文社区:  http://groups.google.com/group/scalacn

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this gro

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: prefix. 
This is analogous to composing functions.

Maybe something like this? 

object MySnippet {
object nextItems extends RequestVar[Iterator[ModelObject]](calcNextItems)

def nextItem: Box[ModelObject] = {
val it = nextItems.is
if (it.hasNext) Full(it.next) else Empty
}

private def calcNextItems: List[ModelObject] =
for (startIndex <- S.attr("index").flatMap(asInt).openOr 0) 
yield ModelObject.findAll(StartAt(startIndex), MaxRows(2)).elements
}

class MySnippet extends DispatchSnippet {
import MySnippet._

val dispatch: DispatchIt = {
case "displayNext" => displayNextItem
}

def displayNext(ns: NodeSeq): NodeSeq) =
nextItem.map(renderItem(ns) _).openOr(NodeSeq.Empty)

def renderItem(item: ModelObject)(ns: NodeSeq): NodeSeq =
bind("item", ns, "which" -> item.title,
 "points" -> renderPointsOf(item) _,
 // other "sub" snippet which need a current item here
 "picture" -> renderPictureOf(item) _)

def renderPointsOf(item: ModelObject)(ns: NodeSeq): NodeSeq =
item.points.flatMap(point => bind("point", ns, "name" -> point.name))

def renderPictureOf(item: ModelObject)(ns: NodeSeq): NodeSeq = 

}

And template item-index-2up.html:

Items









templates-hidden/standard-item-template.html:










I fear I'm not quite understanding what you're looking for, though.

-Ross


On Dec 23, 2009, at 9:43 PM, Alex Black wrote:

> 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
> complex.  You then pointed out it can be broken into sub snippet
> calls, which helps, but I still feel like we'd have this big complex
> snippet call that is tightly coupled to the big complex xhtml block.
> E.g. it'd be like doing an entire page in one snippet call instead of
> lots of little ones.
> 
> Btw, the 'blocks' I keep referring to are product (camera)
> specifications, so its like we're displaying two products on one page.
> 
> I had an idea, could the first snippet set a requestVar for the
> current item, then the other snippet calls read that? e.g.
> 
> Items
> 
> 
> 
> 
>  
>
>  
> 
> 
> 
> 
> // Emit the block twice, once for each item (first,second).
> def firstAndSecond(xhtml: NodeSeq): NodeSeq = {
>  List(first,second).flatMap( item => renderItem(xhtml, item) )
> }
> 
> def renderItem( xhtml: NodeSeq, item: Item): NodeSeq = {
>  _currentItem(item)
>   // do stuff
> }
> 
> def points( xhtml: NodeSeq ): NodeSeq = {
>   // do stuff based on _currentItem.is
> }
> 
> - Alex
> 
> On Dec 23, 5:05 pm, Ross Mellgren  wrote:
>> 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 on.
>>2) when eager_eval="true" is specified on the outer snippet, the  
>> inner snippets get executed completely before the outer snippet gets  
>> executed. the outer snippet sees the _result_ of processing the  
>> children from the template, so it sees whatever the lift:Item.points  
>> snippet gives back.
>> 
>> So, this means that fundamentally you couldn't tell the inner snippet  
>> which is the current one, without rewriting the call to the inner  
>> snippet (e.g. find the  tag and write in an  
>> attribute -- this seems like a grody hack)
>> 
>> If you really want an inner snippet running _during_ the processing of  
>> the outer snippet, I think you need to do that  
>> processSurroundAndInclude thing in the outer snippet code.
>> 
>> If you're not tied to the inner snippet, then omit it, like this:
>> 
>> class Item extends DispatchSnippet {
>>  val dispatch: DispatchIt = {
>>  case "firstAndSecond" => firstAndSecond
>>  }
>> 
>>  def firstAndSecond(ns: NodeSeq): NodeSeq =
>>  List(("first", firstSeqOfThings), ("second",  
>> secondSeqOfThings)).flatMap {
>>  case (label, items) =>
>>  bind("item", ns,
>>   "which" -> label,
>>   "points" -> { (ns: NodeSeq) => items.flatMap  
>> { item =>
>>   bind("point", ns, "name" -> item.name)
>>   })
>>  }
>> 
>> }
>> 
>> And the template would be:
>> 
>> Items
>> 
>> 
>>

[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
complex.  You then pointed out it can be broken into sub snippet
calls, which helps, but I still feel like we'd have this big complex
snippet call that is tightly coupled to the big complex xhtml block.
E.g. it'd be like doing an entire page in one snippet call instead of
lots of little ones.

Btw, the 'blocks' I keep referring to are product (camera)
specifications, so its like we're displaying two products on one page.

I had an idea, could the first snippet set a requestVar for the
current item, then the other snippet calls read that? e.g.

Items




  

  




// Emit the block twice, once for each item (first,second).
def firstAndSecond(xhtml: NodeSeq): NodeSeq = {
  List(first,second).flatMap( item => renderItem(xhtml, item) )
}

def renderItem( xhtml: NodeSeq, item: Item): NodeSeq = {
  _currentItem(item)
   // do stuff
}

def points( xhtml: NodeSeq ): NodeSeq = {
   // do stuff based on _currentItem.is
}

- Alex

On Dec 23, 5:05 pm, Ross Mellgren  wrote:
> 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 on.
>    2) when eager_eval="true" is specified on the outer snippet, the  
> inner snippets get executed completely before the outer snippet gets  
> executed. the outer snippet sees the _result_ of processing the  
> children from the template, so it sees whatever the lift:Item.points  
> snippet gives back.
>
> So, this means that fundamentally you couldn't tell the inner snippet  
> which is the current one, without rewriting the call to the inner  
> snippet (e.g. find the  tag and write in an  
> attribute -- this seems like a grody hack)
>
> If you really want an inner snippet running _during_ the processing of  
> the outer snippet, I think you need to do that  
> processSurroundAndInclude thing in the outer snippet code.
>
> If you're not tied to the inner snippet, then omit it, like this:
>
> class Item extends DispatchSnippet {
>      val dispatch: DispatchIt = {
>          case "firstAndSecond" => firstAndSecond
>      }
>
>      def firstAndSecond(ns: NodeSeq): NodeSeq =
>          List(("first", firstSeqOfThings), ("second",  
> secondSeqOfThings)).flatMap {
>              case (label, items) =>
>                  bind("item", ns,
>                       "which" -> label,
>                       "points" -> { (ns: NodeSeq) => items.flatMap  
> { item =>
>                           bind("point", ns, "name" -> item.name)
>                       })
>          }
>
> }
>
> And the template would be:
>
> Items
>
> 
>      
>      
>          
>              
>          
>      
>      
> 
>
> If you're concerned about embedding so much code in the snippet (which  
> seems to be why you want to break into multiple snippets?) then just  
> break them out into separate functions, like I showed you in the  
> foreach example.
>
> I think it helps to remember that snippets are really just XML -> XML  
> functions, and there's little special about them other than that they  
> can be named in templates. You can always call snippets from other  
> snippets directly (e.g. (new MySnippet).thatSnippet(nodes)), though if  
> you use any stateful stuff in those snippets that depends on the  
> current expansion point (e.g. S.attr) then you'd need to break the  
> snippet into two pieces, e.g.
>
> class MySnippet extends DispatchSnippet {
>      val dispatch: DispatchIt = {
>          case "foobar" => foobar
>      }
>
>      def foobar(ns: NodeSeq): NodeSeq = {
>          S.attr("itemId").map(lookupItemById _) match {
>              case Full(item) => foobar(item)(ns)
>              case _ => error("could not find item -- itemId attribute  
> not given or invalid")
>          }
>      }
>
>      def foobar(item: ItemModel)(ns: NodeSeq): NodeSeq =
>          bind(...)
>
> }
>
> Now if you're calling from template, you say  itemId="1234">..., but if you're in some other  
> snippet you say MySnippet.foobar(theItem)(...)
>
> Hope that helps,
> -Ross
>
> On Dec 23, 2009, at 4:32 PM, Alex Black wrote:
>
> > 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): NodeSeq = {
> >  List(first,second).flatMap( item => renderItem(xhtml, item) )
> > }
>
> > How then do I im

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 EPFL has been very responsive.

I am not usually an RTFM kinda guy, but in this case, you should spend just
a few minutes reviewing the Lift mailing list to understand what's going
on?  Why?  How often do you see a conversation between me and Martin
Odersky?  When you see a conversation, which we were having just yesterday
about the 2.8/Lift issue, between us, you can bet that it worth reading.
So, go back and read it.


> Ouch, the only netbeans plugin for scala that works on the
> current release of netbeans requires 2.8xx..
>

Please refer to my previous email.  And just so you know, "gee, I want to
use the latest and greatest NetBeans plugin even though there are plenty of
other Scala IDE environments," is not a compelling reason.

David


>
> Oh and I'm not mixing lift versions in the same webapp, I was mixing
> in the same container.  But now I moved both webapps to the 2.8.0
> port.
>
> I guess I should have just hung back on netbeans, hindsight 20/20 and
> all, ugh..
>
> Alan
>
> On Dec 22, 8:03 pm, Randinn  wrote:
> > This is not the first time this has cropped up, you may have to sticky
> > warning not to use 2.8 with Lift for the moment.
> >
> > On Dec 23, 2:55 pm, David Pollak 
> > wrote:
> >
> >
> >
> > > Lift *DOES NOT* work on Scala 2.8 Beta1 RC4 & 5.  Do not even try it.
>  We
> > > are currently working with EPFL to resolve these issues.
> >
> > > Lift 1.1-M8 and Lift 1.1-SNAPSHOT only work with Scala 2.7.7.  That is
> the
> > > *only* version of Scala that Lift 1.1-M8 and SNAPSHOT work with.  If
> you
> > > have any other version of Scala specified in your pom.xml file, it will
> not
> > > work.
> >
> > > Do not try to mix different versions of Lift in the same web app.  The
> class
> > > loader will not know which versions of the Lift library go with
> different
> > > Servlets.
> >
> > > Once you get your pom.xml file set up with Scala 2.7.7, then you must
> do a
> > > "mvn -U clean install" before doing an mvn jetty:run
> >
> > > On Tue, Dec 22, 2009 at 7:39 PM, Alan M 
> wrote:
> > > > Update:
> >
> > > > I updated the other servlet to scala 2.8 and lift 1.1 snapshot (much
> > > > easier than I thought, I must be getting used to it) and I checked
> the
> > > > libs for both webapps and the commons lib directory.. no conflicting
> > > > versions of scala or lift jars.. I'm on Tomcat 6 btw..  Not sure
> where
> > > > to look next..
> >
> > > > Alan
> >
> > > > On Dec 22, 7:13 pm, Ross Mellgren  wrote:
> > > > > Where do you have the scala library jars? If you haven't taken
> pains to
> > > > ensure that you have two entirely separate scala JARs (2.7.3 and 2.8)
> in two
> > > > separate classloaders I could believe that you'll get all kinds of
> problems
> > > > like this. You might be better served using two separate tomcat
> instances
> > > > and some kind of reverse proxy like nginx to ensure they remain
> entirely
> > > > separated.
> >
> > > > > -Ross
> >
> > > > > On Dec 22, 2009, at 10:07 PM, Alan M wrote:
> >
> > > > > > I get this message when it tries to initialize the LiftFilter..
> >
> > > > > > Dec 22, 2009 6:53:40 PM org.apache.catalina.core.StandardContext
> > > > > > filterStart
> > > > > > SEVERE: Exception starting filter LiftFilter
> > > > > > java.lang.NoSuchMethodError:
> scala.collection.SeqLike.projection()
> > > > > > Ljava/lang/Object;
> > > > > >at
> net.liftweb.util.ListHelpers$class.first(ListHelpers.scala:
> > > > > > 53)
> > > > > >at net.liftweb.util.Helpers$.first(Helpers.scala:32)
> > > > > >at net.liftweb.util.LogBoot$.findTheFile$1(Log.scala:117)
> > > > > >at net.liftweb.util.LogBoot$._log4JSetup(Log.scala:119)
> > > > > >at net.liftweb.util.LogBoot$$anonfun$1.apply(Log.scala:97)
> > > > > >at net.liftweb.util.LogBoot$$anonfun$1.apply(Log.scala:97)
> > > > > >at net.liftweb.util.LogBoot$.checkConfig(Log.scala:95)
> > > > > >at
> net.liftweb.util.LogBoot$.net$liftweb$util$LogBoot$$_logger
> > > > > > (Log.scala:141)
> > > > > >at
> net.liftweb.util.LogBoot$$anonfun$2.apply(Log.scala:143)
> > > > > >at
> net.liftweb.util.LogBoot$$anonfun$2.apply(Log.scala:143)
> > > > > >at net.liftweb.util.Log$.rootLogger(Log.scala:27)
> > > > > >at net.liftweb.util.Log$.error(Log.scala:43)
> > > > > >at net.liftweb.http.provider.HTTPProvider$class.bootLift
> > > > > > (HTTPProvider.scala:80)
> > > > > >at
> net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:524)
> > > > > >at net.liftweb.http.provider.servlet.ServletFilterProvider
> > > > > > $class.init(ServletFilterProvider.scala:23)
> > > > > >at net.liftweb.http.LiftFilter.init(LiftServlet.scala:

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 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).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 category can fail) then remember
>> that the for comprehension is your friend.
>> 
>> -Ross
>> 
>> On Dec 23, 2009, at 4:45 PM, Jim Wise wrote:
>> 
>>> 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_!)?
>>> 
>>> -- 
>>>   Jim Wise
>>>   jw...@draga.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 
>> .
>> 
> 
> --
> 
> 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.
> 
> 
> 

--

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.




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).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 category can fail) then remember
> that the for comprehension is your friend.
>
> -Ross
>
> On Dec 23, 2009, at 4:45 PM, Jim Wise wrote:
>
>> 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_!)?
>>
>> -- 
>>Jim Wise
>>jw...@draga.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 
> .
>

--

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: 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 17):
>
> def list(html: NodeSeq) = {
>  val id = S.attr("all_id").open_!
>
>  def inner(): NodeSeq = {
>    def reDraw() = SetHtml(id, inner())
>
>    bind("todo", html,
>       "exclude" ->
>         ajaxCheckbox(QueryNotDone, v => {QueryNotDone(v); reDraw}),
>       "list" -> doList(reDraw) _)
>  }
>
>  inner()
>
> }
>
> And the corresponding template:
>
> 
>  
>    
>  
> 
>
> As SetHtml sets the children of the element with the specified id, after one 
> change of the checkbox and one ajax call, there will be a  id="all_todos"> inside the original  (as we set the 
> children of the original element to be the nodes passed to the snippet). So 
> you end up with:
>
> 
>    
>    
>      
>    
>  
> 
>
> Subsequent calls don't produce any more divs, as the children of the first 
> div with id "all_todos" get replaced. However, I think it's not too "clean" 
> to produce markup like that.
> The solution I think would be to (somehow) strip the outer div of the html 
> NodeSeq and use that in the ajax reDraw method, instead of capturing the 
> original html with a closure.
> But probably Lift gurus have a better solution :).
>
> --
> 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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




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")
> 
> And, since I'm looking at this code, what's the safe way to do this
> (i.e. can I avoid the open_!)?

--

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.




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 category can fail) then remember  
that the for comprehension is your friend.

-Ross

On Dec 23, 2009, at 4:45 PM, Jim Wise wrote:

> 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_!)?
>
> -- 
>   Jim Wise
>   jw...@draga.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.




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 on.
   2) when eager_eval="true" is specified on the outer snippet, the  
inner snippets get executed completely before the outer snippet gets  
executed. the outer snippet sees the _result_ of processing the  
children from the template, so it sees whatever the lift:Item.points  
snippet gives back.

So, this means that fundamentally you couldn't tell the inner snippet  
which is the current one, without rewriting the call to the inner  
snippet (e.g. find the  tag and write in an  
attribute -- this seems like a grody hack)

If you really want an inner snippet running _during_ the processing of  
the outer snippet, I think you need to do that  
processSurroundAndInclude thing in the outer snippet code.

If you're not tied to the inner snippet, then omit it, like this:

class Item extends DispatchSnippet {
 val dispatch: DispatchIt = {
 case "firstAndSecond" => firstAndSecond
 }

 def firstAndSecond(ns: NodeSeq): NodeSeq =
 List(("first", firstSeqOfThings), ("second",  
secondSeqOfThings)).flatMap {
 case (label, items) =>
 bind("item", ns,
  "which" -> label,
  "points" -> { (ns: NodeSeq) => items.flatMap  
{ item =>
  bind("point", ns, "name" -> item.name)
  })
 }
}

And the template would be:

Items


 
 
 
 
 
 
 


If you're concerned about embedding so much code in the snippet (which  
seems to be why you want to break into multiple snippets?) then just  
break them out into separate functions, like I showed you in the  
foreach example.

I think it helps to remember that snippets are really just XML -> XML  
functions, and there's little special about them other than that they  
can be named in templates. You can always call snippets from other  
snippets directly (e.g. (new MySnippet).thatSnippet(nodes)), though if  
you use any stateful stuff in those snippets that depends on the  
current expansion point (e.g. S.attr) then you'd need to break the  
snippet into two pieces, e.g.

class MySnippet extends DispatchSnippet {
 val dispatch: DispatchIt = {
 case "foobar" => foobar
 }

 def foobar(ns: NodeSeq): NodeSeq = {
 S.attr("itemId").map(lookupItemById _) match {
 case Full(item) => foobar(item)(ns)
 case _ => error("could not find item -- itemId attribute  
not given or invalid")
 }
 }

 def foobar(item: ItemModel)(ns: NodeSeq): NodeSeq =
 bind(...)
}

Now if you're calling from template, you say ..., but if you're in some other  
snippet you say MySnippet.foobar(theItem)(...)

Hope that helps,
-Ross



On Dec 23, 2009, at 4:32 PM, Alex Black wrote:

> 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): NodeSeq = {
>  List(first,second).flatMap( item => renderItem(xhtml, item) )
> }
>
> How then do I implement Item.picture, Item.points to know *which* item
> is currently being rendered?
>
> thx
>
> - Alex
>
>
>
>
>
>
> On Dec 23, 4:18 pm, Ross Mellgren  wrote:
>> 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") => loadFirstListOfPoints()
>>  case Full("second") => loadSecondListOfPoints()
>>  case _ => error("missing item attribute or has incorrect
>> value")
>>  }
>>
>>  bind(...)
>>  }
>>
>> }
>>
>> -Ross
>>
>> On Dec 23, 2009, at 4:07 PM, Alex Black wrote:
>>
>>> 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
>>> 
>>>  
>>>
>>>  
>>> 
>>> 
>>
>>> My question is: If I write this block once, and surround it in a
>>> snippet which emits it twice, how can the snippet parameterize the
>>> nested snippet calls?
>>
>>> I realize I could bind the entire block with one snippet call, but
>>> because my real blocks are big and complex I'd like to keep the many

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 does not declare how to lay out that 
> list.  The layout should be controlled by CSS.
True, xhtml can also be considered as "logic". You got me convinced ;).

>   TemplateFinder.findAnyTemplate(List("snippets-hidden", "userList")) 
> openOr NodeSeq.Empty)
Worked great; lots of Lift API to explore still :).

If you don't mind, I'll put the results of this thread in a 
"tutorial-ajax-followup" wiki page? I think quite a lot of people may want to 
do something similar.

-- 
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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[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 reDraw() = SetHtml(id, inner()) 
 
   bind("todo", html, 
  "exclude" -> 
ajaxCheckbox(QueryNotDone, v => {QueryNotDone(v); reDraw}), 
  "list" -> doList(reDraw) _) 
 } 
 
 inner() 
}

And the corresponding template:

 
  
   
  


As SetHtml sets the children of the element with the specified id, after one 
change of the checkbox and one ajax call, there will be a  
inside the original  (as we set the children of the 
original element to be the nodes passed to the snippet). So you end up with:

 
   

 

  


Subsequent calls don't produce any more divs, as the children of the first div 
with id "all_todos" get replaced. However, I think it's not too "clean" to 
produce markup like that.
The solution I think would be to (somehow) strip the outer div of the html 
NodeSeq and use that in the ajax reDraw method, instead of capturing the 
original html with a closure.
But probably Lift gurus have a better solution :).

--
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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




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_!)?

-- 
Jim Wise
jw...@draga.com


pgp1ptDq5r8qk.pgp
Description: PGP signature


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,
   "link" ->
 {n: NodeSeq => SHtml.link("/viewImage", () => selected(i.id),
 doBinding(n, i))},
   "category" -> 
 i.category.obj.open_!.name,  // XXX safe unless key rel is corrupt 
?
   AttrBindParam("imgUrl", i.url, "src")
 )

ImageInfo.findAll(
By(ImageInfo.category, category),
OrderBy(ImageInfo.name, Ascending)
  ).flatMap({i => doBinding(in, i)})
  }

which does exactly what I need!

Thanks much,
-- 
Jim Wise
jw...@draga.com


pgpUZxCXm2kPS.pgp
Description: PGP signature


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
> that I described in the thread I paste.

This worked, thanks! :)

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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[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): NodeSeq = {
  List(first,second).flatMap( item => renderItem(xhtml, item) )
}

How then do I implement Item.picture, Item.points to know *which* item
is currently being rendered?

thx

- Alex






On Dec 23, 4:18 pm, Ross Mellgren  wrote:
> 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") => loadFirstListOfPoints()
>              case Full("second") => loadSecondListOfPoints()
>              case _ => error("missing item attribute or has incorrect  
> value")
>          }
>
>          bind(...)
>      }
>
> }
>
> -Ross
>
> On Dec 23, 2009, at 4:07 PM, Alex Black wrote:
>
> > 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
> > 
> >  
> >    
> >  
> > 
> > 
>
> > My question is: If I write this block once, and surround it in a
> > snippet which emits it twice, how can the snippet parameterize the
> > nested snippet calls?
>
> > I realize I could bind the entire block with one snippet call, but
> > because my real blocks are big and complex I'd like to keep the many
> > snippet calls per block.
>
> > So, more specifically, how can i write  and
> >  more like this:  > item="@curItem">
>
> > thx
>
> > - Alex
>
> > --
>
> > 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.




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 =
 bind("showAll", ns,
  "link" -> { (ns: NodeSeq) =>
  SHtml.link("/viewImage", () => selected(i.id),  
,
 doBinding(ns))
  })
 doBinding(ns)
 }
}


-Ross


On Dec 23, 2009, at 4:20 PM, Jim Wise wrote:

>
> 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.) puts a tiny bit of content in the snippet (what if
> different pages want different class attributes on the img tag?), and
> b.) isn't customizable -- if I want another link from the image's  
> name,
> I need another bindpoint, etc.
>
>
> So, with some playing around, I can get a little more general with
>
>  
>
>  some random html
>
>  
>
> bound via:
>
>  "link" ->
>{n: NodeSeq => link("/viewImage", () => selected(i.id), n)}
>
> or:
>
>  "link" -> link("/viewImage", () => selected(i.id),
>  chooseTemplate("showAll", "link", in)),
>
> this works well enough as far as it goes (the latter is a little  
> worse,
> IIUC as it involves more rescanning of the html).
>
>
> But what I would like to do is this:
>
>  
>
>  
>
>  
>
> and neither of the previous two BindParams work, yielding:
>
>XML Parsing Error: prefix not bound to a namespace
>Location: http://www.draga.com:9080/viewImages
>Line Number 135, Column 12:
>   
>
> since the content is not re-substituted.
>
> So far, the only way I've found to do this is with a second call to
> bind, repeating the list of BindParams:
>
>  "link" ->// XXX XXX XXX ugly respecifaction of bind
> {n: NodeSeq => link("/viewImage", () => selected(i.id),
>   bind("showAll", n,
>"name" -> i.name.is,
>AttrBindParam("imgUrl", i.url, "src")
>   ))},
>
> Is there a cleaner way to do this -- to specify that I want bind  
> points
> of this snippet to be evaluated even if they appear within the XML of
> other bind points?  I don't want or need true recursive evaluation --
> just to bind all of the bind points which were visible when the xhtml
> was first parsed.
>
> Thoughts?  This is with 1.1-M8, though I don't think it makes a
> difference...
> -- 
>   Jim Wise
>   jw...@draga.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: 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:
> >  
> >    
> >      
> >    
> >  
> > 
>
> > with this snippet code:
>
> > def alsoKnownAs( xhtml: NodeSeq, product: Product): NodeSeq =  {
> >    def list( xhtml: NodeSeq, product: Product): NodeSeq = {
> >      product
> >        .alternateLabels
> >        .flatMap( l =>
> >          bind("list", xhtml,
> >                "label" -> l
> >          )
> >        )
> >    }
>
> >    product.alternateLabels match {
> >      // Remove the entire block (including title if there are no
> > alternate labels)
> >      case Nil => Nil
> >      case _ => bind("alsoKnownAs", xhtml, "list" -> list
> > (chooseTemplate("alsoKnownAs","list", xhtml), product))
> >    }
> >  }
>
> > This works well:
> > - The entire XHTML is removed if there are no alternateLabels
> > - If there are alternateLabels, the "Also known as:" text is not
> > repeated, just the LI elements in the list
>
> > However, in my bind call:
>
> >      case _ => bind("alsoKnownAs", xhtml, "list" -> list
> > (chooseTemplate("alsoKnownAs","list", xhtml), product))
>
> > I specified alsoKnownAs:list twice, it feels a bit redundant... The
> > intent of the code is: find the thing called alsoKnownAs:list, grab
> > the xhtml below it, pass it into the list function, and replace its
> > value with the output of list.
>
> > Is there some trick I'm missing here to avoid specifying things twice?
>
> > Just curious - the solution is pretty elegant as is.
>
> > - Alex
>
> > --
>
> > 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] 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.) puts a tiny bit of content in the snippet (what if
different pages want different class attributes on the img tag?), and
b.) isn't customizable -- if I want another link from the image's name,
I need another bindpoint, etc.


So, with some playing around, I can get a little more general with

  

  some random html

  

bound via:

  "link" ->
{n: NodeSeq => link("/viewImage", () => selected(i.id), n)}

or:

  "link" -> link("/viewImage", () => selected(i.id),
  chooseTemplate("showAll", "link", in)),

this works well enough as far as it goes (the latter is a little worse,
IIUC as it involves more rescanning of the html).


But what I would like to do is this:

  

  

  

and neither of the previous two BindParams work, yielding:

XML Parsing Error: prefix not bound to a namespace
Location: http://www.draga.com:9080/viewImages
Line Number 135, Column 12:
   

since the content is not re-substituted.

So far, the only way I've found to do this is with a second call to
bind, repeating the list of BindParams:

  "link" -> // XXX XXX XXX ugly respecifaction of bind
 {n: NodeSeq => link("/viewImage", () => selected(i.id), 
   bind("showAll", n,
"name" -> i.name.is,
AttrBindParam("imgUrl", i.url, "src")
   ))},

Is there a cleaner way to do this -- to specify that I want bind points
of this snippet to be evaluated even if they appear within the XML of
other bind points?  I don't want or need true recursive evaluation --
just to bind all of the bind points which were visible when the xhtml
was first parsed.

Thoughts?  This is with 1.1-M8, though I don't think it makes a
difference...
-- 
Jim Wise
jw...@draga.com


pgp94whYwN2xg.pgp
Description: PGP signature


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") => loadFirstListOfPoints()
 case Full("second") => loadSecondListOfPoints()
 case _ => error("missing item attribute or has incorrect  
value")
 }

 bind(...)
 }
}

-Ross

On Dec 23, 2009, at 4:07 PM, Alex Black wrote:

> 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
> 
>  
>
>  
> 
> 
>
> My question is: If I write this block once, and surround it in a
> snippet which emits it twice, how can the snippet parameterize the
> nested snippet calls?
>
> I realize I could bind the entire block with one snippet call, but
> because my real blocks are big and complex I'd like to keep the many
> snippet calls per block.
>
> So, more specifically, how can i write  and
>  more like this:  item="@curItem">
>
> thx
>
> - Alex
>
> --
>
> 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 
> .
>
>

--

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.




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: NodeSeq, product: Product): NodeSeq =  {
>def list( xhtml: NodeSeq, product: Product): NodeSeq = {
>  product
>.alternateLabels
>.flatMap( l =>
>  bind("list", xhtml,
>"label" -> l
>  )
>)
>}
>
>product.alternateLabels match {
>  // Remove the entire block (including title if there are no
> alternate labels)
>  case Nil => Nil
>  case _ => bind("alsoKnownAs", xhtml, "list" -> list
> (chooseTemplate("alsoKnownAs","list", xhtml), product))
>}
>  }
>
> This works well:
> - The entire XHTML is removed if there are no alternateLabels
> - If there are alternateLabels, the "Also known as:" text is not
> repeated, just the LI elements in the list
>
> However, in my bind call:
>
>  case _ => bind("alsoKnownAs", xhtml, "list" -> list
> (chooseTemplate("alsoKnownAs","list", xhtml), product))
>
> I specified alsoKnownAs:list twice, it feels a bit redundant... The
> intent of the code is: find the thing called alsoKnownAs:list, grab
> the xhtml below it, pass it into the list function, and replace its
> value with the output of list.
>
> Is there some trick I'm missing here to avoid specifying things twice?
>
> Just curious - the solution is pretty elegant as is.
>
> - Alex
>
> --
>
> 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 
> .
>
>

--

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] 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

  

  



My question is: If I write this block once, and surround it in a
snippet which emits it twice, how can the snippet parameterize the
nested snippet calls?

I realize I could bind the entire block with one snippet call, but
because my real blocks are big and complex I'd like to keep the many
snippet calls per block.

So, more specifically, how can i write  and
 more like this: 

thx

- Alex

--

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 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, 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 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 =>
  bind("list", xhtml,
"label" -> l
  )
)
}

product.alternateLabels match {
  // Remove the entire block (including title if there are no
alternate labels)
  case Nil => Nil
  case _ => bind("alsoKnownAs", xhtml, "list" -> list
(chooseTemplate("alsoKnownAs","list", xhtml), product))
}
  }

This works well:
- The entire XHTML is removed if there are no alternateLabels
- If there are alternateLabels, the "Also known as:" text is not
repeated, just the LI elements in the list

However, in my bind call:

  case _ => bind("alsoKnownAs", xhtml, "list" -> list
(chooseTemplate("alsoKnownAs","list", xhtml), product))

I specified alsoKnownAs:list twice, it feels a bit redundant... The
intent of the code is: find the thing called alsoKnownAs:list, grab
the xhtml below it, pass it into the list function, and replace its
value with the output of list.

Is there some trick I'm missing here to avoid specifying things twice?

Just curious - the solution is pretty elegant as is.

- Alex

--

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: 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 webapps to the 2.8.0
port.

I guess I should have just hung back on netbeans, hindsight 20/20 and
all, ugh..

Alan

On Dec 22, 8:03 pm, Randinn  wrote:
> This is not the first time this has cropped up, you may have to sticky
> warning not to use 2.8 with Lift for the moment.
>
> On Dec 23, 2:55 pm, David Pollak 
> wrote:
>
>
>
> > Lift *DOES NOT* work on Scala 2.8 Beta1 RC4 & 5.  Do not even try it.  We
> > are currently working with EPFL to resolve these issues.
>
> > Lift 1.1-M8 and Lift 1.1-SNAPSHOT only work with Scala 2.7.7.  That is the
> > *only* version of Scala that Lift 1.1-M8 and SNAPSHOT work with.  If you
> > have any other version of Scala specified in your pom.xml file, it will not
> > work.
>
> > Do not try to mix different versions of Lift in the same web app.  The class
> > loader will not know which versions of the Lift library go with different
> > Servlets.
>
> > Once you get your pom.xml file set up with Scala 2.7.7, then you must do a
> > "mvn -U clean install" before doing an mvn jetty:run
>
> > On Tue, Dec 22, 2009 at 7:39 PM, Alan M  wrote:
> > > Update:
>
> > > I updated the other servlet to scala 2.8 and lift 1.1 snapshot (much
> > > easier than I thought, I must be getting used to it) and I checked the
> > > libs for both webapps and the commons lib directory.. no conflicting
> > > versions of scala or lift jars.. I'm on Tomcat 6 btw..  Not sure where
> > > to look next..
>
> > > Alan
>
> > > On Dec 22, 7:13 pm, Ross Mellgren  wrote:
> > > > Where do you have the scala library jars? If you haven't taken pains to
> > > ensure that you have two entirely separate scala JARs (2.7.3 and 2.8) in 
> > > two
> > > separate classloaders I could believe that you'll get all kinds of 
> > > problems
> > > like this. You might be better served using two separate tomcat instances
> > > and some kind of reverse proxy like nginx to ensure they remain entirely
> > > separated.
>
> > > > -Ross
>
> > > > On Dec 22, 2009, at 10:07 PM, Alan M wrote:
>
> > > > > I get this message when it tries to initialize the LiftFilter..
>
> > > > > Dec 22, 2009 6:53:40 PM org.apache.catalina.core.StandardContext
> > > > > filterStart
> > > > > SEVERE: Exception starting filter LiftFilter
> > > > > java.lang.NoSuchMethodError: scala.collection.SeqLike.projection()
> > > > > Ljava/lang/Object;
> > > > >        at net.liftweb.util.ListHelpers$class.first(ListHelpers.scala:
> > > > > 53)
> > > > >        at net.liftweb.util.Helpers$.first(Helpers.scala:32)
> > > > >        at net.liftweb.util.LogBoot$.findTheFile$1(Log.scala:117)
> > > > >        at net.liftweb.util.LogBoot$._log4JSetup(Log.scala:119)
> > > > >        at net.liftweb.util.LogBoot$$anonfun$1.apply(Log.scala:97)
> > > > >        at net.liftweb.util.LogBoot$$anonfun$1.apply(Log.scala:97)
> > > > >        at net.liftweb.util.LogBoot$.checkConfig(Log.scala:95)
> > > > >        at net.liftweb.util.LogBoot$.net$liftweb$util$LogBoot$$_logger
> > > > > (Log.scala:141)
> > > > >        at net.liftweb.util.LogBoot$$anonfun$2.apply(Log.scala:143)
> > > > >        at net.liftweb.util.LogBoot$$anonfun$2.apply(Log.scala:143)
> > > > >        at net.liftweb.util.Log$.rootLogger(Log.scala:27)
> > > > >        at net.liftweb.util.Log$.error(Log.scala:43)
> > > > >        at net.liftweb.http.provider.HTTPProvider$class.bootLift
> > > > > (HTTPProvider.scala:80)
> > > > >        at net.liftweb.http.LiftFilter.bootLift(LiftServlet.scala:524)
> > > > >        at net.liftweb.http.provider.servlet.ServletFilterProvider
> > > > > $class.init(ServletFilterProvider.scala:23)
> > > > >        at net.liftweb.http.LiftFilter.init(LiftServlet.scala:524)
>
> > > > > Are multiple versions of Scala or Lift getting messed up here?  I have
> > > > > two different Lift based servlets on this tomcat, one with Scala 2.7.3
> > > > > and an older lift version and one with Scala 2.8 and the newest lift
> > > > > version..
>
> > > > > I guess I'm just trying to avoid updating that other servlet because
> > > > > it's really not in my schedule right now..  Then again that might not
> > > > > be the problem at all..
>
> > > > > Alan
>
> > > > > --
>
> > > > > 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...@googlegroup

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 flatMap.

-
Erkki Lindpere wrote:

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 */
>      def bindModelObj(ns: NodeSeq)(model: ModelObj) =
>          bind("model", ns, "field1" -> model.field1, "field2" ->  
> model.field2)
>
> }
>
> class MySnippet extends DispatchSnippet {
>      import MySnippet.bindModelObj
>
>      val dispatch: DispatchIt = {
>          case "forEach" => forEach
>          case "justOne" => justOne
>      }
>
>      def forEach(ns: NodeSeq): NodeSeq =
>          somehowGetAListOfModelObjects().flatMap(bindModelObj(ns) _)
>
>      def justOne(ns: NodeSeq): NodeSeq =
>          bindModelObj(ns)(somehowGetJustOneModelObject())
>
> }
>
> And then in your snippet you can also have reuse (I don't know how  
> efficient this is):
>
> 
>      
>      
> 
>
> 
>      
>      
> 
>
> If you have the same rendering for each object, you could use  
> eager_eval and embed:
>
> 
>      
> 
>
> 
>      
> 
>
> -Ross
>
> On Dec 23, 2009, at 1:51 PM, Erkki Lindpere wrote:
>
> > 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 too.
>
> > Erkki L
>
> > On Dec 23, 8:31 pm, Ross Mellgren  wrote:
> >> 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 the case where a session is not available.
>
> >> I think the more idiomatic way is probably more like
>
> >> def forEachMsg(in: NodeSeq): NodeSeq = {
> >>      val msgs = somehowGetAListOfModelObjects()
> >>      msgs.flatMap { msg =>
> >>          bind("msg", in, "field1" -> msg.field1, "field2" ->
> >> msg.field2);
> >>      }
>
> >> }
>
> >> And then inline at the call side:
>
> >> 
> >>      
> >>      
> >> 
>
> >> Is there something peculiar about your use case where you really want
> >> to do lift:embed and so on?
>
> >> -Ross
>
> >> On Dec 23, 2009, at 1:26 PM, Erkki Lindpere wrote:
>
> >>> 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 through it element by element and processes the
> >>> input NodeSeq for each element. What I came up with is this:
>
> >>>  def foreach(in: NodeSeq) = {
> >>>    val msgs = somehowGetAListOfModelObjects();
> >>>    msgs.flatMap { msg =>
> >>>      // set the current object (CurrentMessage is a ThreadLocal)
> >>>      CurrentMessage.set(msg)
> >>>      // process the contents, with the current object in scope
> >>>      S.session.get.processSurroundAndInclude("", in)
> >>>    }
> >>>  }
>
> >>> And it's called like this:
> >>>    
> >>>            
> >>>    
>
> >>> Is there a more correct solution to this?
>
> >>> --
>
> >>> 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 
> > 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.


--

You received this message because you are subscribed t

[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, 2009 at 11:29 AM, Alex Black  wrote:
> > Hi Xuefeng,
>
> > I'm using the default Lift Sitemap, so I don't think I can use either
> > of your suggestions, or, I don't see how to use them.  The sitemap
> > renders the links for me... I have seen how to set the class of the
> > elements that it renders, but not how to add other attributes such as
> > title.
>
> > - Alex
>
> > > You could add MetaData 'title' by Elem 's method '%'
> > > some page % ("title" -> "what will happen when you
> > click
> > > on this
> > > link")
>
> > > or use { }
> > > some page
>
> > > On Mon, Dec 21, 2009 at 10:38 PM, Alex Black  wrote:
> > > > Can someone point me in the right direction to get tooltips (title
> > > > attributes) rendered in my sitemap?
>
> > > > I'd like to add text to each link, so they get rendered like this:
>
> > > > some page
>
> > > > thx
>
> > > > - Alex
>
> > > > --
>
> > > > 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.
>
> > > --
> > > Scala中文社区:  http://groups.google.com/group/scalacn
>
> > --
>
> > 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.
>
> --
> Scala中文社区:  http://groups.google.com/group/scalacn

--

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: 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 */
>      def bindModelObj(ns: NodeSeq)(model: ModelObj) =
>          bind("model", ns, "field1" -> model.field1, "field2" ->  
> model.field2)
>
> }
>
> class MySnippet extends DispatchSnippet {
>      import MySnippet.bindModelObj
>
>      val dispatch: DispatchIt = {
>          case "forEach" => forEach
>          case "justOne" => justOne
>      }
>
>      def forEach(ns: NodeSeq): NodeSeq =
>          somehowGetAListOfModelObjects().flatMap(bindModelObj(ns) _)
>
>      def justOne(ns: NodeSeq): NodeSeq =
>          bindModelObj(ns)(somehowGetJustOneModelObject())
>
> }
>
> And then in your snippet you can also have reuse (I don't know how  
> efficient this is):
>
> 
>      
>      
> 
>
> 
>      
>      
> 
>
> If you have the same rendering for each object, you could use  
> eager_eval and embed:
>
> 
>      
> 
>
> 
>      
> 
>
> -Ross
>
> On Dec 23, 2009, at 1:51 PM, Erkki Lindpere wrote:
>
> > 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 too.
>
> > Erkki L
>
> > On Dec 23, 8:31 pm, Ross Mellgren  wrote:
> >> 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 the case where a session is not available.
>
> >> I think the more idiomatic way is probably more like
>
> >> def forEachMsg(in: NodeSeq): NodeSeq = {
> >>      val msgs = somehowGetAListOfModelObjects()
> >>      msgs.flatMap { msg =>
> >>          bind("msg", in, "field1" -> msg.field1, "field2" ->
> >> msg.field2);
> >>      }
>
> >> }
>
> >> And then inline at the call side:
>
> >> 
> >>      
> >>      
> >> 
>
> >> Is there something peculiar about your use case where you really want
> >> to do lift:embed and so on?
>
> >> -Ross
>
> >> On Dec 23, 2009, at 1:26 PM, Erkki Lindpere wrote:
>
> >>> 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 through it element by element and processes the
> >>> input NodeSeq for each element. What I came up with is this:
>
> >>>  def foreach(in: NodeSeq) = {
> >>>    val msgs = somehowGetAListOfModelObjects();
> >>>    msgs.flatMap { msg =>
> >>>      // set the current object (CurrentMessage is a ThreadLocal)
> >>>      CurrentMessage.set(msg)
> >>>      // process the contents, with the current object in scope
> >>>      S.session.get.processSurroundAndInclude("", in)
> >>>    }
> >>>  }
>
> >>> And it's called like this:
> >>>    
> >>>            
> >>>    
>
> >>> Is there a more correct solution to this?
>
> >>> --
>
> >>> 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 
> > 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] 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", ns, "field1" -> model.field1, "field2" ->  
> model.field2)
>
> }
>
> class MySnippet extends DispatchSnippet {
>      import MySnippet.bindModelObj
>
>      val dispatch: DispatchIt = {
>          case "forEach" => forEach
>          case "justOne" => justOne
>      }
>
>      def forEach(ns: NodeSeq): NodeSeq =
>          somehowGetAListOfModelObjects().flatMap(bindModelObj(ns) _)
>
>      def justOne(ns: NodeSeq): NodeSeq =
>          bindModelObj(ns)(somehowGetJustOneModelObject())
>
> }
>
> And then in your snippet you can also have reuse (I don't know how  
> efficient this is):
>
> 
>      
>      
> 
>
> 
>      
>      
> 
>
> If you have the same rendering for each object, you could use  
> eager_eval and embed:
>
> 
>      
> 
>
> 
>      
> 
>
> -Ross
>
> On Dec 23, 2009, at 1:51 PM, Erkki Lindpere wrote:
>
> > 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 too.
>
> > Erkki L
>
> > On Dec 23, 8:31 pm, Ross Mellgren  wrote:
> >> 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 the case where a session is not available.
>
> >> I think the more idiomatic way is probably more like
>
> >> def forEachMsg(in: NodeSeq): NodeSeq = {
> >>      val msgs = somehowGetAListOfModelObjects()
> >>      msgs.flatMap { msg =>
> >>          bind("msg", in, "field1" -> msg.field1, "field2" ->
> >> msg.field2);
> >>      }
>
> >> }
>
> >> And then inline at the call side:
>
> >> 
> >>      
> >>      
> >> 
>
> >> Is there something peculiar about your use case where you really want
> >> to do lift:embed and so on?
>
> >> -Ross
>
> >> On Dec 23, 2009, at 1:26 PM, Erkki Lindpere wrote:
>
> >>> 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 through it element by element and processes the
> >>> input NodeSeq for each element. What I came up with is this:
>
> >>>  def foreach(in: NodeSeq) = {
> >>>    val msgs = somehowGetAListOfModelObjects();
> >>>    msgs.flatMap { msg =>
> >>>      // set the current object (CurrentMessage is a ThreadLocal)
> >>>      CurrentMessage.set(msg)
> >>>      // process the contents, with the current object in scope
> >>>      S.session.get.processSurroundAndInclude("", in)
> >>>    }
> >>>  }
>
> >>> And it's called like this:
> >>>    
> >>>            
> >>>    
>
> >>> Is there a more correct solution to this?
>
> >>> --
>
> >>> 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 
> > 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.




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 MySnippet extends DispatchSnippet {
 import MySnippet.bindModelObj

 val dispatch: DispatchIt = {
 case "forEach" => forEach
 case "justOne" => justOne
 }

 def forEach(ns: NodeSeq): NodeSeq =
 somehowGetAListOfModelObjects().flatMap(bindModelObj(ns) _)

 def justOne(ns: NodeSeq): NodeSeq =
 bindModelObj(ns)(somehowGetJustOneModelObject())
}

And then in your snippet you can also have reuse (I don't know how  
efficient this is):


 
 



 
 


If you have the same rendering for each object, you could use  
eager_eval and embed:


 



 


-Ross


On Dec 23, 2009, at 1:51 PM, Erkki Lindpere wrote:

> 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 too.
>
> Erkki L
>
> On Dec 23, 8:31 pm, Ross Mellgren  wrote:
>> 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 the case where a session is not available.
>>
>> I think the more idiomatic way is probably more like
>>
>> def forEachMsg(in: NodeSeq): NodeSeq = {
>>  val msgs = somehowGetAListOfModelObjects()
>>  msgs.flatMap { msg =>
>>  bind("msg", in, "field1" -> msg.field1, "field2" ->
>> msg.field2);
>>  }
>>
>> }
>>
>> And then inline at the call side:
>>
>> 
>>  
>>  
>> 
>>
>> Is there something peculiar about your use case where you really want
>> to do lift:embed and so on?
>>
>> -Ross
>>
>> On Dec 23, 2009, at 1:26 PM, Erkki Lindpere wrote:
>>
>>> 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 through it element by element and processes the
>>> input NodeSeq for each element. What I came up with is this:
>>
>>>  def foreach(in: NodeSeq) = {
>>>val msgs = somehowGetAListOfModelObjects();
>>>msgs.flatMap { msg =>
>>>  // set the current object (CurrentMessage is a ThreadLocal)
>>>  CurrentMessage.set(msg)
>>>  // process the contents, with the current object in scope
>>>  S.session.get.processSurroundAndInclude("", in)
>>>}
>>>  }
>>
>>> And it's called like this:
>>>
>>>
>>>
>>
>>> Is there a more correct solution to this?
>>
>>> --
>>
>>> 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 
> .
>
>

--

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: 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 too.

Erkki L

On Dec 23, 8:31 pm, Ross Mellgren  wrote:
> 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 the case where a session is not available.
>
> I think the more idiomatic way is probably more like
>
> def forEachMsg(in: NodeSeq): NodeSeq = {
>      val msgs = somehowGetAListOfModelObjects()
>      msgs.flatMap { msg =>
>          bind("msg", in, "field1" -> msg.field1, "field2" ->  
> msg.field2);
>      }
>
> }
>
> And then inline at the call side:
>
> 
>      
>      
> 
>
> Is there something peculiar about your use case where you really want  
> to do lift:embed and so on?
>
> -Ross
>
> On Dec 23, 2009, at 1:26 PM, Erkki Lindpere wrote:
>
> > 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 through it element by element and processes the
> > input NodeSeq for each element. What I came up with is this:
>
> >  def foreach(in: NodeSeq) = {
> >    val msgs = somehowGetAListOfModelObjects();
> >    msgs.flatMap { msg =>
> >      // set the current object (CurrentMessage is a ThreadLocal)
> >      CurrentMessage.set(msg)
> >      // process the contents, with the current object in scope
> >      S.session.get.processSurroundAndInclude("", in)
> >    }
> >  }
>
> > And it's called like this:
> >    
> >            
> >    
>
> > Is there a more correct solution to this?
>
> > --
>
> > 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.




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 the case where a session is not available.

I think the more idiomatic way is probably more like

def forEachMsg(in: NodeSeq): NodeSeq = {
 val msgs = somehowGetAListOfModelObjects()
 msgs.flatMap { msg =>
 bind("msg", in, "field1" -> msg.field1, "field2" ->  
msg.field2);
 }
}

And then inline at the call side:


 
 


Is there something peculiar about your use case where you really want  
to do lift:embed and so on?

-Ross

On Dec 23, 2009, at 1:26 PM, Erkki Lindpere wrote:

> 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 through it element by element and processes the
> input NodeSeq for each element. What I came up with is this:
>
>  def foreach(in: NodeSeq) = {
>val msgs = somehowGetAListOfModelObjects();
>msgs.flatMap { msg =>
>  // set the current object (CurrentMessage is a ThreadLocal)
>  CurrentMessage.set(msg)
>  // process the contents, with the current object in scope
>  S.session.get.processSurroundAndInclude("", in)
>}
>  }
>
> And it's called like this:
>   
>   
>   
>
>
> Is there a more correct solution to this?
>
> --
>
> 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 
> .
>
>

--

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] 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 through it element by element and processes the
input NodeSeq for each element. What I came up with is this:

  def foreach(in: NodeSeq) = {
val msgs = somehowGetAListOfModelObjects();
msgs.flatMap { msg =>
  // set the current object (CurrentMessage is a ThreadLocal)
  CurrentMessage.set(msg)
  // process the contents, with the current object in scope
  S.session.get.processSurroundAndInclude("", in)
}
  }

And it's called like this:





Is there a more correct solution to this?

--

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: 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 using lift-mapper as
> dependency should suffice. Rest of the dependencies would be pulled down
> automatically.
>
> I just updated your gist. See if this works.http://gist.github.com/262613
>
> As davidB mentioned you can also run "mvn dependency:analyze" to filter
> out unnecessary dependencies.
>
> Generally speaking:
>
> 1. If you are using any of the persistence modules (lift-mapper,
> lift-jpa, lift-record) you do not need any of the base modules. They
> would be pulled transitively.
>
> 2. If you are not using the persistence module (possibly because your
> app doesn't need such support). Just including lift-webkit should suffice.
>
> 3. Additionally, if you are using any of the special purpose modules
> (from lift-modules), just add that to the lift of dependencies.
>
> Cheers, Indrajit
>
> On 23/12/09 7:12 PM, David Bernard wrote:
>
>
>
> > 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 realize that I've been using lift-core
> >     without realizing it. Thanks.
>
> >     Unfortunately switching to something simpler is giving me some
> >     trouble. I believe that I should be able to add lift-base, but while
> >     its sub-modules get downloaded (lift-common, lift-util, etc), Maven
> >     says that the lift-base module is missing and needs to be installed.
> >     This is the entry I'm using:
> >     
> >     net.liftweb
> >     lift-base
> >     1.1-SNAPSHOT
> >     
>
> >     As the resident Maven expert, do you have any idea what's wrong? My
> >     entire pom.xml is here:http://gist.github.com/262244
>
> >     Thanks,
> >     Peter
>
> >     On Dec 22, 8:32 am, Indrajit Raychaudhuri  >     > wrote:
> >      > On 22/12/09 12:23 AM, David Pollak wrote:
>
> >      > > On Sun, Dec 20, 2009 at 11:39 AM, Indrajit Raychaudhuri
> >      > > mailto:indraj...@gmail.com>
> >     >> wrote:
>
> >      > >     Folks,
>
> >      > >     lift-core is a 'meta' project that can be added as a
> >     dependency to a
> >      > >     Lift project to pull in all the Lift modules. This serves
> >     as a singular
> >      > >     configuration point in a Lift based application.
>
> >      > >     However, since lift-core downloads all the Lift modules
> >     (irrespective of
> >      > >     whether the project needs it), adding this as the
> >     dependency slow  down
> >      > >     things for a standard project that doesn't need some
> >     additional modules.
>
> >      > >     In a sense, we have moved quite a bit from the initial
> >     purpose of having
> >      > >     single dependency on this 'meta' project in a Lift application.
>
> >      > >     Further, the name is a misnomer now!
>
> >      > >     The question, therefore is:
> >      > >     Should we consider deprecating this? If not, we need to
> >     document when it
> >      > >     should be preferred and when not. If yes, what should be
> >     the time frame
> >      > >     for making the move?
>
> >      > >     With Lift 2.0 coming up,
>
> >      > > Lift 2.0 is not "coming up" it's merely a rename of Lift 1.1
> >     based on
> >      > > the naming rules that Heiko proposed and the Lift community
> >     adopted.
> >      > > The fact that the next release of Lift is going to be called
> >     2.0 rather
> >      > > than 1.1 does not change the scope of the release.
>
> >      > Indeed, poor wordings, Lift 2.0 *restructure* coming up is what I
> >     meant.
> >      > But yes, it ends up sounding different, sorry.
>
> >      > > With that being said, deprecating lift-core is fine by me as
> >     long as
> >      > > there is an easy to understand deprecation message with clear
> >      > > instructions as to how to replace lift-core with whatever is
> >     necessary.
>
> >      > For deprecating dependencies, it's just matter of persuasion
> >      > (Announcement, wiki etc.) for at least two releases, or more
> >     (could be
> >      > milestone releases). And eventually, dropping it from the build
> >     beyond
> >      > an agreeable release time frame.
>
> >      > I couldn't figure out a clean way of deprecating 'meta' packages
> >     since
> >      > it doesn't have any active code (thus doesn't expose any place to
> >     code
> >      > in some deprecation warning message).
>
> >      > As such, the package is harmles

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 
automatically.

I just updated your gist. See if this works.
http://gist.github.com/262613

As davidB mentioned you can also run "mvn dependency:analyze" to filter 
out unnecessary dependencies.

Generally speaking:

1. If you are using any of the persistence modules (lift-mapper, 
lift-jpa, lift-record) you do not need any of the base modules. They 
would be pulled transitively.

2. If you are not using the persistence module (possibly because your 
app doesn't need such support). Just including lift-webkit should suffice.

3. Additionally, if you are using any of the special purpose modules 
(from lift-modules), just add that to the lift of dependencies.

Cheers, Indrajit


On 23/12/09 7:12 PM, David Bernard wrote:
> 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 realize that I've been using lift-core
> without realizing it. Thanks.
>
> Unfortunately switching to something simpler is giving me some
> trouble. I believe that I should be able to add lift-base, but while
> its sub-modules get downloaded (lift-common, lift-util, etc), Maven
> says that the lift-base module is missing and needs to be installed.
> This is the entry I'm using:
> 
> net.liftweb
> lift-base
> 1.1-SNAPSHOT
> 
>
> As the resident Maven expert, do you have any idea what's wrong? My
> entire pom.xml is here: http://gist.github.com/262244
>
> Thanks,
> Peter
>
> On Dec 22, 8:32 am, Indrajit Raychaudhuri  > wrote:
>  > On 22/12/09 12:23 AM, David Pollak wrote:
>  >
>  >
>  >
>  >
>  >
>  >
>  >
>  > > On Sun, Dec 20, 2009 at 11:39 AM, Indrajit Raychaudhuri
>  > > mailto:indraj...@gmail.com>
> >> wrote:
>  >
>  > > Folks,
>  >
>  > > lift-core is a 'meta' project that can be added as a
> dependency to a
>  > > Lift project to pull in all the Lift modules. This serves
> as a singular
>  > > configuration point in a Lift based application.
>  >
>  > > However, since lift-core downloads all the Lift modules
> (irrespective of
>  > > whether the project needs it), adding this as the
> dependency slow  down
>  > > things for a standard project that doesn't need some
> additional modules.
>  >
>  > > In a sense, we have moved quite a bit from the initial
> purpose of having
>  > > single dependency on this 'meta' project in a Lift application.
>  >
>  > > Further, the name is a misnomer now!
>  >
>  > > The question, therefore is:
>  > > Should we consider deprecating this? If not, we need to
> document when it
>  > > should be preferred and when not. If yes, what should be
> the time frame
>  > > for making the move?
>  >
>  > > With Lift 2.0 coming up,
>  >
>  > > Lift 2.0 is not "coming up" it's merely a rename of Lift 1.1
> based on
>  > > the naming rules that Heiko proposed and the Lift community
> adopted.
>  > > The fact that the next release of Lift is going to be called
> 2.0 rather
>  > > than 1.1 does not change the scope of the release.
>  >
>  > Indeed, poor wordings, Lift 2.0 *restructure* coming up is what I
> meant.
>  > But yes, it ends up sounding different, sorry.
>  >
>  >
>  >
>  > > With that being said, deprecating lift-core is fine by me as
> long as
>  > > there is an easy to understand deprecation message with clear
>  > > instructions as to how to replace lift-core with whatever is
> necessary.
>  >
>  > For deprecating dependencies, it's just matter of persuasion
>  > (Announcement, wiki etc.) for at least two releases, or more
> (could be
>  > milestone releases). And eventually, dropping it from the build
> beyond
>  > an agreeable release time frame.
>  >
>  > I couldn't figure out a clean way of deprecating 'meta' packages
> since
>  > it doesn't have any active code (thus doesn't expose any place to
> code
>  > in some deprecation warning message).
>  >
>  > As such, the package is harmless and there is zero cost of
> maintenance.
>  > Just that, it's no more a good practice (longer build time,
> 

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 lay out that
list.  The layout should be controlled by CSS.

Second, you can access the same snippet information in your Scala code as
Lift's layout supports.  For example:



In your userList file, you might have a something like:



So, you want to update the fruitbat span via Ajax:

def myAjaxFunc(): JsCmd = {
  // ... do some user list stuff in the RDBMS
  SetHtml("fruitbat",
  TemplateFinder.findAnyTemplate(List("snippets-hidden",
"userList")) openOr NodeSeq.Empty)
}


So, you are now running the same template (which will invoke the same
snippet) in the Ajax call that you were in your main call.


On Wed, Dec 23, 2009 at 3:51 AM, 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 assume this Ajax function:
> >
> > def myCallback(): JsCmd = {
> > val myList = ...
> >
> > val html: NodeSeq = myList.flatMap(e => {e toString})
> >
> > SetHtml("all_todos", html)
> >
> > }
> But then I'm embedding view logic into the code - I wouldn't really want to
> do that. Especially once the list becomes anything more fancy then a simple
> table, I think putting the list-displaying into an html file better.
>
> I tried doing something else, expanding your idea.
> I've put the list-displaying html markup into a template (todo_list.html),
> so now I can reuse it to both display the list and pass it to the snippet
> which handles and binds the form:
>
> Now my form looks like this:
>
> 
> 
>  
> 
> 
>  
> 
> 
>
> 
>
> 
> 
>
> In TD.add I have then:
> ...
> def drawList() = list(chooseTemplate("addForm", "list", form))
> def reDraw() = SetHtml("all_todos", drawList())
>
> bind("todo", chooseTemplate("addForm", "form", form),
> "priority" -> todo.priority.toForm,
> "desc" -> todo.desc.toForm,
> "submit" -> submit("New", checkAndSave))
> )
> ...
>
> Is this the right way to go? And is it the "lift" way?
>
> Anyway I can't test it yet because I can't get my form to be submitted with
> ajax. Both surrounding the bind with SHtml.ajaxForm(...) and replacing
> submit with ajaxButton causes the form to stop working (the values in the
> model aren't updated).
>
> Adam
>
> > Br's,
> > Marius
> >
> > On Dec 23, 10:32 am, Adam Warski  wrote:
> >> 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 after the button
> has been pressed. More generally: how to redraw a page fragment with ajax? I
> could do that with SetHtml if I had the NodeSeq corresponding to the list,
> but the button is in an "unrelated" page fragment so it doesn't have it.
> What's the Lift way to solve such problems?
> >>
> >> The page roughly is:
> >>
> >> 
> >> 
> >> 
> >>
> >> 
> >>
> >> 
> >> 
> >> ...
> >> 
> >>
> >> I was looking through the list archive but didn't find anything. Sorry
> if it's a repeated question :)
> >>
> >> --
> >> 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.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, the simply functional web framework http://liftweb.net
Beginning Scala http://www.apress.com/book/view/1430219890
Follow me: http://twitter.com/dpp
Surf the harmonics

--

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: 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 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, 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.




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 into snippetDispatch yourself.

-Ross

On Dec 23, 2009, at 11:38 AM, 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 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, 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 
> .
>
>

--

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] 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, 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: 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 in the thread I paste.


Br's,
Marius

On Dec 23, 4:50 pm, Adam Warski  wrote:
> 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 model.
>
> Code of my snippet, without ajax (works):
>         bind("todo", chooseTemplate("addForm", "form", form),
>           "desc" -> todo.desc.toForm,
>           "submit" -> submit("New", checkAndSave))
>         )
>
> With ajax (doesn't work):
> ajaxForm(
>         bind("todo", chooseTemplate("addForm", "form", form),
>           "desc" -> todo.desc.toForm,
>           "submit" -> submit("New", checkAndSave))
>         )
>
> Or:
>         bind("todo", chooseTemplate("addForm", "form", form),
>           "desc" -> todo.desc.toForm,
>           "submit" -> ajaxButton("New", () => {checkAndSave; reDraw()}))
>         )
>
> --
> 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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




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 model.

Code of my snippet, without ajax (works):
bind("todo", chooseTemplate("addForm", "form", form),
  "desc" -> todo.desc.toForm,
  "submit" -> submit("New", checkAndSave))
)

With ajax (doesn't work):
ajaxForm(
bind("todo", chooseTemplate("addForm", "form", form),
  "desc" -> todo.desc.toForm,
  "submit" -> submit("New", checkAndSave))
)

Or:
bind("todo", chooseTemplate("addForm", "form", form),
  "desc" -> todo.desc.toForm,
  "submit" -> ajaxButton("New", () => {checkAndSave; reDraw()}))
)

-- 
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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[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 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 = ...
>
> > > val html: NodeSeq = myList.flatMap(e => {e toString})
>
> > > SetHtml("all_todos", html)
>
> > > }
>
> > But then I'm embedding view logic into the code - I wouldn't really want to 
> > do that. Especially once the list becomes anything more fancy then a simple 
> > table, I think putting the list-displaying into an html file better.
>
> Think of Snippets as extensions to the markup responsible for
> generating dynamic markup. Hence markup in snippets is very natural.
> Of course one should not abuse this and generate tons of markup from
> scala code. But what I typically do is to use markup template and then
> bind.
>
> 
>   
>      
>   
> 
>
> Then on server side in your TD snippet you can cache the snippet
> content Xhtml, in this case being:
>  
> ... you can put this in a RequestVar.
>
> Then from you Ajax function can get this markup template and use bind
> on it such as:
>
> object MyMarkupVar extends RequestVar[NodeSeq](NodeSeq.empty)
>
> class TD {
>
> def myAjaxCallback(): JsCmd = {
>   val myList = ...
>
>   val markUp = MyMarkupVar.get
>
>   val html: NodeSeq = myList.flatMap(e => bind("pref", markup
>      "item" -> e.toString /*or whatever have you*/
>   ))
>
>   SetHtml("all_todos", html)
>
> }
>
> def list(xhtml: NodeSeq): NodeSeq = {
>    MyMarkupVar.set(xhtml)
>    NodeSeq.Empty
>
> }
> }
>
> therefore you don't need to know from Scala code how your template
> looks like.
>
>
>
> > I tried doing something else, expanding your idea.
> > I've put the list-displaying html markup into a template (todo_list.html), 
> > so now I can reuse it to both display the list and pass it to the snippet 
> > which handles and binds the form:
>
> > Now my form looks like this:
>
> > 
> > 
> >   
> > 
> > 
> >   
> > 
> > 
>
> > 
>
> > 
> > 
>
> > In TD.add I have then:
> > ...
> > def drawList() = list(chooseTemplate("addForm", "list", form))
> > def reDraw() = SetHtml("all_todos", drawList())
>
> > bind("todo", chooseTemplate("addForm", "form", form),
> > "priority" -> todo.priority.toForm,
> > "desc" -> todo.desc.toForm,
> > "submit" -> submit("New", checkAndSave))
> > )
> > ...
>
> > Is this the right way to go? And is it the "lift" way?
>
> > Anyway I can't test it yet because I can't get my form to be submitted with 
> > ajax. Both surrounding the bind with SHtml.ajaxForm(...) and replacing 
> > submit with ajaxButton causes the form to stop working (the values in the 
> > model aren't updated).
>
> > Adam
>
> > > Br's,
> > > Marius
>
> > > On Dec 23, 10:32 am, Adam Warski  wrote:
> > >> 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 after the button 
> > >> has been pressed. More generally: how to redraw a page fragment with 
> > >> ajax? I could do that with SetHtml if I had the NodeSeq corresponding to 
> > >> the list, but the button is in an "unrelated" page fragment so it 
> > >> doesn't have it. What's the Lift way to solve such problems?
>
> > >> The page roughly is:
>
> > >> 
> > >> 
> > >> 
>
> > >> 
>
> > >> 
> > >> 
> > >> ...
> > >> 
>
> > >> I was looking through the list archive but didn't find anything. Sorry 
> > >> if it's a repeated question :)
>
> > >> --
> > >> 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.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] 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 assume this Ajax function:
>
> > def myCallback(): JsCmd = {
> > val myList = ...
>
> > val html: NodeSeq = myList.flatMap(e => {e toString})
>
> > SetHtml("all_todos", html)
>
> > }
>
> But then I'm embedding view logic into the code - I wouldn't really want to 
> do that. Especially once the list becomes anything more fancy then a simple 
> table, I think putting the list-displaying into an html file better.

Think of Snippets as extensions to the markup responsible for
generating dynamic markup. Hence markup in snippets is very natural.
Of course one should not abuse this and generate tons of markup from
scala code. But what I typically do is to use markup template and then
bind.



  
 
  


Then on server side in your TD snippet you can cache the snippet
content Xhtml, in this case being:
 
... you can put this in a RequestVar.

Then from you Ajax function can get this markup template and use bind
on it such as:

object MyMarkupVar extends RequestVar[NodeSeq](NodeSeq.empty)

class TD {

def myAjaxCallback(): JsCmd = {
  val myList = ...

  val markUp = MyMarkupVar.get


  val html: NodeSeq = myList.flatMap(e => bind("pref", markup
 "item" -> e.toString /*or whatever have you*/
  ))

  SetHtml("all_todos", html)

}


def list(xhtml: NodeSeq): NodeSeq = {
   MyMarkupVar.set(xhtml)
   NodeSeq.Empty
}

}
therefore you don't need to know from Scala code how your template
looks like.

>
> I tried doing something else, expanding your idea.
> I've put the list-displaying html markup into a template (todo_list.html), so 
> now I can reuse it to both display the list and pass it to the snippet which 
> handles and binds the form:
>
> Now my form looks like this:
>
> 
> 
>   
> 
> 
>   
> 
> 
>
> 
>
> 
> 
>
> In TD.add I have then:
> ...
> def drawList() = list(chooseTemplate("addForm", "list", form))
> def reDraw() = SetHtml("all_todos", drawList())
>
> bind("todo", chooseTemplate("addForm", "form", form),
> "priority" -> todo.priority.toForm,
> "desc" -> todo.desc.toForm,
> "submit" -> submit("New", checkAndSave))
> )
> ...
>
> Is this the right way to go? And is it the "lift" way?
>
> Anyway I can't test it yet because I can't get my form to be submitted with 
> ajax. Both surrounding the bind with SHtml.ajaxForm(...) and replacing submit 
> with ajaxButton causes the form to stop working (the values in the model 
> aren't updated).
>
> Adam
>
> > Br's,
> > Marius
>
> > On Dec 23, 10:32 am, Adam Warski  wrote:
> >> 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 after the button 
> >> has been pressed. More generally: how to redraw a page fragment with ajax? 
> >> I could do that with SetHtml if I had the NodeSeq corresponding to the 
> >> list, but the button is in an "unrelated" page fragment so it doesn't have 
> >> it. What's the Lift way to solve such problems?
>
> >> The page roughly is:
>
> >> 
> >> 
> >> 
>
> >> 
>
> >> 
> >> 
> >> ...
> >> 
>
> >> I was looking through the list archive but didn't find anything. Sorry if 
> >> it's a repeated question :)
>
> >> --
> >> 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.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.




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 realize that I've been using lift-core
> without realizing it. Thanks.
>
> Unfortunately switching to something simpler is giving me some
> trouble. I believe that I should be able to add lift-base, but while
> its sub-modules get downloaded (lift-common, lift-util, etc), Maven
> says that the lift-base module is missing and needs to be installed.
> This is the entry I'm using:
> 
>  net.liftweb
>  lift-base
>  1.1-SNAPSHOT
> 
>
> As the resident Maven expert, do you have any idea what's wrong? My
> entire pom.xml is here: http://gist.github.com/262244
>
> Thanks,
> Peter
>
> On Dec 22, 8:32 am, Indrajit Raychaudhuri  wrote:
> > On 22/12/09 12:23 AM, David Pollak wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Sun, Dec 20, 2009 at 11:39 AM, Indrajit Raychaudhuri
> > > mailto:indraj...@gmail.com>> wrote:
> >
> > > Folks,
> >
> > > lift-core is a 'meta' project that can be added as a dependency to
> a
> > > Lift project to pull in all the Lift modules. This serves as a
> singular
> > > configuration point in a Lift based application.
> >
> > > However, since lift-core downloads all the Lift modules
> (irrespective of
> > > whether the project needs it), adding this as the dependency slow
>  down
> > > things for a standard project that doesn't need some additional
> modules.
> >
> > > In a sense, we have moved quite a bit from the initial purpose of
> having
> > > single dependency on this 'meta' project in a Lift application.
> >
> > > Further, the name is a misnomer now!
> >
> > > The question, therefore is:
> > > Should we consider deprecating this? If not, we need to document
> when it
> > > should be preferred and when not. If yes, what should be the time
> frame
> > > for making the move?
> >
> > > With Lift 2.0 coming up,
> >
> > > Lift 2.0 is not "coming up" it's merely a rename of Lift 1.1 based on
> > > the naming rules that Heiko proposed and the Lift community adopted.
> > > The fact that the next release of Lift is going to be called 2.0 rather
> > > than 1.1 does not change the scope of the release.
> >
> > Indeed, poor wordings, Lift 2.0 *restructure* coming up is what I meant.
> > But yes, it ends up sounding different, sorry.
> >
> >
> >
> > > With that being said, deprecating lift-core is fine by me as long as
> > > there is an easy to understand deprecation message with clear
> > > instructions as to how to replace lift-core with whatever is necessary.
> >
> > For deprecating dependencies, it's just matter of persuasion
> > (Announcement, wiki etc.) for at least two releases, or more (could be
> > milestone releases). And eventually, dropping it from the build beyond
> > an agreeable release time frame.
> >
> > I couldn't figure out a clean way of deprecating 'meta' packages since
> > it doesn't have any active code (thus doesn't expose any place to code
> > in some deprecation warning message).
> >
> > As such, the package is harmless and there is zero cost of maintenance.
> > Just that, it's no more a good practice (longer build time, larger war
> > size etc.).
> >
> >
> >
> >
> >
> > > now might be a good time to make a decision.
> > > Thoughts?
> >
> > > Cheers, Indrajit
> >
> > > NB: An open question to anybody in the Lift: Who among you are
> actually
> > > using lift-core in you project and what is the level of impact you
> > > foresee in case you have to move on to have an alternative
> approach.
> >
> > > --
> >
> > > 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, the simply functional web frameworkhttp://liftweb.net
> > > Beginning Scalahttp://www.apress.com/book/view/1430219890
> > > Follow me:http://twitter.com/dpp
> > > Surf the harmonics
> >
> > > --
> >
> > > 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.
>
> --
>
> You received this message because you are subscribed to the Google Groups
> "Lift" group.
> To post to this gr

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 = {
> val myList = ...
> 
> val html: NodeSeq = myList.flatMap(e => {e toString})
> 
> SetHtml("all_todos", html)
> 
> }
But then I'm embedding view logic into the code - I wouldn't really want to do 
that. Especially once the list becomes anything more fancy then a simple table, 
I think putting the list-displaying into an html file better.

I tried doing something else, expanding your idea.
I've put the list-displaying html markup into a template (todo_list.html), so 
now I can reuse it to both display the list and pass it to the snippet which 
handles and binds the form:

Now my form looks like this:



  


  








In TD.add I have then:
...
def drawList() = list(chooseTemplate("addForm", "list", form))
def reDraw() = SetHtml("all_todos", drawList())

bind("todo", chooseTemplate("addForm", "form", form),
"priority" -> todo.priority.toForm,
"desc" -> todo.desc.toForm,
"submit" -> submit("New", checkAndSave))
)
...

Is this the right way to go? And is it the "lift" way?

Anyway I can't test it yet because I can't get my form to be submitted with 
ajax. Both surrounding the bind with SHtml.ajaxForm(...) and replacing submit 
with ajaxButton causes the form to stop working (the values in the model aren't 
updated).

Adam

> Br's,
> Marius
> 
> On Dec 23, 10:32 am, Adam Warski  wrote:
>> 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 after the button has 
>> been pressed. More generally: how to redraw a page fragment with ajax? I 
>> could do that with SetHtml if I had the NodeSeq corresponding to the list, 
>> but the button is in an "unrelated" page fragment so it doesn't have it. 
>> What's the Lift way to solve such problems?
>> 
>> The page roughly is:
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> ...
>> 
>> 
>> I was looking through the list archive but didn't find anything. Sorry if 
>> it's a repeated question :)
>> 
>> --
>> 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.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] 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 getStars(stars : String) : NodeSeq = {
>          if(stars.length >0) {
>           var style = "width: " + (stars.toInt * 10) + "px;"
>           
>         
>           
>          } else {}
>         }
>
> in html code then I have only  and works fine, but
> it is possible to call from html function from lift ? Something like
> tihs:
>  
>                         
>   
>
> and in * like getStars()
> def getStars(stars: String) : String = {
> "width: " + (stars.toInt * 10) + "px;"
>
> }

--

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: 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. Nonetheless this should also work:
>
> 
>
> Then put your link anywhere in your page.
>
> Br's,
> Marius
>
> On Dec 11, 11:01 am, dominikgr  wrote:
>
> > Sorry for the repetition of posts. And thanks for answer.
> > The last question how can I set form name, or form id when i use form
> > created in such way:
>
> > 
>
> > and binding start with bind("form", ns,

--

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] 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;"
  

  
 } else {}
}

in html code then I have only  and works fine, but
it is possible to call from html function from lift ? Something like
tihs:
 

  

and in * like getStars()
def getStars(stars: String) : String = {
"width: " + (stars.toInt * 10) + "px;"
}

--

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: 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 = ...

  val html: NodeSeq = myList.flatMap(e => {e toString})

  SetHtml("all_todos", html)

}

and then in your markup you can just have:



If you were referring to something else, please provide more details.

Br's,
Marius

On Dec 23, 10:32 am, Adam Warski  wrote:
> 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 after the button has 
> been pressed. More generally: how to redraw a page fragment with ajax? I 
> could do that with SetHtml if I had the NodeSeq corresponding to the list, 
> but the button is in an "unrelated" page fragment so it doesn't have it. 
> What's the Lift way to solve such problems?
>
> The page roughly is:
>
> 
> 
> 
>
> 
>
> 
> 
> ...
> 
>
> I was looking through the list archive but didn't find anything. Sorry if 
> it's a repeated question :)
>
> --
> 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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




[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 after the button has 
been pressed. More generally: how to redraw a page fragment with ajax? I could 
do that with SetHtml if I had the NodeSeq corresponding to the list, but the 
button is in an "unrelated" page fragment so it doesn't have it. What's the 
Lift way to solve such problems?

The page roughly is:









...


I was looking through the list archive but didn't find anything. Sorry if it's 
a repeated question :)

-- 
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.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




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 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.