[Lift] Re: How to use prepareStatement to select *** from DB (two db vender)?

2010-01-21 Thread Neil.Lv

  I have added the demo code on the Github now.
  ( Mabye it's a bug with DB.runQuery and DB.use in the two db
vender )

  Here is the address:
  http://github.com/anim510/two_db_demo

  Thanks very much!

Cheers,
  Neil

On Jan 21, 11:26 am, Neil.Lv anim...@gmail.com wrote:
   My email is :   anim...@gmail.com

 On Jan 21, 11:17 am, Neil.Lv anim...@gmail.com wrote:

  Mabye it's a bug with DB.runQuery and DB.use in the two db vender 

  Two question: (problem)

  1: I don't know why the HelloWorld snippet code will be execute 2
  times in this code. (See the HelloWorld.scala file.)
  2: The dbDefaultConnectionIdentifier method in the Model that it works
  fine when using Mapper's method such as ModelName.findAll(),
  it doesn't work when using DB.runQuery and DB.use(...) --- (Maybe it
  can't find the default db identifier)

  The question 2 I test it many times that found this problem.

  In the test app , the Hot.getHots2 and Hot.getHots3 method can't work.

  I comment the code now in the HelloWorld.scala file, you can try it.

  

    I can push the code on the github, and get this errors fatal:
  unable to fork

    So If anyone know what's wrong with it and I can send the demo.tar
  file through the email.

    Thanks very much!

  

  Cheers,
    Neil

  On Jan 21, 1:56 am, Neil.Lv anim...@gmail.com wrote:

     The DB.runQuery can works now, but the DB.prepareStatement also
   cant' work.

     Here is the test app address:
    http://github.com/anim510/two_db_demo

   Cheers,
     Neil

   On Jan 21, 1:16 am, Neil.Lv anim...@gmail.com wrote:

   Thank you very much,

   But it doesn't work yet, maybe because of using two db connections.

   I'll test it later again.

On Jan 21, 12:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:

 Neil.Lv anim...@gmail.com writes:
  Hi all,

    I use two db connections in my app, and I want to use
  DB.prepareStatement to select
  the records from the second db.

    It failed, Here is the code:
  ###
    def getHotByTid(id : Long) =
      DB.use(bootstrap.liftweb.TwoDB) {
        conn =
       DB.prepareStatement(SELECT * FROM hots WHERE id=? , conn) {
               stmt =
                       stmt.setLong(1, id)
  Log.info(stmt : + stmt)   // The information is correctly now, but
  after call executeUpdate method
                       stmt.executeUpdate()
        }
     }

 Not sure what your problem is really, but I think you should use
 DB.runQuery to execute a select statement

 Ie

   val (_,result) = DB.runQuery(SELECT COUNT(*), contract_length  
 FROM +
                     vehicles_current v +
                     WHERE v.account_id=? +
                     GROUP BY contract_length +
                     ORDER BY contract_length,
                     List(42))

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




[Lift] Re: What happens between 7000 and 8000 requests?

2010-01-21 Thread Stefan Koenig
First of all thanks for the replies. Your comments made a lot of
sense, so I tested again using a cookie jsessionid and voilà no
problems anymore even running more than 100,000 requests in a row now.
Also the failed requests are gone.

Thanks again.
Stefan Koenig



On Jan 21, 5:16 am, Derek Williams de...@nebvin.ca wrote:
 Okay, I tried it out. jsessionid is sometimes 12 or 13 characters long
 which is why the document length is changing. Those failures due to
 length are probably safe to ignore.

 On Wed, Jan 20, 2010 at 6:00 PM, Derek Williams de...@nebvin.ca wrote:
  I could be wrong here, but I think the failed requests might be due to the
  jsessionid that jetty adds onto the links, they may be different sizes. I am
  away from my computer right now and can't test it though.

 --
 Derek Williams
-- 
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: What happens between 7000 and 8000 requests?

2010-01-21 Thread David Pollak
On Thu, Jan 21, 2010 at 6:25 AM, Stefan Koenig koeni...@gmail.com wrote:

 First of all thanks for the replies. Your comments made a lot of
 sense, so I tested again using a cookie jsessionid and voilà no
 problems anymore even running more than 100,000 requests in a row now.
 Also the failed requests are gone.


And is Lift still much faster?



 Thanks again.
 Stefan Koenig



 On Jan 21, 5:16 am, Derek Williams de...@nebvin.ca wrote:
  Okay, I tried it out. jsessionid is sometimes 12 or 13 characters long
  which is why the document length is changing. Those failures due to
  length are probably safe to ignore.
 
  On Wed, Jan 20, 2010 at 6:00 PM, Derek Williams de...@nebvin.ca wrote:
   I could be wrong here, but I think the failed requests might be due to
 the
   jsessionid that jetty adds onto the links, they may be different sizes.
 I am
   away from my computer right now and can't test it though.
 
  --
  Derek Williams

 --
 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: How to use prepareStatement to select *** from DB (two db vender)?

2010-01-21 Thread David Pollak
What is wrong with:

DB.use(FirstDB) {
  firstConnection =
  DB.use(SecondDB) {
  secondConnection =

  // do transactional query between two DBs here
}
}

Note that DB.use nests such that the transaction will only be committed when
the last DB.use block for a given ConnectionIdentifier is exited.


On Thu, Jan 21, 2010 at 3:17 AM, Neil.Lv anim...@gmail.com wrote:


  I have added the demo code on the Github now.
  ( Mabye it's a bug with DB.runQuery and DB.use in the two db
 vender )

  Here is the address:
   http://github.com/anim510/two_db_demo

   Thanks very much!

 Cheers,
  Neil

 On Jan 21, 11:26 am, Neil.Lv anim...@gmail.com wrote:
