English 中文(简体)
lift CalendarMonthView sample fails with Lift 1.1-SNAPSHOT
原标题:
  • 时间:2009-12-10 20:07:36
  •  标签:
  • scala
  • lift

A newbie scala/lift question:

I checked out the CalendarMonthView sample:

http://scala-tools.org/mvnsites/liftweb-1.0/lift-widgets/scaladocs/net/liftweb/widgets/calendars/CalendarMonthView.html

with Lift 1.1-M6 and it compiled and worked.

When i tried to migrate the sample to Lift 1.1-SNAPSHOT the signature of AnonFunc seems to have changed from class JsRaw to JsCmd (which is a trait).

The compiler fails here:

def itemClick = Full(AnonFunc("elem, param", JsCmd("alert( itemClick + param + - + elem.nodeName)")))

not found: value JsCmd

am i missing something ?

Regards Paul

问题回答

I found the new Lift 1.1-SNAPSHOT implementation of the CalendarMonthView sample in the sub-project

/lift-modules/lift-widgets

which has other quite impressive widget samples :-)

The best way is to get the whole liftweb repo via:

git clone git://github.com/dpp/liftweb.git

Try using net.liftweb.http.js.JE.JsRaw instead of JsCmd:

def itemClick = Full(AnonFunc("elem, param", JsRaw("alert( itemClick  + param +  -  + elem.nodeName)")))

I m not sure if that will pass through your elem and param from the AnonFunc, but I believe so

There are two solutions to this problem:

  1. Use the JsCmds jsExp to JsCmd converter.
  2. Create a new JsCmd object.

To illustrate these two examples, assuming that your original command was:

def dayClick = Full(AnonFunc("elem, param", JsRaw("alert( day was clicked )")))

The the converter would be:

import net.liftweb.http.js.JsCmds.jsExpToJsCmd
def dayClick = Full(AnonFunc("elem, param", JsRaw("alert( day was clicked )"))) 

And the new Command would be:

import net.liftweb.http.js.JsCmd
def dayClick = Full(AnonFunc("elem, param",
                             new JsCmd("alert( day was clicked )"))) 

Of course, those are not full import lists, simply those imports that are needed for the change in question.





相关问题
How to flatten a List of different types in Scala?

I have 4 elements:List[List[Object]] (Objects are different in each element) that I want to zip so that I can have a List[List[obj1],List[obj2],List[obj3],List[obj4]] I tried to zip them and I ...

To use or not to use Scala for new Java projects? [closed]

I m impressed with Twitter and investigating to use Scala for a new large scale web project with Hibernate and Wicket. What do you think about Scala, and should I use it instead of Java? EDIT: And, ...

Why does Scala create a ~/tmp directory when I run a script?

When I execute a Scala script from the command line, a directory named "tmp" is created in my home directory. It is always empty, so I simply deleted it without any apparent problem. Of course, when I ...

Include jar file in Scala interpreter

Is it possible to include a jar file run running the Scala interpreter? My code is working when I compile from scalac: scalac script.scala -classpath *.jar But I would like to be able to include a ...

Scala and tail recursion

There are various answers on Stack Overflow which explain the conditions under which tail recursion is possible in Scala. I understand the limitations and how and where I can take advantage of tail ...

热门标签