[Lift] Re: Mapper - JObject bridge

2009-12-16 Thread Joni Freeman
Hi,

Yes, that's a way to convert JSON AST to string and vice versa. All
functions in lift-json operate on AST instances. This is lets us post-
and pre-process JSON in many ways before converting it to string. See
for instance functions map, merge, diff, \, etc. defined in JsonAST
(scaladocs still missing but will be provided before Lift 2.0 is
released). Typical conversions might for instance remove some data
from JSON, convert data types, change structure of resulting JSON and
so on.

I usually import all needed objects and their members. After that the
code becomes a bit more concise (the cast is unfortunately needed
since JSON comes from the wild and can be anything):

def encodeAsJsonString(in: A) = compact(render(encodeAsJson(in)))
def buildFromJsonString(json: String): A = buildFromJson(parse
(json).asInstanceOf[JObject])

Cheers Joni


On 16 joulu, 09:03, Xuefeng Wu ben...@gmail.com wrote:
 Hi,
 I add two method to en/decode JObject/String

 def encodeAsJsonString(in: A): String =
 Printer.compact(JsonAST.render(encodeAsJson(in)))
 def buildFromJsonString(json: String): A =
 buildFromJson(JsonParser.parse(json).asInstanceOf[JsonAST.JObject])

 Do there have better way?

 On Thu, Dec 3, 2009 at 5:15 AM, David Pollak
 feeder.of.the.be...@gmail.comwrote:



  Folks (HarryH -- this means you),

  I've just checked in code on the dpp_issue_213 that does Mapper - JObject
  bridging using the awesome lift-json library.

  The methods on MetaMapper:
  protected def encodeAsJSON_! (toEncode: A): JsonAST.JObject
  protected def decodeFromJSON_!(json: JsonAST.JObject): A

  Implement the bridge.  They are protected and have a _! in their name
  because they are *dangerous* in that data can be exposed on the JSON object
  that you might not want exposed and these methods should be used with
  extreme caution.

  An example of usage can be found in the MapperSpecs:

  object SampleModel extends SampleModel with KeyedMetaMapper[Long,
  SampleModel] {
    def encodeAsJson(in: SampleModel): JsonAST.JObject = encodeAsJSON_!(in)
    def buildFromJson(json: JsonAST.JObject): SampleModel =
  decodeFromJSON_!(json)
  }

  class SampleModel extends KeyedMapper[Long, SampleModel] {
    def getSingleton = SampleModel // what's the meta server
    def primaryKeyField = id

    object id extends MappedLongIndex(this)
    object firstName extends MappedString(this, 32)
    object moose extends MappedNullableLong(this)
    object notNull extends MappedString(this, 32) {
      override def dbNotNull_? = true
    }

    def encodeAsJson(): JsonAST.JObject = SampleModel.encodeAsJson(this)
  }

  So, you can use this mechanism to serialize a Mapper object to JSON, shovel
  the object into memcached and then pull it out, mutate a field and save the
  object back to the database (although connection identifier is lost, so if
  you are sharding your database, this will not work).

  Please give it a try, give me feedback.  I'll put it on review board
  tomorrow after any feedback and get it into Lift.

  Thanks,

  David

  --
  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.comliftweb%2bunsubscr...@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.




Re: [Lift] Re: Mapper - JObject bridge

2009-12-16 Thread Xuefeng Wu
Thanks, Joni.

On Wed, Dec 16, 2009 at 4:24 PM, Joni Freeman freeman.j...@gmail.comwrote:

 Hi,

 Yes, that's a way to convert JSON AST to string and vice versa. All
 functions in lift-json operate on AST instances. This is lets us post-
 and pre-process JSON in many ways before converting it to string. See
 for instance functions map, merge, diff, \, etc. defined in JsonAST
 (scaladocs still missing but will be provided before Lift 2.0 is
 released). Typical conversions might for instance remove some data
 from JSON, convert data types, change structure of resulting JSON and
 so on.

 I usually import all needed objects and their members. After that the
 code becomes a bit more concise (the cast is unfortunately needed
 since JSON comes from the wild and can be anything):

 def encodeAsJsonString(in: A) = compact(render(encodeAsJson(in)))
 def buildFromJsonString(json: String): A = buildFromJson(parse
 (json).asInstanceOf[JObject])

 Cheers Joni


 On 16 joulu, 09:03, Xuefeng Wu ben...@gmail.com wrote:
  Hi,
  I add two method to en/decode JObject/String
 
  def encodeAsJsonString(in: A): String =
  Printer.compact(JsonAST.render(encodeAsJson(in)))
  def buildFromJsonString(json: String): A =
  buildFromJson(JsonParser.parse(json).asInstanceOf[JsonAST.JObject])
 
  Do there have better way?
 
  On Thu, Dec 3, 2009 at 5:15 AM, David Pollak
  feeder.of.the.be...@gmail.comwrote:
 
 
 
   Folks (HarryH -- this means you),
 
   I've just checked in code on the dpp_issue_213 that does Mapper -
 JObject
   bridging using the awesome lift-json library.
 
   The methods on MetaMapper:
   protected def encodeAsJSON_! (toEncode: A): JsonAST.JObject
   protected def decodeFromJSON_!(json: JsonAST.JObject): A
 
   Implement the bridge.  They are protected and have a _! in their name
   because they are *dangerous* in that data can be exposed on the JSON
 object
   that you might not want exposed and these methods should be used with
   extreme caution.
 
   An example of usage can be found in the MapperSpecs:
 
   object SampleModel extends SampleModel with KeyedMetaMapper[Long,
   SampleModel] {
 def encodeAsJson(in: SampleModel): JsonAST.JObject =
 encodeAsJSON_!(in)
 def buildFromJson(json: JsonAST.JObject): SampleModel =
   decodeFromJSON_!(json)
   }
 
   class SampleModel extends KeyedMapper[Long, SampleModel] {
 def getSingleton = SampleModel // what's the meta server
 def primaryKeyField = id
 
 object id extends MappedLongIndex(this)
 object firstName extends MappedString(this, 32)
 object moose extends MappedNullableLong(this)
 object notNull extends MappedString(this, 32) {
   override def dbNotNull_? = true
 }
 
 def encodeAsJson(): JsonAST.JObject = SampleModel.encodeAsJson(this)
   }
 
   So, you can use this mechanism to serialize a Mapper object to JSON,
 shovel
   the object into memcached and then pull it out, mutate a field and save
 the
   object back to the database (although connection identifier is lost, so
 if
   you are sharding your database, this will not work).
 
   Please give it a try, give me feedback.  I'll put it on review board
   tomorrow after any feedback and get it into Lift.
 
   Thanks,
 
   David
 
   --
   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.comliftweb%2bunsubscr...@googlegroups.com
 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.comliftweb%2bunsubscr...@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.