My email is :   anim...@gmail.com
 
  On Jan 21, 11:17 am, Neil.Lv anim...@gmail.com wrote:
 
   Mabye it's a bug with DB.runQuery and DB.use in the two db vender 
 
   Two question: (problem)
 
   1: I don't know why the HelloWorld snippet code will be execute 2
   times in this code. (See the HelloWorld.scala file.)
   2: The dbDefaultConnectionIdentifier method in the Model that it works
   fine when using Mapper's method such as ModelName.findAll(),
   it doesn't work when using DB.runQuery and DB.use(...) --- (Maybe it
   can't find the default db identifier)
 
   The question 2 I test it many times that found this problem.
 
   In the test app , the Hot.getHots2 and Hot.getHots3 method can't work.
 
   I comment the code now in the HelloWorld.scala file, you can try it.
 
   
 
 I can push the code on the github, and get this errors fatal:
   unable to fork
 
 So If anyone know what's wrong with it and I can send the demo.tar
   file through the email.
 
 Thanks very much!
 
   
 
   Cheers,
 Neil
 
   On Jan 21, 1:56 am, Neil.Lv anim...@gmail.com wrote:
 
  The DB.runQuery can works now, but the DB.prepareStatement also
cant' work.
 
  Here is the test app address:
 http://github.com/anim510/two_db_demo
 
Cheers,
  Neil
 
On Jan 21, 1:16 am, Neil.Lv anim...@gmail.com wrote:
 
Thank you very much,
 
But it doesn't work yet, maybe because of using two db
 connections.
 
I'll test it later again.
 
 On Jan 21, 12:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:
 
  Neil.Lv anim...@gmail.com writes:
   Hi all,
 
 I use two db connections in my app, and I want to use
   DB.prepareStatement to select
   the records from the second db.
 
 It failed, Here is the code:
   ###
 def getHotByTid(id : Long) =
   DB.use(bootstrap.liftweb.TwoDB) {
 conn =
DB.prepareStatement(SELECT * FROM hots WHERE id=? ,
 conn) {
stmt =
stmt.setLong(1, id)
   Log.info(stmt : + stmt)   // The information is correctly
 now, but
   after call executeUpdate method
stmt.executeUpdate()
 }
  }
 
  Not sure what your problem is really, but I think you should use
  DB.runQuery to execute a select statement
 
  Ie
 
val (_,result) = DB.runQuery(SELECT COUNT(*), contract_length
  FROM +
  vehicles_current v +
  WHERE v.account_id=? +
  GROUP BY contract_length +
  ORDER BY contract_length,
  List(42))
 
  /Jeppe

 --
 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.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: 1.1-M8 to 2.0-M1 behavior change

2010-01-21 Thread David Pollak
On Thu, Jan 21, 2010 at 1:24 AM, aw anth...@whitford.com wrote:

 I think I discovered that my issue is related to the fact that the
 code is part of a CometActor/CometListener, and it sounds like S isn't
 fully functional from this perspective...  My clue was the
 inStatefulScope_? method documentation.

 I do think I managed to work around my specific issue, but I don't
 fully understand this, and I'm not sure if this change in behavior was
 intentional.


There is no HTTP request within the scope of a CometActor.  This is the
defined behavior.  If you were somehow able to access a Req or other part of
an HTTP request within the CometActor scope in a prior version of Lift, this
was a bug.



 --
 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: How to use prepareStatement to select *** from DB (two db vender)?

2010-01-21 Thread Neil.Lv

  The users table in the OneDB, and the hots table in the TwoDB, they
are separated!

  I have changed the method that like this:
###
  # I specify the TwoDB for hots table.
  override def dbDefaultConnectionIdentifier = bootstrap.liftweb.TwoDB


  def getHots3(id : Long) = {
DB.use(bootstrap.liftweb.OneDB) {
  firstConn =
 DB.use(bootstrap.liftweb.TwoDB) {
conn =
 DB.prepareStatement(SELECT * FROM hots WHERE id?, conn) {
 stmt =
 stmt.setLong(1, id)
 stmt.executeUpdate()
}
}
}
  }
###

  But it doesn't work.

  Thanks very much!  :)

Cheers,
  Neil


On Jan 22, 12:49 am, David Pollak feeder.of.the.be...@gmail.com
wrote:
 What is wrong with:

 DB.use(FirstDB) {
   firstConnection =
   DB.use(SecondDB) {
   secondConnection =

   // do transactional query between two DBs here

 }
 }

 Note that DB.use nests such that the transaction will only be committed when
 the last DB.use block for a given ConnectionIdentifier is exited.



 On Thu, Jan 21, 2010 at 3:17 AM, Neil.Lv anim...@gmail.com wrote:

   I have added the demo code on the Github now.
   ( Mabye it's a bug with DB.runQuery and DB.use in the two db
  vender )

   Here is the address:
   http://github.com/anim510/two_db_demo

    Thanks very much!

  Cheers,
   Neil

  On Jan 21, 11:26 am, Neil.Lv anim...@gmail.com wrote:
     My email is :   anim...@gmail.com

   On Jan 21, 11:17 am, Neil.Lv anim...@gmail.com wrote:

Mabye it's a bug with DB.runQuery and DB.use in the two db vender 

Two question: (problem)

1: I don't know why the HelloWorld snippet code will be execute 2
times in this code. (See the HelloWorld.scala file.)
2: The dbDefaultConnectionIdentifier method in the Model that it works
fine when using Mapper's method such as ModelName.findAll(),
it doesn't work when using DB.runQuery and DB.use(...) --- (Maybe it
can't find the default db identifier)

The question 2 I test it many times that found this problem.

In the test app , the Hot.getHots2 and Hot.getHots3 method can't work.

I comment the code now in the HelloWorld.scala file, you can try it.



  I can push the code on the github, and get this errors fatal:
unable to fork

  So If anyone know what's wrong with it and I can send the demo.tar
file through the email.

  Thanks very much!



Cheers,
  Neil

On Jan 21, 1:56 am, Neil.Lv anim...@gmail.com wrote:

   The DB.runQuery can works now, but the DB.prepareStatement also
 cant' work.

   Here is the test app address:
  http://github.com/anim510/two_db_demo

 Cheers,
   Neil

 On Jan 21, 1:16 am, Neil.Lv anim...@gmail.com wrote:

     Thank you very much,

     But it doesn't work yet, maybe because of using two db
  connections.

     I'll test it later again.

  On Jan 21, 12:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:

   Neil.Lv anim...@gmail.com writes:
