[Lift] Lift 2.0M2 LiftMerge order?

2010-03-02 Thread Rick R
I have a pair of templates which rely on both a Snippet and a
CometActor. There appears to be a dependency injection process of
sorts where lift_page is defined and liftAjax.js is included. However,
it looks like the list of things is being included in reverse order.
The results seem to be the same whether I just return a NodeSeq from
CometActor.render or if I return a RenderOut defined with  NodeSeq and
JsCmd.

I'm not doing anything too crazy, I do Rewrite urls for the pages used
by the cometactors, but it's pretty standard.
(On a side note, is there any way to get GET params from a Rewrite to
the render function in a CometActor?, I tried a sessionVar but it
didn't work. What I ended up doing was getting the param in a snippet.
Setting it as a js variable on the page, then having the js use that
value to make a JsonCmd  to the cometActor, it should work provided I
can fix the code represented below)


For example:  (my comments -- inline)

-- This is the start of the template: adminchat.html

  h2Welcome to The Interview Tool./h2
p
  div id=F1040260232478N4M_outer style=display: inlinediv
id=F1040260232478N4M style=display: inlinediv
  pspan id=info/span/p
  p !-- A place to put stuff --

-- the following is the result of including : Script(JsonInCode)  from
render in my CometActor. This makes sense that we need to define the
callback before using it. Note, however, that it's referencing
liftAjax.lift  but we haven't included liftAjax.js yet.

script type=text/javascript
// ![CDATA[
/* JSON Func Other $$ F104026023248133W */function
F104026023248133W(obj)
{liftAjax.lift_ajaxHandler('F104026023248133W='+
encodeURIComponent(JSON.stringify(obj)), null,null);}
// ]]

/script
input type=textarea
onkeypress=processKeyPress(event.which, function(a)
{F104026023248133W({'command': quot;pressedquot;, 'params':a});})
id=txt1 /
  /p
/divscript type=text/javascript
// ![CDATA[

F104026023248133W({'command': connect, 'params':chatKey});

-- okay.. we define this function again, I'm not sure why and I didn't
ask it to, but no real harm done.

/* JSON Func Other $$ F104026023248133W */function
F104026023248133W(obj)
{liftAjax.lift_ajaxHandler('F104026023248133W='+
encodeURIComponent(JSON.stringify(obj)), null,null);}
// ]]
/script/divscript type=text/javascript
// ![CDATA[
var destroy_F1040260232478N4M = function() {}
// ]]
/script/div

-- this is the end of the output from the CometACtor

/p

 -- this is the end of output from the template.

  /div

  hr /
/div

-- this should be the end of output from default.html, but I'm
guessing this is where stuff gets merged in.
-- Here we include liftAjax, it's a bit late, but it's still wrong
because it relies on lift_page.

  script type=text/javascript src=/ajax_request/liftAjax.js/script
script type=text/javascript
src=/comet_request/xkvbzq4ueltw/cometAjax.js/script

-- here's where we finally define the vars needed by liftAjax et al.

script type=text/javascript
// ![CDATA[
var lift_toWatch = {F1040260232478N4M: 1040260232480};
// ]]
/script
script type=text/javascript
// ![CDATA[

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



Re: [Lift] Lift 2.0M2 LiftMerge order?

2010-03-02 Thread David Pollak
On Tue, Mar 2, 2010 at 11:07 AM, Rick R rick.richard...@gmail.com wrote:

 I have a pair of templates which rely on both a Snippet and a
 CometActor. There appears to be a dependency injection


Dependency injection is an entirely different concept.  Lift rewrites the
page as it goes out to insure comet and ajax support.


 process of
 sorts where lift_page is defined and liftAjax.js is included. However,
 it looks like the list of things is being included in reverse order.


What do you mean reverse order?  Are you seeing an actual error?  Is
something actually failing?

All of the stuff in Lift is (or at least should be) invoked only after the
page load is complete.


 The results seem to be the same whether I just return a NodeSeq from
 CometActor.render or if I return a RenderOut defined with  NodeSeq and
 JsCmd.

 I'm not doing anything too crazy, I do Rewrite urls for the pages used
 by the cometactors, but it's pretty standard.
 (On a side note, is there any way to get GET params from a Rewrite to
 the render function in a CometActor?


You can't.  CometActors are not rendered in response to an HTTP request and
have no access to specific request state.


 , I tried a sessionVar but it
 didn't work. What I ended up doing was getting the param in a snippet.
 Setting it as a js variable on the page, then having the js use that
 value to make a JsonCmd  to the cometActor, it should work provided I
 can fix the code represented below)


 For example:  (my comments -- inline)

 -- This is the start of the template: adminchat.html

  h2Welcome to The Interview Tool./h2
