WiringUI and AutoComplete conflict

128 views
Skip to first unread message

ChristopherC

unread,
Feb 15, 2012, 11:08:00 AM2/15/12
to Lift
Hi,

I am currently trying to implement a form which is loaded in Ajax
given other criteria, however I have a conflict when I use
Autocomplete whereas is works with ajaxSelect for example.

I have the following error displayed on my webpage:

error on line 146 at column 80: AttValue: " or ' expected

Here is the corresponding line:

try{jQuery("#F114215951950RGX25X").each(function(i) {this.innerHTML =
"<span id=\"F114215951957PA3NZS\"></span>";});} catch (e) {}

Here is the code in my snippet:

import net.liftweb.util.ValueCell
import http.SHtml
import net.liftweb.widgets.autocomplete.AutoComplete

object SearchMenu {

/* A valueCell on which WiringUI is used */
val wiringCell= ValueCell(true)

/* The function called in html template */
def display = WiringUI.apply(wiringCell)(displayAjax)

/* The cell to be updated using autocomplete */
val cell = ValueCell("")

/* The function to create and display the autocomplete box */
def displayAjax(value: Boolean)(ns:NodeSeq):NodeSeq = {
def buildQueryName(current: String, limit: Int): Seq[String] = {
if (current.length == 0) Nil
else (1 to limit).map(n => current+""+n).take(limit)
}
AutoComplete("", buildQueryName _, cell.set _)
}
}

Here is the code in my HTML page:

<form class="lift:form.ajax">
<div class="lift:display"> </div>
</form>

Note: the code works if I call displayAjax(true) instead of display,
that is to say, if I don't use Wiring. So I think the problem might
come from the fact that autocomplete uses a script that is not loaded
when using Wiring UI but I don't have a solution.

Thanks in advance,
Chris

David Pollak

unread,
Feb 15, 2012, 2:08:03 PM2/15/12
to lif...@googlegroups.com
Christopher,

Can you put together example code (see https://www.assembla.com/wiki/show/liftweb/Posting_example_code ) and I'll take a look at it (probably on Tuesday).

Thanks,

David


--
Lift, the simply functional web framework: http://liftweb.net
Code: http://github.com/lift
Discussion: http://groups.google.com/group/liftweb
Stuck? Help us help you: https://www.assembla.com/wiki/show/liftweb/Posting_example_code



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net


ChristopherC

unread,
Feb 20, 2012, 1:01:57 PM2/20/12
to Lift
Hi,

Thanks for your answer, here is the corresponding github repository.

Regards,
Chris

On Feb 15, 8:08 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> Christopher,
>
> Can you put together example code (seehttps://www.assembla.com/wiki/show/liftweb/Posting_example_code) and I'll
> take a look at it (probably on Tuesday).
>
> Thanks,
>
> David
>
> On Wed, Feb 15, 2012 at 8:08 AM, ChristopherC
> <christopher.chi...@gmail.com>wrote:
> Visi.Pro, Cloud Computing for the Rest of Ushttp://visi.pro
> Lift, the simply functional web frameworkhttp://liftweb.net

ChristopherC

unread,
Feb 20, 2012, 1:03:29 PM2/20/12
to Lift
As usual, with the link it is always better:
https://github.com/ChrisJamesC/Liftweb---WiringUI-and-Autocomplete

On Feb 15, 8:08 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> Christopher,
>
> Can you put together example code (seehttps://www.assembla.com/wiki/show/liftweb/Posting_example_code) and I'll
> take a look at it (probably on Tuesday).
>
> Thanks,
>
> David
>
> On Wed, Feb 15, 2012 at 8:08 AM, ChristopherC
> <christopher.chi...@gmail.com>wrote:
> Visi.Pro, Cloud Computing for the Rest of Ushttp://visi.pro
> Lift, the simply functional web frameworkhttp://liftweb.net

David Pollak

unread,
Feb 21, 2012, 12:58:30 PM2/21/12
to lif...@googlegroups.com
On Mon, Feb 20, 2012 at 10:03 AM, ChristopherC <christoph...@gmail.com> wrote:
As usual, with the link it is always better:
https://github.com/ChrisJamesC/Liftweb---WiringUI-and-Autocomplete

Okay... your code triggers 2 different bugs in Lift:
  • The String -> JsString does not properly escape ]]> which then leads to premature XML unescaping
  • The SetHtml command does not properly move <script> blocks into properly executing JavaScript
Please open a ticket at http://ticket.liftweb.net (you must be a watcher of the LiftWeb space on Assembla to open tickets and at least some people are having problems opening tickets even as watchers) and assign it to me and put a link to this Google Groups thread in the ticket.

Thanks!

David



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net

ChristopherC

unread,
Feb 22, 2012, 11:42:32 AM2/22/12
to Lift
Hi,
I created an account using my gmail id and watched liftweb on
assembla, however I can't open a ticket: "You do not have permission
to access the requested page."
What can I do?

I will retry tomorrow to see if my permissions change.

On Feb 21, 6:58 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> On Mon, Feb 20, 2012 at 10:03 AM, ChristopherC <christopher.chi...@gmail.com
>
> > wrote:
> > As usual, with the link it is always better:
> >https://github.com/ChrisJamesC/Liftweb---WiringUI-and-Autocomplete
>
> Okay... your code triggers 2 different bugs in Lift:
>
>    - The String -> JsString does not properly escape ]]> which then leads
>    to premature XML unescaping
>    - The SetHtml command does not properly move <script> blocks into
>    properly executing JavaScript
>
> Please open a ticket athttp://ticket.liftweb.net(you must be a watcher of