Hi all,

  I use two db connections in my app, and I want to use
DB.prepareStatement to select
the records from the second db.

  It failed, Here is the code:
###
  def getHotByTid(id : Long) =
    DB.use(bootstrap.liftweb.TwoDB) {
      conn =
     DB.prepareStatement(SELECT * FROM hots WHERE id=? ,
  conn) {
             stmt =
                     stmt.setLong(1, id)
Log.info(stmt : + stmt)   // The information is correctly
  now, but
after call executeUpdate method
                     stmt.executeUpdate()
      }
   }

   Not sure what your problem is really, but I think you should use
   DB.runQuery to execute a select statement

   Ie

     val (_,result) = DB.runQuery(SELECT COUNT(*), contract_length
   FROM +
                       vehicles_current v +
                       WHERE v.account_id=? +
                       GROUP BY contract_length +
                       ORDER BY contract_length,
                       List(42))

   /Jeppe

  --
  You received this message because you are subscribed to the Google Groups
  Lift group.
  To post to this group, send email to lift...@googlegroups.com.
  To unsubscribe from this group, send email to
  liftweb+unsubscr...@googlegroups.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 

Re: [Lift] Re: How to use prepareStatement to select *** from DB (two db vender)?

2010-01-21 Thread Ross Mellgren
It doesn't work is not sufficient to diagnose. What behavior did you get, and 
what were you expecting? Were there any errors, log messages, exceptions, etc? 
If so, please copy them. Finally, if you have a reproducible test case please 
post it to github. I note earlier in the thread that you were fiddling with 
github, so if an older example is there, please make sure it's up to date with 
the most recent code.

Thanks,
-Ross

On Jan 21, 2010, at 12:29 PM, Neil.Lv wrote:

 
  The users table in the OneDB, and the hots table in the TwoDB, they
 are separated!
 
  I have changed the method that like this:
 ###
  # I specify the TwoDB for hots table.
  override def dbDefaultConnectionIdentifier = bootstrap.liftweb.TwoDB
 
 
  def getHots3(id : Long) = {
DB.use(bootstrap.liftweb.OneDB) {
  firstConn =
DB.use(bootstrap.liftweb.TwoDB) {
   conn =
DB.prepareStatement(SELECT * FROM hots WHERE id?, conn) {
stmt =
stmt.setLong(1, id)
stmt.executeUpdate()
   }
   }
}
  }
 ###
 
  But it doesn't work.
 
  Thanks very much!  :)
 
 Cheers,
  Neil
 
 
 On Jan 22, 12:49 am, David Pollak feeder.of.the.be...@gmail.com
 wrote:
 What is wrong with:
 
 DB.use(FirstDB) {
   firstConnection =
   DB.use(SecondDB) {
   secondConnection =
 
   // do transactional query between two DBs here
 
 }
 }
 
 Note that DB.use nests such that the transaction will only be committed when
 the last DB.use block for a given ConnectionIdentifier is exited.
 
 
 
 On Thu, Jan 21, 2010 at 3:17 AM, Neil.Lv anim...@gmail.com wrote:
 
  I have added the demo code on the Github now.
  ( Mabye it's a bug with DB.runQuery and DB.use in the two db
 vender )
 
  Here is the address:
  http://github.com/anim510/two_db_demo
 
   Thanks very much!
 
 Cheers,
  Neil
 
 On Jan 21, 11:26 am, Neil.Lv anim...@gmail.com wrote:
   My email is :   anim...@gmail.com
 
 On Jan 21, 11:17 am, Neil.Lv anim...@gmail.com wrote:
 
 Mabye it's a bug with DB.runQuery and DB.use in the two db vender 
 
 Two question: (problem)
 
 1: I don't know why the HelloWorld snippet code will be execute 2
 times in this code. (See the HelloWorld.scala file.)
 2: The dbDefaultConnectionIdentifier method in the Model that it works
 fine when using Mapper's method such as ModelName.findAll(),
 it doesn't work when using DB.runQuery and DB.use(...) --- (Maybe it
 can't find the default db identifier)
 
 The question 2 I test it many times that found this problem.
 
 In the test app , the Hot.getHots2 and Hot.getHots3 method can't work.
 
 I comment the code now in the HelloWorld.scala file, you can try it.
 
 
 
   I can push the code on the github, and get this errors fatal:
 unable to fork
 
   So If anyone know what's wrong with it and I can send the demo.tar
 file through the email.
 
   Thanks very much!
 
 
 
 Cheers,
   Neil
 
 On Jan 21, 1:56 am, Neil.Lv anim...@gmail.com wrote:
 
   The DB.runQuery can works now, but the DB.prepareStatement also
 cant' work.
 
   Here is the test app address:
  http://github.com/anim510/two_db_demo
 
 Cheers,
   Neil
 
 On Jan 21, 1:16 am, Neil.Lv anim...@gmail.com wrote:
 
Thank you very much,
 
But it doesn't work yet, maybe because of using two db
 connections.
 
I'll test it later again.
 
 On Jan 21, 12:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:
 
 Neil.Lv anim...@gmail.com writes:
 Hi all,
 
   I use two db connections in my app, and I want to use
 DB.prepareStatement to select
 the records from the second db.
 
   It failed, Here is the code:
 ###
   def getHotByTid(id : Long) =
 DB.use(bootstrap.liftweb.TwoDB) {
   conn =
  DB.prepareStatement(SELECT * FROM hots WHERE id=? ,
 conn) {
  stmt =
  stmt.setLong(1, id)
 Log.info(stmt : + stmt)   // The information is correctly
 now, but
 after call executeUpdate method
  stmt.executeUpdate()
   }
}
 
 Not sure what your problem is really, but I think you should use
 DB.runQuery to execute a select statement
 
 Ie
 
   val (_,result) = DB.runQuery(SELECT COUNT(*), contract_length
  FROM +
 vehicles_current v +
 WHERE v.account_id=? +
 GROUP BY contract_length +
 ORDER BY contract_length,
 List(42))
 
 /Jeppe
 
 --
 You received this message because you are subscribed to the Google Groups
 Lift group.
 To post to this group, send email to lift...@googlegroups.com.
 To unsubscribe from this group, send email to
 liftweb+unsubscr...@googlegroups.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 