Re: [Lift] [ANN] Lift 1.1-M8

2009-12-16 Thread Xuefeng Wu
anyone will add the source.jar?

On Wed, Dec 16, 2009 at 3:33 AM, Jim McBeath goo...@j.jimmc.org wrote:

 It looks like the source jars are missing from the M8 repository, at
 least for some of the libraries (for example,
 http://scala-tools.org/repo-releases/net/liftweb/lift-util/1.1-M8/).

 Are these perhaps located somewhere else now?  Or do they typically
 get added a bit later?

 --
 Jim

 On Mon, Dec 14, 2009 at 11:37:02AM -0800, David Pollak wrote:
  Date: Mon, 14 Dec 2009 11:37:02 -0800
  From: David Pollak feeder.of.the.be...@gmail.com
  To: liftweb liftweb@googlegroups.com
  Subject: [Lift] [ANN] Lift 1.1-M8
 
 The Lift Web Framework team is pleased to announce the lift-1.1-M8
 release!

 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.





-- 
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] lift_successRegisterGC()

2009-12-16 Thread Alex Black
I see the following javascript on each of my pages in my site:

// ![CDATA[
jQuery(document).ready(function() {lift_successRegisterGC();});
var lift_page = 'F1212351415633FZT';
// ]]

I don't think its necessary for what I'm doing, is there a way to turn
off this feature?

Thanks!

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




Re: [Lift] lift_successRegisterGC()

2009-12-16 Thread David Pollak
On Wed, Dec 16, 2009 at 5:47 AM, Alex Black a...@alexblack.ca wrote:

 I see the following javascript on each of my pages in my site:

 // ![CDATA[
 jQuery(document).ready(function() {lift_successRegisterGC();});
 var lift_page = 'F1212351415633FZT';
 // ]]

 I don't think its necessary for what I'm doing, is there a way to turn
 off this feature?


Are you using any Comet or Ajax or any Lift generated form elements?  If you
are using any of these (anything where Lift is storing a function on the
server-side and presenting the function as a GUID on the client side), then
it is strongly advised that you enable GC.



 Thanks!

 - 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.comliftweb%2bunsubscr...@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: lift_successRegisterGC()

2009-12-16 Thread Alex Black
 Are you using any Comet or Ajax or any Lift generated form elements?  If you
 are using any of these (anything where Lift is storing a function on the
 server-side and presenting the function as a GUID on the client side), then
 it is strongly advised that you enable GC.

We're not using Comet or Lift generated form elements.  We are using a
jQuery plugin to do autocomplete which uses ajax. Can you tell me a
bit more about GC, is it a jQuery thing?

I've turned off auto ajax also:

 // For now, disable all Lift ajax stuff
LiftRules.autoIncludeAjax = session = false

So, I get this error on every page:

Error: lift_successRegisterGC is not defined

and this error on pages that don't use jQuery:

Error: jQuery is not defined









  Thanks!

  - 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.comliftweb%2bunsubscr...@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.




Re: [Lift] Re: How to disable XHTML?

2009-12-16 Thread Indrajit Raychaudhuri
On 15/12/09 6:31 PM, Tim Nelson wrote:
 You need to remove the if guard on the first case match and change the
 second parameter you are passing to Req. The second param is for the
 context. Try this:

 LiftRules.determineContentType = {
case (Full(Req(location :: maps :: testmap :: Nil, _,
 GetRequest)), Full(accept)) =  text/html; charset=utf-8
case _ =  application/xhtml+xml; charset=utf-8
 }

However, in this case LiftRules.determineContentType is ignored 
completely. You could consider adjusting it like so:

LiftRules.determineContentType = {
   case (Full(Req(location :: maps :: testmap :: Nil, _, 
GetRequest)), _) =
   text/html; charset=utf-8

   case (_, Full(accept))
 if LiftRules.useXhtmlMimeType  
accept.toLowerCase.contains(application/xhtml+xml) =
   application/xhtml+xml; charset=utf-8

   case _ = text/html; charset=utf-8
}

Cheers, Indrajit


 Tim

 On Tue, Dec 15, 2009 at 6:09 AM, Tweekd.sztwio...@gmail.com  wrote:
 It still dosn't work :(

 this is path to my html file, which is using google maps api: ./
 location/maps/testmap.html

 i put in my Boot.scala file this code:

 LiftRules.determineContentType = {
 case (Full(Req(location :: maps :: testmap :: Nil,
 html, GetRequest)), Full(accept))
 if LiftRules.useXhtmlMimeType
 accept.toLowerCase.contains(application/xhtml+xml) =
 text/html; charset=utf-8
 case _ =  application/xhtml+xml; charset=utf-8
 }

 i can't disable XHTML in whole projcet becouse then i'm losing
 functionality like jquery datepicker etc.

 Could You tell me what i did wrong?

 Thanks

 On 15 Gru, 10:38, Timothy Perretttimo...@getintheloop.eu  wrote:
 You need to put it in your Boot.scala file.

 determineContentType is of PartialFunction[(Box[Req], Box[String]), String] 
 type - this means that you can match on particular paths:

  LiftRules.determineContentType = {
case (Full(Req(some :: path :: Nil, pdf, GetRequest)), 
 Full(accept))
  if LiftRules.useXhtmlMimeType  
 accept.toLowerCase.contains(application/xhtml+xml) =
  application/xhtml+xml; charset=utf-8
case _ =  text/html; charset=utf-8
  }

 Cheers, Tim

 On 15 Dec 2009, at 07:58, Tweek wrote:

 Thanks for answer Tim.

 I know it will be a nooby question, but how i need to define this
 site, where i don't want XHTML ?

 On 14 Gru, 12:30, Tim Nelsontnell...@gmail.com  wrote:
 You can use LiftRules.determineContentType to do this. Here is a
 sample from my project:

 LiftRules.determineContentType = {
case (_, Full(accept)) if LiftRules.useXhtmlMimeType
 accept.toLowerCase.contains(application/xhtml+xml) =
  application/xhtml+xml; charset=utf-8
case _ =  text/html; charset=utf-8

 }

 Tim

 On Mon, Dec 14, 2009 at 3:59 AM, Tweekd.sztwio...@gmail.com  wrote:
 Hi Guys

 Is it possible todisableXHTMLonly in one html file?

 When i put
 LiftRules.useXhtmlMimeType = false
   in Boot.scala then i'll swich this off in whole project.

 Is any other place to put this line?

 Thanks.

 --

 You received this message because you are subscribed to the Google 
 Groups Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to 
 liftweb+unsubscr...@googlegroups.com.
 For more options, visit this group 
 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 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: Please review a simple app for displaying Flickr pictures

