AJAX Widget Autocomplete used in Comet Element

38 views
Skip to first unread message

meiko

unread,
Nov 12, 2010, 5:16:43 AM11/12/10
to Lift
Hi

I use an Autocomplete-Widget
(root_.net.liftweb.widgets.autocomplete.AutoComplete) which calls a
method in a CometActor. The method is called correctly, when typing a
new letter - but i cannot get the request-parameters there.
S.param("q") is empty. My browser was sending the request correctly
(firebug shows the correct parameters in the request). If i use the
Autocomplete in a Snippet, all is running fine.

class MyCometActor extends CometActor {
...
def render = {
...
bind("my",
"autoSel" -> AutoComplete("",
(q: String, limit: Int) => {
//this method is called if a new letter is typed in
the select field
// but q is "" and S.param("q") == ""
//same in a snippet works (the q is the content of
the select-field)
List(q,q+"1") },
(q: String) => { }),
...
}
...
}

Is there an easy way to solve this problem ?
Is it a good idea to combine comet and complex ajax components ?

Thank you.

Meiko

David Pollak

unread,
Nov 12, 2010, 9:25:32 AM11/12/10
to lif...@googlegroups.com
On Fri, Nov 12, 2010 at 2:16 AM, meiko <rach...@googlemail.com> wrote:
Hi

I use an Autocomplete-Widget
(root_.net.liftweb.widgets.autocomplete.AutoComplete) which calls a
method in a CometActor. The method is called correctly, when typing a
new letter - but i cannot get the request-parameters there.
S.param("q") is empty.

That's correct.  CometActors always process messages outside the scope of the HTTP request/response cycle, so there's no Req instance and no query parameters.
 
My browser was sending the request correctly
(firebug shows the correct parameters in the request). If i use the
Autocomplete in a Snippet, all is running fine.

class MyCometActor extends CometActor {
...
 def render = {
   ...
   bind("my",
          "autoSel" -> AutoComplete("",
             (q: String, limit: Int) => {
                //this method is called if a new letter is typed in
the select field
                // but q is "" and S.param("q") == ""
                //same in a snippet works (the q is the content of
the select-field)
                List(q,q+"1") },
             (q: String) => {  }),
        ...
 }
...
}

Is there an easy way to solve this problem ?
Is it a good idea to combine comet and complex ajax components ?

For Ajax components built with SHtml.ajaxXXX, it's fine to mix Ajax and Comet.  However, this particular component does some bridging between the "Lift way" and the "jQuery way" that results in a less-than-optimal situation.

In the "Lift way", the parameters to an Ajax call are unwrapped when the call is being processed on the HTTP thread and then the parameters are sent via message to the CometActor for application to the function.

The "jQuery way" is to have a stable URL to make the query on.

The AutoComplete widget uses the q and limit parameters which are not available within the scope of the CometActor.

What's needed is a bridge between the two (basically, the ability to pull extra query parameters while the message is being packaged up for the CometActor).  Please open a ticket at http://ticket.liftweb.net (you need to be a watcher of the Liftweb space on Assembla to open a ticket) noting this thread.  It'd be ideal if you could put together a GitHub project that demonstrates the problem.  I'll create a general solution that will address this issue but also insure that other Ajax components that require stable query parameters are able to work with CometActors.
 

Thank you.

Meiko

--
You received this message because you are subscribed to the Google Groups "Lift" group.
To post to this group, send email to lif...@googlegroups.com.
To unsubscribe from this group, send email to liftweb+u...@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
Blog: http://goodstuff.im
Surf the harmonics

meiko

unread,
Nov 14, 2010, 11:48:48 AM11/14/10
to Lift
Done: Ticket #730 and https://github.com/meiko/lift-comet-autocomplete
Good support, thank you:)

On 12 Nov., 15:25, David Pollak <feeder.of.the.be...@gmail.com> wrote:
> CometActor).  Please open a ticket athttp://ticket.liftweb.net(you need to
> be a watcher of the Liftweb space on Assembla to open a ticket) noting this
> thread.  It'd be ideal if you could put together a GitHub project that
> demonstrates the problem.  I'll create a general solution that will address
> this issue but also insure that other Ajax components that require stable
> query parameters are able to work with CometActors.
>
>
>
>
>
> > Thank you.
>
> > Meiko
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Lift" group.
> > To post to this group, send email to lif...@googlegroups.com.
> > To unsubscribe from this group, send email to
> > liftweb+u...@googlegroups.com<liftweb%2Bunsu...@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
Reply all
Reply to author
Forward
0 new messages