[Lift] Re: Embedding comet actor in ModalDialog

2010-01-21 Thread Marius
Right ... building progress bars should be quite easy but just have
your page contain the comet actor.So roughly the steps would be:

1. Include your comet in the page. In this state it renders nothing
visible
2. hen you open the dialog, send an ajax response
3. From your ajax scal function send a message to your comet actor to
activate the progress
4. From your comet actor I assume you would know the progress of an
operation and you'd send progress bar updates using partialUpdate.

... you got the idea.

I'm doing something similar with multiple progress bars monitoring the
progress of some backgroud server processes using comet but not really
inside of a dialog. Putting them inside a modal dialog would be very
easy.

Br's,
Marius

On Jan 21, 9:54 am, ced docpom...@googlemail.com wrote:
 @David: Thanks. Now the approach is clear.

  Is that your use-case ?  so see async intems coming from server
  only when the dialog is opened?

 @Marius: Yes, it is. I'd like to display a progressbar in the dialog.
 It seemed to me quite natural to deliver it (the comet component)
 along with the dialog, but as I now know that this is not possible,
 it's really no problem to have it prepared in the page and bring it to
 life when needed, i.e. make it visible. Another solution would be to
 redirect to a whole new page with the progressbar on it, but I wanted
 to look it more like a desktop application.

 Thanks,
 Chris

 On 20 Jan., 23:22, Marius marius.dan...@gmail.com wrote:

  I really don't see the need for such use-case. I mean if one wants to
  see async stuff in a dialog only when the dialog is opened this could
  be easily done via Ajax requests that will activate/deactivate
  async messages to client by sending from the ajax functions messages
  to the comet actor.

  Is that your use-case ?  so see async intems coming from server
  only when the dialog is opened?

  Br's,
  Marius

  On Jan 20, 11:00 pm, ced docpom...@googlemail.com wrote:

   Hi all,

   I'm trying to create some sort of progress notification for a long
   lasting request. The idea is to answer an ajax request with a
   JqJsCmds.ModalDialog which embeds a comet actor like so:

   ajaxButton(Start process, () = ModalDialog(divdivProgress/
   divlift:comet type=Progress//div))

   Unfortunately this doesn't work, the dialog doesn't get displayed.
   Embedding a normal snippet works just fine though.

   The code returned in the response to the button click seems ok also.

   As a workaround I place the comet actor in the page enclosed in a
   hidden div id=progress-actorlift:comet type=Progress//div.
   Then I return the ModalDialog(divdivProgress/divdiv id=actor-
   goes-here/div) along with some JS-code that takes the progress-
   actor div, moves it into the actor-goes-here div and makes it
   visible.

   Does anyone tried something similar? Any help is appreciated...

   Chris
-- 
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: Memory behavior in Jetty with CometActor - 25MB of scala.xml.Text!

2010-01-21 Thread David Pollak
On Wed, Jan 20, 2010 at 9:28 PM, mark chance mark.cha...@gmail.com wrote:

 I did post the project to drop.io - http://drop.io/memtest.


The project does not build:

  Path to dependency:
  1) com.peopledesigned:memtest:war:1.0-SNAPSHOT
  2) org.jfree:jcommon:jar:1.0.16


Looking at your code, each of the functions created/passed as part of the
SHtml.ajaxCall(), etc. calls are retained for the duration of the session.
Lift garbage collects these references if there's not seen on a page for 10
minutes.  However, if the GUIDs are created within the scope of a
CometActor, the function is retained until the CometActor is released (in
your case, for the length of the session).

There are a couple of ways to deal with this:

   - Create a single SHtml.ajaxCall instance as part of the CometActor
   (rather than on each partialUpdate).
   - Use the CometActor's built-in JSON handler to send a message from the
   browser to the server.  See CometActor.handleJson()