David Pollak

unread,
Feb 22, 2012, 12:54:49 PM2/22/12
to lif...@googlegroups.com
On Wed, Feb 22, 2012 at 8:42 AM, ChristopherC <christoph...@gmail.com> wrote:
Hi,
I created an account using my gmail id and watched liftweb on
assembla, however I can't open a ticket: "You do not have permission
to access the requested page."
What can I do?

I will retry tomorrow to see if my permissions change.

I've fixed the permissions issue.  Thanks!



--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net

David Pollak

unread,
Feb 22, 2012, 1:44:13 PM2/22/12
to lif...@googlegroups.com
On Wed, Feb 22, 2012 at 9:54 AM, David Pollak <feeder.of...@gmail.com> wrote:


On Wed, Feb 22, 2012 at 8:42 AM, ChristopherC <christoph...@gmail.com> wrote:
Hi,
I created an account using my gmail id and watched liftweb on
assembla, however I can't open a ticket: "You do not have permission
to access the requested page."
What can I do?

I will retry tomorrow to see if my permissions change.

I've fixed the permissions issue.  Thanks!

Whoops... we disabled permissions because we're moving to GitHub for ticketing... please open the ticket at https://github.com/lift/framework/issues

ChristopherC

unread,
Feb 24, 2012, 2:54:47 AM2/24/12
to Lift
Thank you for all the informations, here is a link to the ticket:
https://github.com/lift/framework/issues/1223

On Feb 22, 7:44 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> On Wed, Feb 22, 2012 at 9:54 AM, David Pollak <feeder.of.the.be...@gmail.com
>
>
>
>
>
>
>
>
>
> > wrote:
>
> > On Wed, Feb 22, 2012 at 8:42 AM, ChristopherC <
> > christopher.chi...@gmail.com> wrote:
>
> >> Hi,
> >> I created an account using my gmail id and watched liftweb on
> >> assembla, however I can't open a ticket: "You do not have permission
> >> to access the requested page."
> >> What can I do?
>
> >> I will retry tomorrow to see if my permissions change.
>
> > I've fixed the permissions issue.  Thanks!
>
> Whoops... we disabled permissions because we're moving to GitHub for
> ticketing... please open the ticket athttps://github.com/lift/framework/issues
>
>
>
>
>
>
>
>
>
>
>
> >> On Feb 21, 6:58 pm, David Pollak <feeder.of.the.be...@gmail.com>
> >> wrote:
> >> > On Mon, Feb 20, 2012 at 10:03 AM, ChristopherC <
> >> christopher.chi...@gmail.com
>
> >> > > wrote:
> >> > > As usual, with the link it is always better:
> >> > >https://github.com/ChrisJamesC/Liftweb---WiringUI-and-Autocomplete
>
> >> > Okay... your code triggers 2 different bugs in Lift:
>
> >> >    - The String -> JsString does not properly escape ]]> which then
> >> leads
> >> >    to premature XML unescaping
> >> >    - The SetHtml command does not properly move <script> blocks into
> >> >    properly executing JavaScript
>
> >> > Please open a ticket athttp://ticket.liftweb.net(youmust be a watcher