2009-12-16 Thread Indrajit Raychaudhuri
Wonderful, and thanks for the credits!

Cheers, Indrajit

On 15/12/09 11:49 PM, Timothy Perrett wrote:
 Awesome Dave! Thanks for the acknowledgement.

 Cheers, Tim

 On 15 Dec 2009, at 18:07, Dave Briccetti wrote:

 Thanks again for the help. Here are tho talk slides:
 http://www.slideshare.net/dcbriccetti/birdshow-a-lift-app-for-showing-flickr-photos-2720594

 --

 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.




[Lift] Confused about validation

2009-12-16 Thread greekscala
Hello lift people,

lift seems very promising. I am trying to make some tests
and examples because I am new to lift.
I wanted to add some validation to a form element and show
the validation error to the user.
But after little searching I was a little disappointet to see that
there
is no such support, exept when using Mapper. I do not want to use
Mapper.  I want only simple field validation with the errors messages
printed in a feedback panel.

Before lift I was using Wicket. I think they did a good job with the
validators.

I try to understand why lift has not such support? I do not want to
code
everything in my submit method and validate things there.

best regards

--

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_successRegisterGC()

2009-12-16 Thread Alex Black
Hi David, is there a way to turn off the output of this javascript
code?

On Dec 16, 8:51 am, David Pollak feeder.of.the.be...@gmail.com
wrote:
 On Wed, Dec 16, 2009 at 5:47 AM, Alex Black a...@alexblack.ca wrote:
  I see the following javascript on each of my pages in my site:

  // ![CDATA[
  jQuery(document).ready(function() {lift_successRegisterGC();});
  var lift_page = 'F1212351415633FZT';
  // ]]

  I don't think its necessary for what I'm doing, is there a way to turn
  off this feature?

 Are you using any Comet or Ajax or any Lift generated form elements?  If you
 are using any of these (anything where Lift is storing a function on the
 server-side and presenting the function as a GUID on the client side), then
 it is strongly advised that you enable GC.





  Thanks!

  - 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.comliftweb%2bunsubscr...@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.




[Lift] Re: Please review a simple app for displaying Flickr pictures

2009-12-16 Thread Alex Black
Hey Dave, great site, beautiful photography.

If you had time you might add some URL rewriting, so that galleries
had nice urls like:

http://briccettiphoto.com/show/galleries/kenya

- Alex

On Dec 13, 1:44 am, Dave Briccetti da...@davebsoft.com wrote:
 For a lightning talk at Bay Area Scala Enthusiasts at Twitter HQ
 Monday, I will show BirdShow, a Lift application that shows photos
 from Flickr. The current instantiation is a nature photography Web
 site. Would some of you Lift experts be willing to review the code and
 comment on the application? I want this to be an example of good Scala
 and Lift coding. I will gladly acknowledge your help in the
 presentation.

 http://briccettiphoto.comhttp://github.com/dcbriccetti/bird-show

--

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_successRegisterGC()

2009-12-16 Thread Alex Black
I found this in another thread:

LiftRules.enableLiftGC = false


On Dec 16, 12:55 pm, Alex Black a...@alexblack.ca wrote:
 Hi David, is there a way to turn off the output of this javascript
 code?

 On Dec 16, 8:51 am, David Pollak feeder.of.the.be...@gmail.com
 wrote:

  On Wed, Dec 16, 2009 at 5:47 AM, Alex Black a...@alexblack.ca wrote:
   I see the following javascript on each of my pages in my site:

   // ![CDATA[
   jQuery(document).ready(function() {lift_successRegisterGC();});
   var lift_page = 'F1212351415633FZT';
   // ]]

   I don't think its necessary for what I'm doing, is there a way to turn
   off this feature?

  Are you using any Comet or Ajax or any Lift generated form elements?  If you
  are using any of these (anything where Lift is storing a function on the
  server-side and presenting the function as a GUID on the client side), then
  it is strongly advised that you enable GC.

   Thanks!

   - 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.comliftweb%2bunsubscr...@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.




[Lift] Re: Duplicate Keys Created by Schemefier

2009-12-16 Thread Peter Robinett
Fair enough, but isn't this still a non-optimal situation with the
MySQL database driver?

Peter

On Dec 15, 7:23 pm, David Pollak feeder.of.the.be...@gmail.com
wrote:
 On Tue, Dec 15, 2009 at 5:46 PM, Peter Robinett 
 pe...@bubblefoundry.comwrote:





  My tables created by Schemefier have multiple keys for the primary key
  when my Mapper model is declared like so: class myModel extends
  LongKeyedMapper[myModel] with IdPK. There is naturally the primary key
  but there is also a unique key on the column that simply duplicates
  the functionality of the primary key.

  Are other people seeing this? I've only looked on MySQL. This seems to
  be because IdPK adds an id of type MappedLongIndex. Only the
  longIndexColumnType of MySqlDriver has UNIQUE KEY in its definition.
  Unique keys are great but, as I mentioned, if the column is also the
  primary key the index is a duplication. Maybe this is something that
  IdPK can disable when declaring the column? At least with MySQL
  primary keys are guaranteed to be unique and InnoDB tables, which
  Mapper uses, can have issues with long primary keys[1].

  Should this be fixed? Or is the more helpful answer 'Don't use
  MySQL'? ;-)

 I would use MySQL for a production site.

 If IdPK isn't doing what you want, then don't use it, just declare the
 primary key field manually.







  Peter

  [1]:http://dev.mysql.com/doc/refman/5.1/en/innodb-index-types.html

  --

  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com 
  
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.

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




[Lift] Funny behavior of head merging with nested head blocks

2009-12-16 Thread Ross Mellgren
I was diagnosing some incorrect HTML in our application using Lift,  
and I found a strange behavior of head merging (I assume) when you  
emit a head tag into a head tag from the snippet. The code speaks  
better than I do about this:

...
object Dialog extends DispatchSnippet {
 val standardDialogOptions: JsObj = JsObj(
 autoOpen  - false,
 bgiframe  - true,
 modal - true,
 resizable - false
 )

 val dispatch: DispatchIt = {
 case head = renderHead
 case render = render
 }

 def renderHead(ns: NodeSeq): NodeSeq =
 head{ Script { JsCrVar(pxStandardDialogOptions,  
Dialog.standardDialogOptions) } }/head
...
}


 LiftRules.snippetDispatch.append {
...
 case Dialog   = Dialog
...
 }


lift:surround with=default at=content
 head
 titleEmail Editor/title
 lift:Dialog.head /
 /head
/lift:surround


I agree I'm doing the wrong thing here -- the lift:Dialog.head / tag  
rightly should be outside of the head block, or the snippet should not  
emit head. However, the resulting behavior is funny (certainly more  
funny than I'd expect):


html xmlns:lift=http://liftweb.net/; xmlns=http://www.w3.org/1999/xhtml 

head
...
titleEmail Editor/title


script type=text/javascript
// ![CDATA[
var pxStandardDialogOptions = {autoOpen: false, bgiframe: true,  
modal: true, resizable: false};
// ]]
/script


headscript type=text/javascript
// ![CDATA[
var pxStandardDialogOptions = {autoOpen: false, bgiframe: true,  
modal: true, resizable: false};
// ]]
/script/head


/head
...
/html


Ideally I'd like this to just work so that it doesn't matter  
precisely where the snippet is called, though it would be some special  
magic just to work around an erroneous case. But, the behavior that  
does happen seems odd, duplicating the markup inside the head?

Should I file a bug? Just smile and nod?

-Ross




--

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] Funny behavior of head merging with nested head blocks

2009-12-16 Thread David Pollak
On Wed, Dec 16, 2009 at 11:55 AM, Ross Mellgren dri...@gmail.com wrote:

 I was diagnosing some incorrect HTML in our application using Lift,
 and I found a strange behavior of head merging (I assume) when you
 emit a head tag into a head tag from the snippet. The code speaks
 better than I do about this:

 ...
 object Dialog extends DispatchSnippet {
 val standardDialogOptions: JsObj = JsObj(
 autoOpen  - false,
 bgiframe  - true,
 modal - true,
 resizable - false
 )

 val dispatch: DispatchIt = {
 case head = renderHead
 case render = render
 }

 def renderHead(ns: NodeSeq): NodeSeq =
 head{ Script { JsCrVar(pxStandardDialogOptions,
 Dialog.standardDialogOptions) } }/head
 ...
 }


 LiftRules.snippetDispatch.append {
 ...
 case Dialog   = Dialog
 ...
 }


 lift:surround with=default at=content
 head
 titleEmail Editor/title
 lift:Dialog.head /
 /head
 /lift:surround


 I agree I'm doing the wrong thing here -- the lift:Dialog.head / tag
 rightly should be outside of the head block, or the snippet should not
 emit head. However, the resulting behavior is funny (certainly more
 funny than I'd expect):


 html xmlns:lift=http://liftweb.net/; xmlns=http://www.w3.org/1999/xhtml
 
 head
 ...
 titleEmail Editor/title


 script type=text/javascript
 // ![CDATA[
 var pxStandardDialogOptions = {autoOpen: false, bgiframe: true,
 modal: true, resizable: false};
 // ]]
 /script


 headscript type=text/javascript
 // ![CDATA[
 var pxStandardDialogOptions = {autoOpen: false, bgiframe: true,
 modal: true, resizable: false};
 // ]]
 /script/head


 /head
 ...
 /html


 Ideally I'd like this to just work so that it doesn't matter
 precisely where the snippet is called, though it would be some special
 magic just to work around an erroneous case. But, the behavior that
 does happen seems odd, duplicating the markup inside the head?

 Should I file a bug? Just smile and nod?


If we had to recursively check all the head tags for head tags, that
would significantly increase the overhead of the rewrite phase.  I would
suggest using the new Helpers.stripHead() call to remove head tags from
stuff you already know is in a head tag.



 -Ross




 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.





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




Re: [Lift] Re: Duplicate Keys Created by Schemefier

2009-12-16 Thread David Pollak
On Wed, Dec 16, 2009 at 11:07 AM, Peter Robinett pe...@bubblefoundry.comwrote:

 Fair enough, but isn't this still a non-optimal situation with the
 MySQL database driver?


What is your proposed change?



 Peter

 On Dec 15, 7:23 pm, David Pollak feeder.of.the.be...@gmail.com
 wrote:
  On Tue, Dec 15, 2009 at 5:46 PM, Peter Robinett pe...@bubblefoundry.com
 wrote:
 
 
 
 
 
   My tables created by Schemefier have multiple keys for the primary key
   when my Mapper model is declared like so: class myModel extends
   LongKeyedMapper[myModel] with IdPK. There is naturally the primary key
   but there is also a unique key on the column that simply duplicates
   the functionality of the primary key.
 
   Are other people seeing this? I've only looked on MySQL. This seems to
   be because IdPK adds an id of type MappedLongIndex. Only the
   longIndexColumnType of MySqlDriver has UNIQUE KEY in its definition.
   Unique keys are great but, as I mentioned, if the column is also the
   primary key the index is a duplication. Maybe this is something that
   IdPK can disable when declaring the column? At least with MySQL
   primary keys are guaranteed to be unique and InnoDB tables, which
   Mapper uses, can have issues with long primary keys[1].
 
   Should this be fixed? Or is the more helpful answer 'Don't use
   MySQL'? ;-)
 
  I would use MySQL for a production site.
 
  If IdPK isn't doing what you want, then don't use it, just declare the
  primary key field manually.
 
 
 
 
 
 
 
   Peter
 
   [1]:http://dev.mysql.com/doc/refman/5.1/en/innodb-index-types.html
 
   --
 
   You received this message because you are subscribed to the Google
 Groups
   Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send email to
   liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.comliftweb%2bunsubscr...@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.




Re: [Lift] Re: lift_successRegisterGC()

2009-12-16 Thread David Pollak
On Wed, Dec 16, 2009 at 5:56 AM, Alex Black a...@alexblack.ca wrote:

  Are you using any Comet or Ajax or any Lift generated form elements?  If
 you
  are using any of these (anything where Lift is storing a function on the
  server-side and presenting the function as a GUID on the client side),
 then
  it is strongly advised that you enable GC.


To disable Garbage Collection:

LiftRules.enableLiftGC = false

Each GUID that's shipped to the client for form callbacks, Comet callbacks,
Ajax callbacks, JSON callbacks, etc. is associated with a function.  That
function is stored in a session-specific table that maps from GUIDs to
functions.  Without garbage collection, the functions associated with the
GUIDs build up for the duration of a given session.  The can be memory
intensive.  So, we've implemented a mechanism where every 75 seconds (a
tunable parameter), the browser does an Ajax call to the server saying page
 is still live.  All GUIDs associated with that page are kept