The latter is the best bet for handling rich interactions with the
CometActor from the client without creating lots and lots of functions.




 On Wed, Jan 20, 2010 at 10:06 PM, David Pollak 
 feeder.of.the.be...@gmail.com wrote:



 On Wed, Jan 20, 2010 at 9:03 PM, Java1Guy mark.cha...@gmail.com wrote:

 Ok - i've left my Jetty server up and running with one page open...
 The good news is Jetty hasn't crapped out.  It had 500MB of heap space
 used before a forced GC brought it down to 250MB.  The heap dump is
 interesting: http://twitpic.com/z0xnx almost 25MB of Text objects used
 by the almost 80K displayList partial function objects in my
 CometActor.
 To me that sounds like a lot of functions!


 Without your actual code, there's little we can do.



 Thanks in advance if you can have a look.
 Mark

 On Jan 18, 6:36 pm, Java1Guy mark.cha...@gmail.com wrote:
  Thanks for the response.  I have created a small project here:
 http://drop.io/memtest(btw http://drop.io/memtest%28btw - the zip file
 is so big because there are
  3 heap dumps - before that it was only 21k!) which i believe does
  exhibit the problem.  One comet actor page which gets updated every 20
  sec. via tick.
  So to run this, I've built the war file and installed it into a Jetty
  6.1.22 installation.  The file etc/memtest.xml goes in the jetty/
  contexts dir.
  I open my Firefox browser to the only page it shows and just leave it
  open for about four hours now - so the session should still be active,
  FWIW.
  An additional thing I'm noticing now is that despite not much else
  happening in the app, the comet responses are taking just under 20
  sec.  That seems huge.
  There are two things I notice in the heap dumps: one is the large
  number of xml.Text objects and their Strings, but second the 5800
  anonFuncs from the DatastreamActor which are being held by the S
  $ProxtFuncHolder.  I guess I could look up the API on that to see if
  there's a way to controls itsbehavior...  but there it is.
  Thanks to anyone who takes a look at this, Mark
 
  The stdout:
  ConsoleActor.lowPriority.Tick...DataStreamActor.lowPriority:
 HostAddMsg local
 
  ds count 4
  DataStreamActor.refreshStreams: now we know about stream count: 8
  INFO - Service request (GET) /memtest/comet_request/2021921075/
  p6s263zexmzz took 19513 Milliseconds
  ConsoleActor.lowPriority.Tick...DataStreamActor.lowPriority:
 HostAddMsg local
 
  ds count 4
  DataStreamActor.refreshStreams: now we know about stream count: 8
  INFO - Service request (GET) /memtest/comet_request/11287578067/
  p6s263zexmzz took 19879 Milliseconds
  ConsoleActor.lowPriority.Tick...DataStreamActor.lowPriority:
 HostAddMsg local
 
  ds count 4
  DataStreamActor.refreshStreams: now we know about stream count: 8
  INFO - Service request (GET) /memtest/comet_request/26532853932/
  p6s263zexmzz took 19868 Milliseconds
  ConsoleActor.lowPriority.Tick...DataStreamActor.lowPriority:
 HostAddMsg local
 
  ds count 4
  DataStreamActor.refreshStreams: now we know about stream count: 8
  INFO - Service request (GET) /memtest/comet_request/11619469749/
  p6s263zexmzz took 19918 Milliseconds
 
  On Jan 16, 2:32 am, Marius marius.dan...@gmail.com wrote:
 
   Lift GC is likely keeping your functions to not expire but this is
   meant to be that way ... but this doesn't explain the large amount of
   functions. Can you post a minimalistic example of your app where you
   can reproduce thisbehavior?
 
   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.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
 

Re: [Lift] Re: How to use prepareStatement to select *** from DB (two db vender)?

2010-01-21 Thread David Pollak
On Thu, Jan 21, 2010 at 9:29 AM, Neil.Lv anim...@gmail.com wrote:


  The users table in the OneDB, and the hots table in the TwoDB, they
 are separated!

  I have changed the method that like this:
 ###
  # I specify the TwoDB for hots table.
  override def dbDefaultConnectionIdentifier = bootstrap.liftweb.TwoDB


  def getHots3(id : Long) = {
DB.use(bootstrap.liftweb.OneDB) {
  firstConn =
  DB.use(bootstrap.liftweb.TwoDB) {
conn =
 DB.prepareStatement(SELECT * FROM hots WHERE id?, conn)
 {
 stmt =
 stmt.setLong(1, id)
  stmt.executeUpdate()
}
}
}
  }
 ###

  But it doesn't work.


What do it doesn't work mean?  Does it not compile, if not, what's the
compilation error?   If it's another error, what's the error?  In your
example, you are not using the firstConn connection.  Also, you will get an
exception if you do an executeUpdate with a SELECT statement (this is JDBC,
not Lift).  You must do an executeQuery for a SELECT.



  Thanks very much!  :)

 Cheers,
  Neil


 On Jan 22, 12:49 am, David Pollak feeder.of.the.be...@gmail.com
 wrote:
  What is wrong with:
 
  DB.use(FirstDB) {
firstConnection =
DB.use(SecondDB) {
secondConnection =
 
// do transactional query between two DBs here
 
  }
  }
 
  Note that DB.use nests such that the transaction will only be committed
 when
  the last DB.use block for a given ConnectionIdentifier is exited.
 
 
 
  On Thu, Jan 21, 2010 at 3:17 AM, Neil.Lv anim...@gmail.com wrote:
 
I have added the demo code on the Github now.
( Mabye it's a bug with DB.runQuery and DB.use in the two db
   vender )
 
Here is the address:
http://github.com/anim510/two_db_demo
 
 Thanks very much!
 
   Cheers,
Neil
 
   On Jan 21, 11:26 am, Neil.Lv anim...@gmail.com wrote:
  My email is :   anim...@gmail.com
 
On Jan 21, 11:17 am, Neil.Lv anim...@gmail.com wrote:
 
 Mabye it's a bug with DB.runQuery and DB.use in the two db vender
 
 
 Two question: (problem)
 
 1: I don't know why the HelloWorld snippet code will be execute 2
 times in this code. (See the HelloWorld.scala file.)
 2: The dbDefaultConnectionIdentifier method in the Model that it
 works
 fine when using Mapper's method such as ModelName.findAll(),
 it doesn't work when using DB.runQuery and DB.use(...) --- (Maybe
 it
 can't find the default db identifier)
 
 The question 2 I test it many times that found this problem.
 
 In the test app , the Hot.getHots2 and Hot.getHots3 method can't
 work.
 
 I comment the code now in the HelloWorld.scala file, you can try
 it.
 
 
 
   I can push the code on the github, and get this errors fatal:
 unable to fork
 
   So If anyone know what's wrong with it and I can send the
 demo.tar
 file through the email.
 
   Thanks very much!
 
 
 
 Cheers,
   Neil
 
 On Jan 21, 1:56 am, Neil.Lv anim...@gmail.com wrote:
 
The DB.runQuery can works now, but the DB.prepareStatement also
  cant' work.
 
Here is the test app address:
   http://github.com/anim510/two_db_demo
 
  Cheers,
Neil
 
  On Jan 21, 1:16 am, Neil.Lv anim...@gmail.com wrote:
 
  Thank you very much,
 
  But it doesn't work yet, maybe because of using two db
   connections.
 
  I'll test it later again.
 
   On Jan 21, 12:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk
 wrote:
 