ChristopherC

unread,
Feb 25, 2012, 10:10:59 AM2/25/12
to Lift
Hi,

Do you have an idea about a way to overpass these bugs?
I would really need a way to load an autocomplete form using
wiringUI.
Moreover I would like to know if there is a way to know if it will be
fixed soon or not.

Thanks for your time,

Christopher
> > >> > Please open a ticket athttp://ticket.liftweb.net(youmustbe a watcher
> > >> of
> > >> > the LiftWeb space on Assembla to open tickets and at least some people
> > >> are
> > >> > having problems opening tickets even as watchers) and assign it to me
> > >> and
> > >> > put a link to this Google Groups thread in the ticket.
>
> > >> > Thanks!
>
> > >> > David
>
> > >> > > On Feb 15, 8:08 pm, David Pollak <feeder.of.the.be...@gmail.com>
> > >> > > wrote:
> > >> > > > Christopher,
>
> > >> > > > Can you put together example code (seehttps://
> > >> > >www.assembla.com/wiki/show/liftweb/Posting_example_code) and I'll
> > >> > > > take a look at it (probably on Tuesday).
>
> > >> > > > Thanks,
>
> > >> > > > David
>
> > >> > > > On Wed, Feb 15, 2012 at 8:08 AM, ChristopherC
> > >> > > > <christopher.chi...@gmail.com>wrote:
>
> > >> > > > > Hi,
>
> > >> > > > > I am currently trying to implement a form which is loaded in Ajax
> > >> > > > > given other criteria, however I have a conflict when I use
> > >> > > > >Autocompletewhereas is works with ajaxSelect for example.
>
> > >> > > > > I have the following error displayed on my webpage:
>
> > >> > > > > error on line 146 at column 80: AttValue: " or ' expected
>
> > >> > > > > Here is the corresponding line:
>
> > >> > > > > try{jQuery("#F114215951950RGX25X").each(function(i)
> > >> {this.innerHTML =
> > >> > > > > "<span id=\"F114215951957PA3NZS\"></span>";});} catch (e) {}
>
> > >> > > > > Here is the code in my snippet:
>
> > >> > > > > import net.liftweb.util.ValueCell
> > >> > > > > import http.SHtml
> > >> > > > > import net.liftweb.widgets.autocomplete.AutoComplete
>
> > >> > > > > object SearchMenu {
>
> > >> > > > >  /* A valueCell on which WiringUI is used */
> > >> > > > >  val wiringCell= ValueCell(true)
>
> > >> > > > >  /* The function called in html template */
> > >> > > > >  def display = WiringUI.apply(wiringCell)(displayAjax)
>
> > >> > > > >  /* The cell to be updated usingautocomplete*/
> > >> > > > >  val cell = ValueCell("")
>
> > >> > > > >  /* The function to create and display theautocompletebox */
> > >> > > > >  def displayAjax(value: Boolean)(ns:NodeSeq):NodeSeq = {
> > >> > > > >    def buildQueryName(current: String, limit: Int): Seq[String] =
> > >> {
> > >> > > > >      if (current.length == 0) Nil
> > >> > > > >      else (1 to limit).map(n => current+""+n).take(limit)
> > >> > > > >    }
> > >> > > > >    AutoComplete("", buildQueryName _, cell.set _)
> > >> > > > >  }
> > >> > > > > }
>
> > >> > > > > Here is the code in my HTML page:
>
> > >> > > > > <form class="lift:form.ajax">
> > >> > > > >    <div class="lift:display"> </div>
> > >> > > > > </form>
>
> > >> > > > > Note: the code works if I call displayAjax(true) instead of
> > >> display,
> > >> > > > > that is to say, if I don't useWiring. So I think the problem
> > >> might
> > >> > > > > come from the fact thatautocompleteuses a script that is not
> > >> loaded
> > >> > > > > when usingWiringUI but I don't have a solution.