around.  If a GUID hasn't been seen on a page in 10 minutes and is not
associated with a Comet component that's still live, then the function is
removed from the GUID mapping table and will ultimately be removed from
memory by the JVM garbage collector.




 We're not using Comet or Lift generated form elements.  We are using a
 jQuery plugin to do autocomplete which uses ajax. Can you tell me a
 bit more about GC, is it a jQuery thing?

 I've turned off auto ajax also:

  // For now, disable all Lift ajax stuff
LiftRules.autoIncludeAjax = session = false

 So, I get this error on every page:

 Error: lift_successRegisterGC is not defined

 and this error on pages that don't use jQuery:

 Error: jQuery is not defined




 
 
 
 
 
   Thanks!
 
   - 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.comliftweb%2bunsubscr...@googlegroups.com
 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.comliftweb%2bunsubscr...@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: lift_successRegisterGC()

2009-12-16 Thread Alex Black
cool, thanks for the info. We're not using those features yet, so
we'll leave this off for now.

On Dec 16, 4:03 pm, David Pollak feeder.of.the.be...@gmail.com
wrote:
 On Wed, Dec 16, 2009 at 5:56 AM, Alex Black a...@alexblack.ca wrote:
   Are you using any Comet or Ajax or any Lift generated form elements?  If
  you
   are using any of these (anything where Lift is storing a function on the
   server-side and presenting the function as a GUID on the client side),
  then
   it is strongly advised that you enable GC.

 To disable Garbage Collection:

 LiftRules.enableLiftGC = false

 Each GUID that's shipped to the client for form callbacks, Comet callbacks,
 Ajax callbacks, JSON callbacks, etc. is associated with a function.  That
 function is stored in a session-specific table that maps from GUIDs to
 functions.  Without garbage collection, the functions associated with the
 GUIDs build up for the duration of a given session.  The can be memory
 intensive.  So, we've implemented a mechanism where every 75 seconds (a
 tunable parameter), the browser does an Ajax call to the server saying page
  is still live.  All GUIDs associated with that page are kept
 around.  If a GUID hasn't been seen on a page in 10 minutes and is not
 associated with a Comet component that's still live, then the function is
 removed from the GUID mapping table and will ultimately be removed from
 memory by the JVM garbage collector.



  We're not using Comet or Lift generated form elements.  We are using a
  jQuery plugin to do autocomplete which uses ajax. Can you tell me a
  bit more about GC, is it a jQuery thing?

  I've turned off auto ajax also:

   // For now, disable all Lift ajax stuff
     LiftRules.autoIncludeAjax = session = false

  So, I get this error on every page:

  Error: lift_successRegisterGC is not defined

  and this error on pages that don't use jQuery:

  Error: jQuery is not defined

Thanks!

- 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.comliftweb%2bunsubscr...@googlegroups.com
  liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.comliftweb%2bunsubscr...@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.




Re: [Lift] Re: lift_successRegisterGC()

2009-12-16 Thread David Pollak
On Wed, Dec 16, 2009 at 1:30 PM, Alex Black a...@alexblack.ca wrote:

 cool, thanks for the info. We're not using those features yet, so
 we'll leave this off for now.


If you're not using those features what part of Lift are you using?

Can you send the raw HTML (via view source in your browser) of a page?  I'm
betting that you're using some GUID - function stuff... it's pretty hard
not to in Lift.



 On Dec 16, 4:03 pm, David Pollak feeder.of.the.be...@gmail.com
 wrote:
  On Wed, Dec 16, 2009 at 5:56 AM, Alex Black a...@alexblack.ca wrote:
Are you using any Comet or Ajax or any Lift generated form elements?
  If
   you
are using any of these (anything where Lift is storing a function on
 the
server-side and presenting the function as a GUID on the client
 side),
   then
it is strongly advised that you enable GC.
 
  To disable Garbage Collection:
 
  LiftRules.enableLiftGC = false
 
  Each GUID that's shipped to the client for form callbacks, Comet
 callbacks,
  Ajax callbacks, JSON callbacks, etc. is associated with a function.  That
  function is stored in a session-specific table that maps from GUIDs to
  functions.  Without garbage collection, the functions associated with the
  GUIDs build up for the duration of a given session.  The can be memory
  intensive.  So, we've implemented a mechanism where every 75 seconds (a
  tunable parameter), the browser does an Ajax call to the server saying
 page
   is still live.  All GUIDs associated with that page are kept
  around.  If a GUID hasn't been seen on a page in 10 minutes and is not
  associated with a Comet component that's still live, then the function is
  removed from the GUID mapping table and will ultimately be removed from
  memory by the JVM garbage collector.
 
 
 
   We're not using Comet or Lift generated form elements.  We are using a
   jQuery plugin to do autocomplete which uses ajax. Can you tell me a
   bit more about GC, is it a jQuery thing?
 
   I've turned off auto ajax also:
 
// For now, disable all Lift ajax stuff
  LiftRules.autoIncludeAjax = session = false
 
   So, I get this error on every page:
 
   Error: lift_successRegisterGC is not defined
 
   and this error on pages that don't use jQuery:
 
   Error: jQuery is not defined
 
 Thanks!
 
 - 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.comliftweb%2bunsubscr...@googlegroups.com
 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com
 
   liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com
 liftweb%252bunsubscr...@googlegroups.comliftweb%25252bunsubscr...@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.comliftweb%2bunsubscr...@googlegroups.com
 liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.comliftweb%2bunsubscr...@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: lift_successRegisterGC()

2009-12-16 Thread Alex Black
Heh.  We're only using basic templates/snippets, and url rewriting/
dispatching.  We're not using lift forms, ajax, comet, mapper etc.  We
just wanted a templating engine that worked well with Scala, and Lift
seems to do that pretty nicely