Neil.Lv anim...@gmail.com writes:
 Hi all,
 
   I use two db connections in my app, and I want to use
 DB.prepareStatement to select
 the records from the second db.
 
   It failed, Here is the code:
 ###
   def getHotByTid(id : Long) =
 DB.use(bootstrap.liftweb.TwoDB) {
   conn =
  DB.prepareStatement(SELECT * FROM hots WHERE id=? ,
   conn) {
  stmt =
  stmt.setLong(1, id)
 Log.info(stmt : + stmt)   // The information is correctly
   now, but
 after call executeUpdate method
  stmt.executeUpdate()
   }
}
 
Not sure what your problem is really, but I think you should
 use
DB.runQuery to execute a select statement
 
Ie
 
  val (_,result) = DB.runQuery(SELECT COUNT(*),
 contract_length
FROM +
vehicles_current v +
WHERE v.account_id=? +
GROUP BY contract_length +
ORDER BY contract_length,
List(42))
 
/Jeppe
 
   --
   You received this message because you are subscribed to the Google
 Groups
   Lift group.
   To post to this group, send email to lift...@googlegroups.com.
   To unsubscribe from this group, send 

[Lift] Re: Ideas for how to inject QueryParams into find() and findAll()

2010-01-21 Thread Franz Bettag
I will implement it into my own MetaMapper-sub-trait so all of my
models can share the code.

Thank you all for your input!

On Jan 21, 9:44 am, Jeppe Nejsum Madsen je...@ingolfs.dk wrote:
 Naftoli Gugenheim naftoli...@gmail.com writes:
  Why not define a new method?
  def findByCurUser(params: QueryParam*) = User.currentUser.flatMap(user= 
  find((Seq(By(User.username, user.username.is)) ++ params): _*))
  find returns a Box and currentUser does too, so flatMap flattens them into 
  one. Basically find takes a varargs and you're passing a Seq instead using 
  : _*, and that Seq contains the user and other params.
  You could probably write params + By(User.username, user.username.is) 
  instead of the reverse order, as it's shorter than the previous version.

 The problem with this solution is that you cannot use any of Lift's
 builtin stuff such as CRUDify.

 If you wan't to create a multitenant service with only a single set of 
 tables, you wan't do make damn
 sure that each customer only sees his/her own data :-)

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




[Lift] Re: [scala-internals] RC8 candidate for the first 2.8.0 beta

2010-01-21 Thread David Pollak
I've written a work-around and am currently testing the code more in a
few minutes.

On Thu, Jan 21, 2010 at 11:20 AM, David Pollak 
feeder.of.the.be...@gmail.com wrote:

 Okay... it looks like the VarArg stuff is messing with the compiler:

 case class Index[A : Mapper[A]](columns: Seq[IndexItem[A]])

 works just fine, but:

 case class Index[A : Mapper[A]](columns: IndexItem[A] *)

 Fails.


 On Thu, Jan 21, 2010 at 10:51 AM, Heiko Seeberger 
 heiko.seeber...@googlemail.com wrote:

 When updating from RC7 to RC8 we observe the following compiler error:

 [ERROR]
 .../lift-mapper/src/main/scala/net/liftweb/mapper/MetaMapper.scala:1262:
 error: type arguments [net.liftweb.mapper.IndexItem[A]] do not conform to
 method sameElements's type parameter bounds [B :
 net.liftweb.mapper.IndexItem[Any]]
 [INFO] case class Index[A : Mapper[A]](indexColumns : IndexItem[A]*)
 extends BaseIndex[A](indexColumns : _*)

 Any ideas what could be going wrong here?

 Attached you will find the full source file.

 Heiko

 2010/1/18 Antonio Cunei antonio.cu...@epfl.ch

 All,

 A new release candidate for 2.8.0.Beta1 is available for testing. You can
 obtain the new candidate from the links below, as well as from the
 scala-tools.org Maven repository:


 http://www.scala-lang.org/downloads/distrib/files/scala-2.8.0.Beta1-RC8.tgz

 http://www.scala-lang.org/downloads/distrib/files/scala-2.8.0.Beta1-RC8.zip

 http://www.scala-lang.org/downloads/distrib/files/scala-2.8.0.Beta1-RC8-installer.jar

 http://www.scala-lang.org/downloads/distrib/files/scala-2.8.0.Beta1-RC8-devel-docs.tgz

 http://www.scala-lang.org/downloads/distrib/files/scala-2.8.0.Beta1-RC8-sources.tgz

 http://www.scala-lang.org/downloads/distrib/files/scala.library_2.8.0.Beta1-RC8.jar

 This is a candidate for the first, preliminary beta release of 2.8.0: it
 is
 only intended to help developers port their code onto the new 2.8
 codebase,
 and it is not production-quality code.

 Developers: this version includes the very latest fixes and updates to
 the Scala 2.8 codebase. Kindly test this last RC as well, and let us know if
 you detect anything unusual.

 Thanks!
 Toni




 --
 Heiko Seeberger

 Work: weiglewilczek.com
 Blog: heikoseeberger.name
 Follow me: twitter.com/hseeberger
 OSGi on Scala: scalamodules.org
 Lift, the simply functional web framework: liftweb.net




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




-- 
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: [scala-internals] RC8 candidate for the first 2.8.0 beta

2010-01-21 Thread martin odersky
(Un)fortunately I have an idea what the problem is. It's probably my
fix for #2867. I have now rolled back that fix in r20629. Can you
check again whether it works with that revision (should be in the
nightly tomorrow)? If it does we might be able to make an exception to
our RC = final rule, because this one just rolls back a non-critical
patch, so I fail to see how this could affect anything but the
original ticket.

Cheers

 -- Martin
-- 
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-internals] RC8 candidate for the first 2.8.0 beta

2010-01-21 Thread martin odersky
On Thu, Jan 21, 2010 at 8:31 PM, David Pollak
feeder.of.the.be...@gmail.com wrote:
 I've written a work-around and am currently testing the code more in a
 few minutes.