p
  div id=F1040260232478N4M_outer style=display: inlinediv
 id=F1040260232478N4M style=display: inlinediv
  pspan id=info/span/p
  p !-- A place to put stuff --

 -- the following is the result of including : Script(JsonInCode)  from
 render in my CometActor. This makes sense that we need to define the
 callback before using it. Note, however, that it's referencing
 liftAjax.lift  but we haven't included liftAjax.js yet.

script type=text/javascript
 // ![CDATA[
 /* JSON Func Other $$ F104026023248133W */function
 F104026023248133W(obj)
 {liftAjax.lift_ajaxHandler('F104026023248133W='+
 encodeURIComponent(JSON.stringify(obj)), null,null);}
 // ]]

 /script
input type=textarea
 onkeypress=processKeyPress(event.which, function(a)
 {F104026023248133W({'command': quot;pressedquot;, 'params':a});})
 id=txt1 /
  /p
/divscript type=text/javascript
 // ![CDATA[

 F104026023248133W({'command': connect, 'params':chatKey});

 -- okay.. we define this function again, I'm not sure why and I didn't
 ask it to, but no real harm done.

 /* JSON Func Other $$ F104026023248133W */function
 F104026023248133W(obj)
 {liftAjax.lift_ajaxHandler('F104026023248133W='+
 encodeURIComponent(JSON.stringify(obj)), null,null);}
 // ]]
 /script/divscript type=text/javascript
 // ![CDATA[
 var destroy_F1040260232478N4M = function() {}
 // ]]
 /script/div

 -- this is the end of the output from the CometACtor

/p

  -- this is the end of output from the template.

  /div

  hr /
/div

 -- this should be the end of output from default.html, but I'm
 guessing this is where stuff gets merged in.
 -- Here we include liftAjax, it's a bit late, but it's still wrong
 because it relies on lift_page.

  script type=text/javascript src=/ajax_request/liftAjax.js/script
 script type=text/javascript
 src=/comet_request/xkvbzq4ueltw/cometAjax.js/script

 -- here's where we finally define the vars needed by liftAjax et al.

 script type=text/javascript
 // ![CDATA[
 var lift_toWatch = {F1040260232478N4M: 1040260232480};
 // ]]
 /script
 script type=text/javascript
 // ![CDATA[

 var lift_page = F1040260232477ZYH;
 // ]]
 /script/body
 /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 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] Lift 2.0M2 LiftMerge order?

2010-03-02 Thread Rick R

 On Tue, Mar 2, 2010 at 11:07 AM, Rick R rick.richard...@gmail.com wrote:

 I have a pair of templates which rely on both a Snippet and a
 CometActor. There appears to be a dependency injection

 Dependency injection is an entirely different concept.  Lift rewrites the
 page as it goes out to insure comet and ajax support.


Yes,  that was the reason for the quotes.  I am referring to the
mechanism by which lift determines that a page required ajax, so it
makes sure to include liftAjax.js.


 process of
 sorts where lift_page is defined and liftAjax.js is included. However,
 it looks like the list of things is being included in reverse order.

 What do you mean reverse order?  Are you seeing an actual error?  Is
 something actually failing?

Yes.  As I indicate below (albeit in a messy fashion)  the callbacks
which use liftAjax are defined before liftAjax.js is included.
Further, the variables which are needed by liftAjax.js, such as
lift_page, are defined *after* liftAjax.js is
included.