I'm stubborn - I'm holding to my views that web servers should be as
stateless as possible - using state for callbacks doesn't sit well
with me, yet.

- Alex

On Dec 16, 4:35 pm, David Pollak feeder.of.the.be...@gmail.com
wrote:
 On Wed, Dec 16, 2009 at 1:30 PM, Alex Black a...@alexblack.ca wrote:
  cool, thanks for the info. We're not using those features yet, so
  we'll leave this off for now.

 If you're not using those features what part of Lift are you using?

 Can you send the raw HTML (via view source in your browser) of a page?  I'm
 betting that you're using some GUID - function stuff... it's pretty hard
 not to in Lift.





  On Dec 16, 4:03 pm, David Pollak feeder.of.the.be...@gmail.com
  wrote:
   On Wed, Dec 16, 2009 at 5:56 AM, Alex Black a...@alexblack.ca wrote:
 Are you using any Comet or Ajax or any Lift generated form elements?
   If
you
 are using any of these (anything where Lift is storing a function on
  the
 server-side and presenting the function as a GUID on the client
  side),
then
 it is strongly advised that you enable GC.

   To disable Garbage Collection:

   LiftRules.enableLiftGC = false

   Each GUID that's shipped to the client for form callbacks, Comet
  callbacks,
   Ajax callbacks, JSON callbacks, etc. is associated with a function.  That
   function is stored in a session-specific table that maps from GUIDs to
   functions.  Without garbage collection, the functions associated with the
   GUIDs build up for the duration of a given session.  The can be memory
   intensive.  So, we've implemented a mechanism where every 75 seconds (a
   tunable parameter), the browser does an Ajax call to the server saying
  page
    is still live.  All GUIDs associated with that page are kept
   around.  If a GUID hasn't been seen on a page in 10 minutes and is not
   associated with a Comet component that's still live, then the function is
   removed from the GUID mapping table and will ultimately be removed from
   memory by the JVM garbage collector.

We're not using Comet or Lift generated form elements.  We are using a
jQuery plugin to do autocomplete which uses ajax. Can you tell me a
bit more about GC, is it a jQuery thing?

I've turned off auto ajax also:

 // For now, disable all Lift ajax stuff
   LiftRules.autoIncludeAjax = session = false

So, I get this error on every page:

Error: lift_successRegisterGC is not defined

and this error on pages that don't use jQuery:

Error: jQuery is not defined

  Thanks!

  - 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.comliftweb%2bunsubscr...@googlegroups.com
  liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com

liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@googlegroups.com
  liftweb%252bunsubscr...@googlegroups.comliftweb%25252bunsubscr...@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.comliftweb%2bunsubscr...@googlegroups.com
  liftweb%2bunsubscr...@googlegroups.comliftweb%252bunsubscr...@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.comliftweb%2bunsubscr...@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.

Re: [Lift] Funny behavior of head merging with nested head blocks

2009-12-16 Thread Ross Mellgren

On Dec 16, 2009, at 3:54 PM, David Pollak wrote:
 On Wed, Dec 16, 2009 at 11:55 AM, Ross Mellgren dri...@gmail.com  
 wrote:
 I agree I'm doing the wrong thing here -- the lift:Dialog.head / tag
 rightly should be outside of the head block, or the snippet should not
 emit head. However, the resulting behavior is funny (certainly more
 funny than I'd expect):


 html xmlns:lift=http://liftweb.net/; xmlns=http://www.w3.org/1999/xhtml
 
 head
 ...
 titleEmail Editor/title


 script type=text/javascript
 // ![CDATA[
 var pxStandardDialogOptions = {autoOpen: false, bgiframe: true,
 modal: true, resizable: false};
 // ]]
 /script


 headscript type=text/javascript
 // ![CDATA[
 var pxStandardDialogOptions = {autoOpen: false, bgiframe: true,
 modal: true, resizable: false};
 // ]]
 /script/head


 /head
 ...
 /html


 Ideally I'd like this to just work so that it doesn't matter
 precisely where the snippet is called, though it would be some special
 magic just to work around an erroneous case. But, the behavior that
 does happen seems odd, duplicating the markup inside the head?

 Should I file a bug? Just smile and nod?

 If we had to recursively check all the head tags for head tags,  
 that would significantly increase the overhead of the rewrite  
 phase.  I would suggest using the new Helpers.stripHead() call to  
 remove head tags from stuff you already know is in a head tag.

We're pinned to 1.1-M8 now, and I don't think it has the method, but  
in any case I'm just going to remove the head from the snippet since  
the name of the snippet method implies it should be in the head already.

I was more curious whether the duplication of nodes is something that  
should be fixed or at least investigated. Having my snippet called  
once but chunks of its output appearing in two places surprised (and  
confused) me, it was only when I was creating a reproducible test case  
that I realized my mistake was the nested blocks, since the first  
appearance of the snippet output had no head around it so it  
appeared to be the right thing.

-Ross

--

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] Highlighting even/odd rows in a table

2009-12-16 Thread Stevo
Say for a second that in one of my Snippets I have the following
binding:

def view(xhtml: NodeSeq): NodeSeq =
{
val entries: NodeSeq = Customer.findAll() match
{
case Nil = Text(No customers currently defined)
case customers =
customers.flatMap(customer = bind(cust, 
chooseTemplate
(customer, entry, xhtml),
name - 
Text(emptyIfNull(customer.name.is)),
address - Text
(customer.workAddress.obj.open_!.singleTextLine),
phone - 
Text(emptyIfNull(customer.workPhone.is)),
other - 
Text(emptyIfNull(customer.other.is)),
fax - 
Text(emptyIfNull(customer.workFax.is)),
email - 
Text(emptyIfNull(customer.email.is)),
url - 
Text(emptyIfNull(customer.email.is
}
bind(customer, xhtml, entry - entries)
}

Is there a way that I could apply a style to a complete customer:entry
with the goal of highlighting even/odd rows?

Let me know and best regards to all,


Steve

--

--

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] Highlighting even/odd rows in a table

2009-12-16 Thread Ross Mellgren
You could use customers.zipWithIndex.flatMap({ case (customer, index)  
= ... instead of customers.flatMap(customer = to get the index, and  
then use index % 2 == 0 to see if it's an even row or an odd row. How  
you get that style into your template is up to you -- using an  
attribute bind param would probably be pretty easy, or emitting the  
td straight out of the snippet.

If you need more guidance give a shout and I'll write you up some  
example code.

Note that zipWithIndex only works on List, and it regenerates the  
list, so if you have a bunch of customers on the page and are  
concerned about performance you might want to do something different  
(and less convenient).

-Ross

On Dec 16, 2009, at 5:59 PM, Stevo wrote:

 Say for a second that in one of my Snippets I have the following
 binding:

   def view(xhtml: NodeSeq): NodeSeq =
   {
   val entries: NodeSeq = Customer.findAll() match
   {
   case Nil = Text(No customers currently defined)
   case customers =
   customers.flatMap(customer = bind(cust, 
 chooseTemplate
 (customer, entry, xhtml),
   name - 
 Text(emptyIfNull(customer.name.is)),
   address - Text
 (customer.workAddress.obj.open_!.singleTextLine),
   phone - 
 Text(emptyIfNull(customer.workPhone.is)),
   other - 
 Text(emptyIfNull(customer.other.is)),
   fax - 
 Text(emptyIfNull(customer.workFax.is)),
   email - 
 Text(emptyIfNull(customer.email.is)),
   url - 
 Text(emptyIfNull(customer.email.is
   }
   bind(customer, xhtml, entry - entries)
   }

 Is there a way that I could apply a style to a complete customer:entry
 with the goal of highlighting even/odd rows?

 Let me know and best regards to all,


 Steve

 --

 --

 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] Highlighting even/odd rows in a table

2009-12-16 Thread Alex Boisvert
Or delegate the work to the browser using jQuery + CSS
http://docs.jquery.com/Selectors/odd

alex


On Wed, Dec 16, 2009 at 4:04 PM, Ross Mellgren dri...@gmail.com wrote:

 You could use customers.zipWithIndex.flatMap({ case (customer, index)
 = ... instead of customers.flatMap(customer = to get the index, and
 then use index % 2 == 0 to see if it's an even row or an odd row. How
 you get that style into your template is up to you -- using an
 attribute bind param would probably be pretty easy, or emitting the
 td straight out of the snippet.

 If you need more guidance give a shout and I'll write you up some
 example code.

 Note that zipWithIndex only works on List, and it regenerates the
 list, so if you have a bunch of customers on the page and are
 concerned about performance you might want to do something different
 (and less convenient).

 -Ross

 On Dec 16, 2009, at 5:59 PM, Stevo wrote:

  Say for a second that in one of my Snippets I have the following
  binding:
 
def view(xhtml: NodeSeq): NodeSeq =
{
val entries: NodeSeq = Customer.findAll() match
{
case Nil = Text(No customers currently defined)
case customers =
customers.flatMap(customer = bind(cust,
 chooseTemplate
  (customer, entry, xhtml),
name - Text(emptyIfNull(
 customer.name.is)),
address - Text
  (customer.workAddress.obj.open_!.singleTextLine),
phone - Text(emptyIfNull(
 customer.workPhone.is)),
other - Text(emptyIfNull(
 customer.other.is)),
fax - Text(emptyIfNull(
 customer.workFax.is)),
email - Text(emptyIfNull(
 customer.email.is)),
url - Text(emptyIfNull(
 customer.email.is
}
bind(customer, xhtml, entry - entries)
}
 
  Is there a way that I could apply a style to a complete customer:entry
  with the goal of highlighting even/odd rows?
 
  Let me know and best regards to all,
 
 
  Steve
 
  --
 
  --
 
  You received this message because you are subscribed to the Google
  Groups Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
  .
  For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en
  .
 
 

 --

 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.comliftweb%2bunsubscr...@googlegroups.com
 .
 For more options, visit this group at
 http://groups.google.com/group/liftweb?hl=en.




--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to lift...@googlegroups.com.
To unsubscribe from this group, send email to 
liftweb+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.




Re: [Lift] Highlighting even/odd rows in a table

2009-12-16 Thread Ross Mellgren
Oh, speaking of jquery, tablesorter also has a zebra plugin that does this, 
so if you're tablesorter you can use that also.

-Ross

On Dec 16, 2009, at 9:01 PM, Alex Boisvert wrote:

 Or delegate the work to the browser using jQuery + CSS
 http://docs.jquery.com/Selectors/odd
 
 alex
 
 
 On Wed, Dec 16, 2009 at 4:04 PM, Ross Mellgren dri...@gmail.com wrote:
 You could use customers.zipWithIndex.flatMap({ case (customer, index)
 = ... instead of customers.flatMap(customer = to get the index, and
 then use index % 2 == 0 to see if it's an even row or an odd row. How
 you get that style into your template is up to you -- using an
 attribute bind param would probably be pretty easy, or emitting the
 td straight out of the snippet.
 
 If you need more guidance give a shout and I'll write you up some
 example code.
 
 Note that zipWithIndex only works on List, and it regenerates the
 list, so if you have a bunch of customers on the page and are
 concerned about performance you might want to do something different
 (and less convenient).
 
 -Ross
 
 On Dec 16, 2009, at 5:59 PM, Stevo wrote:
 
  Say for a second that in one of my Snippets I have the following
  binding:
 
def view(xhtml: NodeSeq): NodeSeq =
{
val entries: NodeSeq = Customer.findAll() match
{
case Nil = Text(No customers currently defined)
case customers =
customers.flatMap(customer = bind(cust, 
  chooseTemplate
  (customer, entry, xhtml),
name - 
  Text(emptyIfNull(customer.name.is)),
address - Text
  (customer.workAddress.obj.open_!.singleTextLine),
phone - 
  Text(emptyIfNull(customer.workPhone.is)),
other - 
  Text(emptyIfNull(customer.other.is)),
fax - 
  Text(emptyIfNull(customer.workFax.is)),
email - 
  Text(emptyIfNull(customer.email.is)),
url - 
  Text(emptyIfNull(customer.email.is
}
bind(customer, xhtml, entry - entries)
}
 
  Is there a way that I could apply a style to a complete customer:entry
  with the goal of highlighting even/odd rows?
 
  Let me know and best regards to all,
 
 
  Steve
 
  --
 
  --
 
  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.

--

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] Scala to JavaScript DSL ...

2009-12-16 Thread Naftoli Gugenheim
I'm thinking of an approach to writing a DSL with a much cleaner syntax. I'll 
try to put something together.

-
Marius Danciumarius.dan...@gmail.com wrote:

All,

I just want to see if there is any interest in the approach discussed here.
As you know Lift has some interesting support for building JavaScript
constructs from Scala code usig JsExp, JsCmd etc classes. I used quite a lot
this support and it's great but if your JS code that you want to send down
to the browser (say as an Ajax or Comet partial update response) gets a bit
more complicated then constructing the JS fragment leads IMO to some
cumbersome Scala code. I found myselft in quite a few situation to use JsRaw
to write the JavaScript fragment in order for the code reader to understand
what JavaScript code will be generated. But of course with JsRaw we put
everything into a String so I'm not a big fan of this approach. So I started
to define a JavaScript like DSL that IMO is closer to JavaScript form.
Attached is a source code smaple of how this looks like, so for instance we
can have something like:


val js = JsFunc('myFunc, 'param1, 'param2) {
JsIf('param1 __ 30) {
Var('home) := Wrap(234 __- 3) __/ 2 `;`
Var('someArray) := JsArray(1, 2, 3, 4, 5) `;`
'myFunc(1, 2, do it, 'home) `;`
$(#myID)  'attr(value, 123) `;`
  } ~
  JsForEach(Var('i) in 'someArray) {
'console  'log(Hi there  __+ 'i) `;`
  } ~
  JsAnonFunc('arg1, 'arg2) {
   'alert(Anonymous function  __+ 'arg1 __+ 'arg2)
  }(1, 2) `;`
}

println(js.toJs)

this yields the following JavaScript code:


function myFunc( param1, param2 ) {
if (param1  30) {
var home = ( 234 - 3 ) / 2;
var someArray = [ 1, 2, 3, 4, 5 ];
myFunc(1, 2, do it, home);
$(#myID).attr(value, 123);
}
for (var i in someArray) {
console.log(Hi there  + i);
}
function ( arg1, arg2 ) {
alert(Anonymous function  + arg1 + arg2)
}(1, 2);
}


... ok I just droped nonsense code in there for exemplification. A few
words:

1. JsIf, JsForEach describe JavaScript if and for(each) statements
2. Functions like __, __, ... __+, __- are function that alows definition
of boolean and/or algebraic expressions.
3. Wrap just wraps an expression into ()
4. Var defined a variable
5 := defines an assignment
6. JsFunc declares a JS function
7. JsAnonFunc declares an anonymous function
8. 'myFunc(1, 2, do it, 'home)  is simply a javascript function invocation
by providing 4 parameter.
9. ~ is just a function that chains statements that don;t necessarily end in
;


Do you think that something like this would be usable in Lift?

Br's,
Marius

--

You received this message because you are subscribed to the Google Groups 
Lift group.
To post to this group, send email to 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: Latest API Documentation

2009-12-16 Thread Vesa
I would also appreciate aggregated docs. It would be great to have
these at least for the M-releases..

- Vesa

On 7 marras, 05:47, aw anth...@whitford.com wrote:
 OK, so I can go tohttp://scala-tools.org/mvnsites/liftweb-1.1-7/
 but I am not finding a comprehensive ScalaDoc similar to what is
 available here:http://scala-tools.org/scaladocs/liftweb/1.0/

 It is hard (and SLOW) for me to figure out which component a class/
 object might reside, and find its corresponding ScalaDoc...  Or am I
 not seeing it?

--

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: Scala to JavaScript DSL ...

2009-12-16 Thread Marius
Let me know when you have something.

Br's,
Marius

On Dec 17, 8:58 am, Naftoli Gugenheim naftoli...@gmail.com wrote:
 I'm thinking of an approach to writing a DSL with a much cleaner syntax. I'll 
 try to put something together.

 -

 Marius Danciumarius.dan...@gmail.com wrote:

 All,

 I just want to see if there is any interest in the approach discussed here.
 As you know Lift has some interesting support for building JavaScript
 constructs from Scala code usig JsExp, JsCmd etc classes. I used quite a lot
 this support and it's great but if your JS code that you want to send down
 to the browser (say as an Ajax or Comet partial update response) gets a bit
 more complicated then constructing the JS fragment leads IMO to some
 cumbersome Scala code. I found myselft in quite a few situation to use JsRaw
 to write the JavaScript fragment in order for the code reader to understand
 what JavaScript code will be generated. But of course with JsRaw we put
 everything into a String so I'm not a big fan of this approach. So I started
 to define a JavaScript like DSL that IMO is closer to JavaScript form.
 Attached is a source code smaple of how this looks like, so for instance we
 can have something like:

 val js = JsFunc('myFunc, 'param1, 'param2) {
     JsIf('param1 __ 30) {
         Var('home) := Wrap(234 __- 3) __/ 2 `;`
         Var('someArray) := JsArray(1, 2, 3, 4, 5) `;`
         'myFunc(1, 2, do it, 'home) `;`
         $(#myID)  'attr(value, 123) `;`
       } ~
       JsForEach(Var('i) in 'someArray) {
         'console  'log(Hi there  __+ 'i) `;`
       } ~
       JsAnonFunc('arg1, 'arg2) {
        'alert(Anonymous function  __+ 'arg1 __+ 'arg2)
       }(1, 2) `;`
     }

     println(js.toJs)

 this yields the following JavaScript code:

 function myFunc( param1, param2 ) {
 if (param1  30) {
 var home = ( 234 - 3 ) / 2;
 var someArray = [ 1, 2, 3, 4, 5 ];
 myFunc(1, 2, do it, home);
 $(#myID).attr(value, 123);}

 for (var i in someArray) {
 console.log(Hi there  + i);}

 function ( arg1, arg2 ) {
 alert(Anonymous function  + arg1 + arg2)

 }(1, 2);
 }

 ... ok I just droped nonsense code in there for exemplification. A few
 words:

 1. JsIf, JsForEach describe JavaScript if and for(each) statements
 2. Functions like __, __, ... __+, __- are function that alows definition
 of boolean and/or algebraic expressions.
 3. Wrap just wraps an expression into ()
 4. Var defined a variable
 5 := defines an assignment
 6. JsFunc declares a JS function
 7. JsAnonFunc declares an anonymous function
 8. 'myFunc(1, 2, do it, 'home)  is simply a javascript function invocation
 by providing 4 parameter.
 9. ~ is just a function that chains statements that don;t necessarily end in
 ;

 Do you think that something like this would be usable in Lift?

 Br's,
 Marius

 --

 You received this message because you are subscribed to the Google Groups 
 Lift group.
 To post to this group, send email to 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.