If you can make it work, so much the better. To give some info: The
original ticket had a vararg parameter of the form List[_]* in a case
class. This caused type inference for the synthetic equals method
(which uses sameElements for varargs) to fail, because the existential
in List[_] made the problem underconstrained. The patch passed the
argument type explicitly as the type parameter. In the lift case, it
seems that this explicit type parameter violated some type bound, so
the type inferencer should have chosen a more general type which would
not violate the bound. The easiest fix is probably to just roll back
and leave ticket #2867 open until we find a better solution. That's
what I have done.

Cheers

 -- Martin
-- 
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-internals] RC8 candidate for the first 2.8.0 beta

2010-01-21 Thread David Pollak
Okay... the work-around is checked into the Lift repo.

I say, Ship RC8 as the beta and we'll work through this (and likely other)
issues during the beta period.

On Thu, Jan 21, 2010 at 11:36 AM, martin odersky martin.oder...@epfl.chwrote:

 On Thu, Jan 21, 2010 at 8:31 PM, David Pollak
 feeder.of.the.be...@gmail.com wrote:
  I've written a work-around and am currently testing the code more in
 a
  few minutes.
 
 If you can make it work, so much the better. To give some info: The
 original ticket had a vararg parameter of the form List[_]* in a case
 class. This caused type inference for the synthetic equals method
 (which uses sameElements for varargs) to fail, because the existential
 in List[_] made the problem underconstrained. The patch passed the
 argument type explicitly as the type parameter. In the lift case, it
 seems that this explicit type parameter violated some type bound, so
 the type inferencer should have chosen a more general type which would
 not violate the bound. The easiest fix is probably to just roll back
 and leave ticket #2867 open until we find a better solution. That's
 what I have done.

 Cheers

  -- Martin




-- 
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: [scala-internals] RC8 candidate for the first 2.8.0 beta

2010-01-21 Thread martin odersky
On Thu, Jan 21, 2010 at 8:37 PM, David Pollak
feeder.of.the.be...@gmail.com wrote:
 Okay... the work-around is checked into the Lift repo.

 I say, Ship RC8 as the beta and we'll work through this (and likely other)
 issues during the beta period.

Sounds good. Thanks! -- Martin

 On Thu, Jan 21, 2010 at 11:36 AM, martin odersky martin.oder...@epfl.ch
 wrote:

 On Thu, Jan 21, 2010 at 8:31 PM, David Pollak
 feeder.of.the.be...@gmail.com wrote:
  I've written a work-around and am currently testing the code more in
  a
  few minutes.
 
 If you can make it work, so much the better. To give some info: The
 original ticket had a vararg parameter of the form List[_]* in a case
 class. This caused type inference for the synthetic equals method
 (which uses sameElements for varargs) to fail, because the existential
 in List[_] made the problem underconstrained. The patch passed the
 argument type explicitly as the type parameter. In the lift case, it
 seems that this explicit type parameter violated some type bound, so
 the type inferencer should have chosen a more general type which would
 not violate the bound. The easiest fix is probably to just roll back
 and leave ticket #2867 open until we find a better solution. That's
 what I have done.

 Cheers

  -- Martin



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

2010-01-21 Thread David Pollak
I'm okay with making the flag optional (but on by default with a breaking
changes notice) for the H2 database.

On Wed, Jan 20, 2010 at 11:09 AM, Naftoli Gugenheim naftoli...@gmail.comwrote:

 David and everone,
 Some time ago we discussed on this list what it would take to have
 Schemifier generate foreign key constraints. The obvious reason why it
 doesn't currently is because the relevant flag on all the DriverTypes is set
 to false.
 Derek was going to work on it but he got busy and didn't get far. Now, I
 personally, on my local repository, enabled foreign key generation for H2
 and it seems to have worked fine (although it gave me plenty of work
 manually fixing the integrity of my client's database so the keys could be
 generated successfully).
 In order for the tests to be successful, I had to change my ManyToManySpecs
 (if that's what it's called) to use a dummy DriverType with FK generation
 off, so it could test ManyToMany with broken joins.
 In any case, my quesion is, what criteria have to be fulfilled to push this
 (besides ReviewBoard approval obviously :) )?
 What level of testing?
 I assume it should be controllable with a flag that should, at least
 temporarily, be false. What form should this setting take?
 What other features should be supported? Different ON UPDATE/DELETE
 actions?
 Note that this is not the most immediate thing on my plate but I did
 already start as mentioned.
 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.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] Mindless work...

2010-01-21 Thread David Pollak
Folks,

It's looking like Scala 2.8 RC8 will become 2.8 Beta1 on Tuesday.

I'd like to get the Lift 2.8 branch up to date (and keep it up to date) with
the 2.0-SNAPSHOT branch as well as getting continuous builds on Hudson and
deployment in the scala-tools.org snapshots directory.

I think our best bet to get the 2.8 branch up to date with 2.0-SNAPSHOT is
to restart the port based on the work that Heiko is doing:
http://github.com/dpp/liftweb/issues#issue/292

I have time to do the mindless work of doing the port tonight (my brain will
explode if it has to think, but mindless is okay).

So:

   - Heiko -- how far along is the stuff in issue 292?  Is this code on the
   irc_issue_292 branch? Can I work on this branch tonight?
   - Indrajit -- Do you have the multi-thingy pom.xml stuff set up so we can
   build a 2.7.7 version and a 2.8 version with different names (2.0-SNAPSHOT
   and 2.0_S28-SNAPSHOT) from the same source tree?  What's the timing for
   getting Hudson all prepared?

Thanks,

David (who is very serious about making Lift on Scala 2.8 very successful)

-- 
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: A better approach to ajax forms?

2010-01-21 Thread Naftoli Gugenheim
Those names seem counterintuitive to me. ajaxSubmit submits an ajax form but 
submitAjaxForm submits a non-ajax form? submitAjaxForm implies that it should 
be the reverse, no?

-
Mariusmarius.dan...@gmail.com wrote:

Instead of

 submit - SHtml.submit(Parse, () = ())

use:

 submit - SHtml.ajaxSubmit(Parse, () = ())

you can also send normal forms via ajax like:

SHtml.submitAjaxForm(formId, () = {

  /// Do your stuff here. This function will be called after form
field functions are executed.
 Noop
})