David Pollak

unread,
Feb 25, 2012, 12:45:46 PM2/25/12
to lif...@googlegroups.com
On Sat, Feb 25, 2012 at 7:10 AM, ChristopherC
<christoph...@gmail.com> wrote:
> Hi,
>
> Do you have an idea about a way to overpass these bugs?

rewrite the autocomplete code. It's fairly broken in Lift (it has
been one of the highest bug to LoC ratios in the project).

Autocomplete is generally not difficult with jQuery, although making
it generic is a problem (thus the issues with the existing
Autocomplete code). It should take you an hour or two to write
autocomplete yourself. It's a couple of simple JQ calls.

> I would really need a way to load an autocomplete form using
> wiringUI.
> Moreover I would like to know if there is a way to know if it will be
> fixed soon or not.

It's not a high priority for me.

--
Visi.Pro, Cloud Computing for the Rest of Us http://visi.pro
Lift, the simply functional web framework http://liftweb.net

Alex Holdtman

unread,
Mar 15, 2012, 10:49:40 AM3/15/12
to Lift
I experienced a similar problem, and found this chain when searching
for a solution.  After reading I started messing around with the
Script object in JsCommands.  I found that if you remove the type
attribute from the generated script node then the js is correctly
generated.  Here's an example from the render method of my customized
Autocomplete field.  I was very unsure about the stability of this
solution, until I discovered that the type attribute in HTML5 is not
required, and that script tags in all browsers default to javascript.
 If anyone sees other weaknesses in this solution please point them
out.




Have at it:




      def fixEndScriptTag(in: String): String = {
        if (S.ieMode) """\<\/script\>""".r.replaceAllIn(in, """<\\/
script>""")
        else in
      }




      <span>
        <head>
          <link rel="stylesheet" href={"/" +
LiftRules.resourceServerPath +"/autocomplete/jquery.autocomplete.css"}
type="text/css" />
          <script type="text/javascript" src={"/" +
LiftRules.resourceServerPath +"/autocomplete/jquery.autocomplete.js"} /
>
          <script>{Unparsed("""
          """ + fixEndScriptTag(onDocumentReady.toJsCmd) + """
          """)}</script>
        </head>
        {
          attrs.foldLeft(<input type="text" id={id} value={start} />)
(_ % _)
        }
        <input type="hidden" name={hidden} id={hidden} value={start} /
>
      </span>

On Feb 25, 1:45 pm, David Pollak <feeder.of.the.be...@gmail.com>
wrote:
> On Sat, Feb 25, 2012 at 7:10 AM, ChristopherC
>
> <christopher.chi...@gmail.com> wrote:
> > Hi,
>
> > Do you have an idea about a way to overpass these bugs?
>
> rewrite theautocompletecode.  It's fairly broken in Lift (it has
> been one of the highest bug to LoC ratios in the project).
>
> Autocompleteis generally not difficult with jQuery, although making
> it generic is a problem (thus the issues with the existingAutocompletecode).  It should take you an hour or two to writeautocompleteyourself.  It's a couple of simple JQ calls.
>
> > I would really need a way toloadanautocompleteform using
> >> > >> > Please open a ticket athttp://ticket.liftweb.net(youmustbea watcher
Reply all
Reply to author
Forward
0 new messages