This is what lead me to believe that these three sections are being
rendered in reverse.
What I would expect to see is lift_page being rendered before the
inclusion of liftAjax.js which occurs before
the definition of the functions which rely on liftAjax.


 (On a side note, is there any way to get GET params from a Rewrite to
 the render function in a CometActor?

 You can't.  CometActors are not rendered in response to an HTTP request and
 have no access to specific request state.

That is fine, should one expect a SessionVar to work for a CometActor
when it is set in response to a RewriteRequest?



 For example:  (my comments -- inline)

 -- This is the start of the template: adminchat.html

  h2Welcome to The Interview Tool./h2
                p
      div id=F1040260232478N4M_outer style=display: inlinediv
 id=F1040260232478N4M style=display: inlinediv
      pspan id=info/span/p
      p !-- A place to put stuff --

 -- the following is the result of including : Script(JsonInCode)  from
 render in my CometActor. This makes sense that we need to define the
 callback before using it. Note, however, that it's referencing
 liftAjax.lift  but we haven't included liftAjax.js yet.

        script type=text/javascript
 // ![CDATA[
 /* JSON Func Other $$ F104026023248133W */function
 F104026023248133W(obj)
 {liftAjax.lift_ajaxHandler('F104026023248133W='+
 encodeURIComponent(JSON.stringify(obj)), null,null);}
 // ]]

 /script
        input type=textarea
 onkeypress=processKeyPress(event.which, function(a)
 {F104026023248133W({'command': quot;pressedquot;, 'params':a});})
 id=txt1 /
      /p
    /divscript type=text/javascript
 // ![CDATA[

 F104026023248133W({'command': connect, 'params':chatKey});

 -- okay.. we define this function again, I'm not sure why and I didn't
 ask it to, but no real harm done.

 /* JSON Func Other $$ F104026023248133W */function
 F104026023248133W(obj)
 {liftAjax.lift_ajaxHandler('F104026023248133W='+
 encodeURIComponent(JSON.stringify(obj)), null,null);}
 // ]]
 /script/divscript type=text/javascript
 // ![CDATA[
 var destroy_F1040260232478N4M = function() {}
 // ]]
 /script/div

 -- this is the end of the output from the CometACtor

    /p

  -- this is the end of output from the template.

      /div

      hr /
    /div

 -- this should be the end of output from default.html, but I'm
 guessing this is where stuff gets merged in.
 -- Here we include liftAjax, it's a bit late, but it's still wrong
 because it relies on lift_page.

  script type=text/javascript src=/ajax_request/liftAjax.js/script
 script type=text/javascript
 src=/comet_request/xkvbzq4ueltw/cometAjax.js/script

 -- here's where we finally define the vars needed by liftAjax et al.

 script type=text/javascript
 // ![CDATA[
 var lift_toWatch = {F1040260232478N4M: 1040260232480};
 // ]]
 /script
 script type=text/javascript
 // ![CDATA[

 var lift_page = F1040260232477ZYH;
 // ]]
 /script/body
 /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.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.


-- 
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] Lift 2.0M2 LiftMerge order?

2010-03-02 Thread David Pollak
On Tue, Mar 2, 2010 at 1:21 PM, Rick R rick.richard...@gmail.com wrote:

 
  On Tue, Mar 2, 2010 at 11:07 AM, Rick R rick.richard...@gmail.com
 wrote:
 
  I have a pair of templates which rely on both a Snippet and a
  CometActor. There appears to be a dependency injection
 
  Dependency injection is an entirely different concept.  Lift rewrites the
  page as it goes out to insure comet and ajax support.
 

 Yes,  that was the reason for the quotes.  I am referring to the
 mechanism by which lift determines that a page required ajax, so it
 makes sure to include liftAjax.js.

 
  process of
  sorts where lift_page is defined and liftAjax.js is included. However,
  it looks like the list of things is being included in reverse order.
 
  What do you mean reverse order?  Are you seeing an actual error?  Is
  something actually failing?

 Yes.  As I indicate below (albeit in a messy fashion)  the callbacks
 which use liftAjax are defined before liftAjax.js is included.
 Further, the variables which are needed by liftAjax.js, such as
 lift_page, are defined *after* liftAjax.js is
 included.

 This is what lead me to believe that these three sections are being
 rendered in reverse.
 What I would expect to see is lift_page being rendered before the
 inclusion of liftAjax.js which occurs before
 the definition of the functions which rely on liftAjax.


They are not being rendered in reverse.  There is no problem.  The code
works correctly.

Why?

First, the code in the CometActor is a call a function in response to an
event.  The page will be loaded before you can press the button or otherwise
cause the event to be dispatched.

Second, as I said in my first response, the code in liftAjax only gets
executed after the page is loaded... that means if there's some random event
that causes the page parsing to be delayed until after the liftAjax.js file
is loaded and parsed, the calls in liftAjax that reference the variables on
the page is not going to get executed until after the page is completely
loaded (which also means the page is parsed and the inline JavaScript code
is executed.)

