Lifted,

When i look at the button behavior using firebug, this is the following
error i see.

F891109765602PT1 is not defined
onclick(click clientX=950, clientY=152)1tbfBLwe...6bg%3D%3D (line 2)
(F891109765602PT1, lift_ajaxHand...whatField").attr("value"), null, null));

It would appear that however the

ajaxCall(JsRaw("$('#whatField').attr('value')")

is working it is setting up a handle that is stale by the time the behavior
is actually invoked. This is behind-the-scenes stuff for a programmer like
me. It's part of what lift is s'posed to provide. Moreover, i get no help
from the compiler. The code i have written is well-typed. Any help would be
greatly appreciated.

Best wishes,

--greg


On Sat, May 2, 2009 at 8:50 PM, Meredith Gregory
<lgreg.mered...@gmail.com>wrote:

> Lifted,
>
> i'm putting together a little lift-based testharness in which to evaluate
> various solutions to the challenge Martin posted recently regarding scalable
> abstractions for a little lambda interpreter. You can get a copy of the app
> here <http://svn.biosimilarity.com/src/open/rlambda/trunk/>. (Please note:
> this is a testharness and not a proposed solution. i've got a couple of
> solutions in mind, but before i post them, i'd like to put them in a web
> "container".) As usual, i'm running into problems on the frontend. i'm not
> getting expected callback behavior, and, moreover, the code i'm using used
> to work fine.
>
> The snippet code is included below this email's closing. The relevant
> fragment is listed just below. The behavior i see is that the button
> produces no behavior on the server at all. The CR/LF event on the text field
> causes updateWhat to be called twice. Any advice on the frontend behavior
> would be greatly appreciated.
>
> def whatNode(termStr : String) = {
>     theTerm = termStr
>     theClientRequestStr = evalStr()
>     var theParseResponseStr : String =
>       ("failure: " + theClientRequestStr + "\n");
>     try {
>       theParseResponseStr =
>     theREPL.showClientRequestParseTree(theClientRequestStr)
>       println( "parsed : " + theParseResponseStr );
>     //theREPL.readEvalPrint(theClientRequestStr)
>     }
>     catch {
>       case e => {
>     val sw : java.io.StringWriter =    new java.io.StringWriter( );
>     e.printStackTrace( new java.io.PrintWriter( sw, true ) );
>     theParseResponseStr = theParseResponseStr + e.toString
>       }
>     }
>     <div id="parseTree">{theParseResponseStr}</div>
>   }
>
>   def updateWhat(str: String): JsCmd = {
>     println("updateWhat with " + str)
>     JsCmds.SetHtml("parseTree", whatNode(str))
>   }
>
>   def show(xhtml: NodeSeq): NodeSeq = {
>     <xml:group>
>       <label for="whatField">Term :</label>
>       { text("lambda x.x", (updateWhat _)) % ("size" -> "60") % ("id" ->
> "whatField") }
>       { <button type="button">{?("Go")}</button> %
>        ("onclick" -> ajaxCall(JsRaw("$('#whatField').attr('value')"), s =>
> updateWhat(s))) }
>       <br/>
>       <div id="parseTree">{whatNode(evalStr())}</div>
>     </xml:group>
>   }
>
> Best wishes,
>
> --greg
>
> package com.biosimilarity.reflection.snippet
>
> import net.liftweb._
> import http._
> import S._
> import SHtml._
> import util._
> import Helpers._
> import mapper._
> import textile._
> import js.{JE, JsCmd, JsCmds}
> import JsCmds._
> import JE._
>
> import com.biosimilarity.reflection.model.REPL
>
> import scala.xml._
>
> class REPLForm {
>   val theREPL = new REPL()
>   var theTerm : String = "lambda x.x"
>   var theClientRequestStr : String = evalStr()
>
>   def evalStr() = theTerm
>   def clientRequestRequest() = theClientRequestStr
>
>   def parseTreeNode(clientRequestStr : String) = {
>     theClientRequestStr = clientRequestStr.replace( "\n", "" );
>     var theParseResponseStr : String =
>       ( "failure: " + theClientRequestStr + "\n" );
>     try {
>       theParseResponseStr =
>     theREPL.showClientRequestParseTree(theClientRequestStr)
>     //theREPL.readEvalPrint(theClientRequestStr)
>     }
>     catch {
>       case e => {
>     val sw : java.io.StringWriter =    new java.io.StringWriter( );
>     e.printStackTrace( new java.io.PrintWriter( sw, true ) );
>     theParseResponseStr = theParseResponseStr + e.toString
>       }
>     }
>     <div id="parseTree">{theParseResponseStr}</div>
>   }
>
>   def whatNode(termStr : String) = {
>     theTerm = termStr
>     theClientRequestStr = evalStr()
>     var theParseResponseStr : String =
>       ("failure: " + theClientRequestStr + "\n");
>     try {
>       theParseResponseStr =
>     theREPL.showClientRequestParseTree(theClientRequestStr)
>       println( "parsed : " + theParseResponseStr );
>     //theREPL.readEvalPrint(theClientRequestStr)
>     }
>     catch {
>       case e => {
>     val sw : java.io.StringWriter =    new java.io.StringWriter( );
>     e.printStackTrace( new java.io.PrintWriter( sw, true ) );
>     theParseResponseStr = theParseResponseStr + e.toString
>       }
>     }
>     <div id="parseTree">{theParseResponseStr}</div>
>   }
>
>   def updateWhat(str: String): JsCmd = {
>     println("updateWhat with " + str)
>     JsCmds.SetHtml("parseTree", whatNode(str))
>   }
>
>   def show(xhtml: NodeSeq): NodeSeq = {
>     <xml:group>
>       <label for="whatField">Term :</label>
>       { text("lambda x.x", (updateWhat _)) % ("size" -> "60") % ("id" ->
> "whatField") }
>       { <button type="button">{?("Go")}</button> %
>        ("onclick" -> ajaxCall(JsRaw("$('#whatField').attr('value')"), s =>
> updateWhat(s))) }
>       <br/>
>       <div id="parseTree">{whatNode(evalStr())}</div>
>     </xml:group>
>   }
> }
>
>
> --
> L.G. Meredith
> Managing Partner
> Biosimilarity LLC
> 1219 NW 83rd St
> Seattle, WA 98117
>
> +1 206.650.3740
>
> http://biosimilarity.blogspot.com
>



-- 
L.G. Meredith
Managing Partner
Biosimilarity LLC
1219 NW 83rd St
Seattle, WA 98117

+1 206.650.3740

http://biosimilarity.blogspot.com

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to liftweb@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
-~----------~----~----~----~------~----~------~--~---

Reply via email to