Br's,
Marius

On Jan 21, 9:03 pm, Kris Nuttycombe kris.nuttyco...@gmail.com wrote:
 *thump* *thump* Hello, is this thing on? :)

 On Wed, Jan 20, 2010 at 10:20 AM, Kris Nuttycombe

 kris.nuttyco...@gmail.com wrote:
  On Wed, Jan 20, 2010 at 9:51 AM, Kris Nuttycombe
  kris.nuttyco...@gmail.com wrote:
  On Wed, Jan 20, 2010 at 9:39 AM, Kris Nuttycombe
  kris.nuttyco...@gmail.com wrote:
  Hi, all,

  I'm working on an AJAX form and feel like I'm missing something:
  namely, how to update the page based upon the result of the form
  submission.

  The three ajaxForm methods in SHtml have the following signatures:

  def ajaxForm(body : NodeSeq)
  def ajaxForm(body : NodeSeq, onSubmit : JsCmd)
  def ajaxForm(body : NodeSeq, onSubmit : JsCmd, postSubmit : JsCmd)

  In these signatures, onSubmit is called by the client prior to form
  submission, and postSubmit is called by the client after successful
  submission. My question is, why is there not a signature like this:

  def ajaxForm(body: NodeSeq, result: () = JsCmd)

  for which the specified result function will be called, and the JsCmd
  returned to the browser for evaluation after processing of the form
  contents on the server?

  Right now, I'm using the following to achieve this effect, but it
  seems really hacky:

         val (psId, psJs) = ajaxCall(JsRaw(dsl_text.value), text =
  After(20, SetHtml(results, parse(text

         ajaxForm(
             bind(plan, xhtml,
                  dsl - SHtml.textarea(, s = (), id -
  dsl_text, rows - 40, cols - 120),
                  submit - SHtml.submit(Parse, () = ())
             ),
             psJs.cmd
         )

  Here, JsCmd is actually doing the heavy lifting prior to form
  submission, with noop implementations for handling of the form
  elements. Seems really hacky.

  I feel like I've got to be missing something here, like there's got to
  be a better way to implement this such that the parsing of the
  textarea contents can be done by the closure passed to the
  SHtml.textarea call. How can I do this?

  Here's an idea I've been toying with for a while; it would be a
  somewhat significant change to Lift but I feel like there would be
  some benefits.

  Instead of SHtml.* having signatures like (String, () = Any, (String,
  String)*) = NodeSeq, imagine that there was a parameterized class
  (call it FormElement) that all of the SHtml methods returned, and then
  an implicit conversion from FormElement to NodeSeq. Might look
  something like this:

  trait FormElement[T] {
   def !: T
   def toNodeSeq: NodeSeq
  }

  An addendum: there's an obvious extension available here:

  trait FormElement[T] { self =
   def !: T

   def toNodeSeq: NodeSeq

   def map[U](f: T = U): FormElement[U] = new FormElement[U] {
     lazy val !: U = f(self!)
     lazy val toNodeSeq: NodeSeq = self.toNodeSeq
   }

   def flatMap[U](f: T = FormElement[U]): FormElement[U] = new
  FormElement[U] {
     private lazy val cache = f(self!)
     lazy val !: U = cache!
     lazy val toNodeSeq = self.toNodeSeq ++ cache.toNodeSeq
   }
  }

  On second thought, that FormElement implementation as a monad is wrong
  because toNodeSeq would cause strict evaluation of the closure when
  used in the SHtml.* case. Maybe FormElement just has to be a functor
  and not a monad.

  Kris
-- 
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] Version of maven for lift

2010-01-21 Thread James Matlik
What is Lift's recommended version of Maven?  I am looking to create an sbaz
package for easy download and install for maven for newcomers (myself
included), and figure that having one that is compatible with lift would be
of prime interest.  Is the latest and greatest version compatible with 2.0?

Regards,
James
-- 

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: A better approach to ajax forms?

2010-01-21 Thread Kris Nuttycombe
On Thu, Jan 21, 2010 at 12:23 PM, Marius marius.dan...@gmail.com wrote:
 Instead of

  submit - SHtml.submit(Parse, () = ())

 use:

  submit - SHtml.ajaxSubmit(Parse, () = ())

 you can also send normal forms via ajax like:

 SHtml.submitAjaxForm(formId, () = {

  /// Do your stuff here. This function will be called after form
 field functions are executed.
  Noop
 })


 Br's,
 Marius

Thanks, Marius. I've just updated from M1 to the snapshot to get
ajaxSubmit; however, it doesn't address my question as to why the
function passed to AjaxSubmit doesn't return a JsCmd that can be used
to refresh the page.

Also, any thoughts on my proposal?

Kris



 On Jan 21, 9:03 pm, Kris Nuttycombe kris.nuttyco...@gmail.com wrote:
 *thump* *thump* Hello, is this thing on? :)

 On Wed, Jan 20, 2010 at 10:20 AM, Kris Nuttycombe

 kris.nuttyco...@gmail.com wrote:
  On Wed, Jan 20, 2010 at 9:51 AM, Kris Nuttycombe
  kris.nuttyco...@gmail.com wrote:
  On Wed, Jan 20, 2010 at 9:39 AM, Kris Nuttycombe
  kris.nuttyco...@gmail.com wrote:
  Hi, all,

  I'm working on an AJAX form and feel like I'm missing something:
  namely, how to update the page based upon the result of the form
  submission.

  The three ajaxForm methods in SHtml have the following signatures:

  def ajaxForm(body : NodeSeq)
  def ajaxForm(body : NodeSeq, onSubmit : JsCmd)
  def ajaxForm(body : NodeSeq, onSubmit : JsCmd, postSubmit : JsCmd)

  In these signatures, onSubmit is called by the client prior to form
  submission, and postSubmit is called by the client after successful
  submission. My question is, why is there not a signature like this:

  def ajaxForm(body: NodeSeq, result: () = JsCmd)

  for which the specified result function will be called, and the JsCmd
  retur