More broadly, we take bug reports from *actual* failures.  Actual failure
means that something is not working as you expect (e.g., the comet component
is not updating, ajax stuff is not firing ajax events.)  The pieces part of
Lift work well and for a wide variety of users from our friends at Four
Square to our friends at Novell to our friends at Innovation Games.  It
would be very likely that if there was an actual problem with the way Lift
dealt with Comet or Ajax, that the hundreds of thousands of users of Lift
applications would have discovered the problem.  But in actual fact, the
Novell folks tend to burn cycles with stuff like
http://twitter.com/djspiewak/status/9837576830 because the core Lift comet
stuff works so well for them.  Sure,
therehttps://liftweb.assembla.com/spaces/liftweb/tickets/319-control-characters-in-input-can-lead-to-denial-of-service-attacks
arehttps://liftweb.assembla.com/spaces/liftweb/tickets/367-exception-net-liftweb-common-lrumap-value1
bugshttps://liftweb.assembla.com/spaces/liftweb/tickets/343-add-linktoself--true-false--option-to-menu-snippet
in
Lift, but the bugs and feature requests get serviced quickly because we can
understand what is expected, we can agree on what is expected, we can
reproduce deviations from what is expected, and then we can bring the code
into line.






  (On a side note, is there any way to get GET params from a Rewrite to
  the render function in a CometActor?
 
  You can't.  CometActors are not rendered in response to an HTTP request
 and
  have no access to specific request state.

 That is fine, should one expect a SessionVar to work for a CometActor
 when it is set in response to a RewriteRequest?


No.  You can only communicate with CometActors via messages sent to the
CometActor with the ! operator.  Comet Actors live outside of the HTTP
request/response pipeline.  They may or may not share Session Vars during a
given request.




 
  For example:  (my comments -- inline)
 
  -- This is the start of the template: adminchat.html
 
   h2Welcome to The Interview Tool./h2
 p
   div id=F1040260232478N4M_outer style=display: inlinediv
  id=F1040260232478N4M style=display: inlinediv
   pspan id=info/span/p
   p !-- A place to put stuff --
 
  -- the following is the result of including : Script(JsonInCode)  from
  render in my CometActor. This makes sense that we need to define the
  callback before using it. Note, however, that it's referencing
  liftAjax.lift  but we haven't included liftAjax.js yet.
 
 script type=text/javascript
  // ![CDATA[
  /* JSON Func Other $$ F104026023248133W */function
  F104026023248133W(obj)
  {liftAjax.lift_ajaxHandler('F104026023248133W='+
  encodeURIComponent(JSON.stringify(obj)), null,null);}
  // ]]
 
  /script
 input type=textarea
  onkeypress=processKeyPress(event.which, function(a)
  

Re: [Lift] Lift 2.0M2 LiftMerge order?

2010-03-02 Thread Rick R
 They are not being rendered in reverse.  There is no problem.  The code
 works correctly.
 Why?
 First, the code in the CometActor is a call a function in response to an
 event.  The page will be loaded before you can press the button or otherwise
 cause the event to be dispatched.
 Second, as I said in my first response, the code in liftAjax only gets
 executed after the page is loaded... that means if there's some random event
 that causes the page parsing to be delayed until after the liftAjax.js file
 is loaded and parsed, the calls in liftAjax that reference the variables on
 the page is not going to get executed until after the page is completely
 loaded (which also means the page is parsed and the inline JavaScript code
 is executed.)

Thanks for clarifying.  Upon page load, I am attempting to make a
JsonCall connect to the CometActor. This is how I intend to get the
parameter created by the RewriteRequest function to the CometActor.
So that it can use that param to fetch a previously allocated
resource.

I noticed a failure, which is why I posted to the list. The failure
was that my call to to the comet server occurred before liftAjax.js
was loaded. Thus causing javascript to stop evaluating and my json
call to not occur.

Thanks to your explanation above, I now realize that I should probably
use some mechanism to specify that my jsonCall occurs on the
body.onLoad event, or something like it, rather than being executed
inline.

Could you provide guidance in this area? Because I can't find anything
in the docs that would allow me to specify such a task from scala
source.  I could just hack something $(document).ready, but I was
hoping to go for as much Lift as possible.

Thanks.

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