On Tue, Mar 2, 2010 at 1:21 PM, Rick R <[email protected]> wrote:

> >
> > On Tue, Mar 2, 2010 at 11:07 AM, Rick R <[email protected]>
> 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,
there<https://liftweb.assembla.com/spaces/liftweb/tickets/319-control-characters-in-input-can-lead-to-denial-of-service-attacks>
are<https://liftweb.assembla.com/spaces/liftweb/tickets/367-exception-net-liftweb-common-lrumap-value1>
bugs<https://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
> >>
> >>  <h2>Welcome to The Interview Tool.</h2>
> >>                <p>
> >>      <div id="F1040260232478N4M_outer" style="display: inline"><div
> >> id="F1040260232478N4M" style="display: inline"><div>
> >>      <p><span 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;pressed&quot;, 'params':a});})"
> >> id="txt1" />
> >>      </p>
> >>    </div><script 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></div><script 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 [email protected].
> >> To unsubscribe from this group, send email to
> >> [email protected]<liftweb%[email protected]>
> .
> >> 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 [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<liftweb%[email protected]>
> .
> > 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 [email protected].
> To unsubscribe from this group, send email to
> [email protected]<liftweb%[email protected]>
> .
> 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 [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.

Reply via email to