lift

converting xml to Json with lift behaves strange

北城余情 提交于 2019-12-07 09:10:17
问题 I'm using scala / lift for a Rest API. Under the hood I'm generating xml which will be converted to json via Xml.toJson() as output. Now i noticed some strange behavior which drives me nuts. for example i have the following xml: <data> <item> <foo>1</foo> <bar>1</bar> </item> <item> <foo>2</foo> <bar>2</bar> </item> </data> the result of xml.toJson() looks like: JObject( List( JField( data,JObject( List( JField(item, JArray( List( JObject( List( JField(foo,JString(1)), JField(bar,JString(1)))

how to deserialize DateTime in Lift

爱⌒轻易说出口 提交于 2019-12-07 07:08:36
问题 I am having trouble deserializing a org.joda.time.DateTime field from JSON into a case class. The JSON: val ajson=parse(""" { "creationDate": "2013-01-02T10:48:41.000-05:00" }""") I also set these serialization options: implicit val formats = Serialization.formats(NoTypeHints) ++ net.liftweb.json.ext.JodaTimeSerializers.all And the deserialization: val val1=ajson.extract[Post] where Post is: case class Post( creationDate : DateTime){ ... } The exception I get is: net.liftweb.json

Scala and Lift and SessionVar that loses it contents

浪子不回头ぞ 提交于 2019-12-06 16:48:43
I have SessionVar like this in Lift: object MyObject { object myVar extends SessionVar[Box[MyObject]](Empty) } Then I set value once for myVar: MyObject.myVar(Full(value)) My problem is that after some time (1-5 mins) myVar will lose its value, that is, it will have value Empty again. This is not due inactivity since I am clicking pages constantly. My code is not setting value to Empty. During this 1-5 mins the myVar will work correctly. The logs contain no related messages. I tried to add shutdown method to myVar, but it is not getting called. override protected def onShutdown(session:

How do I access the fields of a link-table with Lift Mapper?

ε祈祈猫儿з 提交于 2019-12-06 16:32:00
From the Lift-Web Mapper model below, how do I access the fields under AssignmentformLink? object TForm extends TForm with LongKeyedMetaMapper[TForm] class TForm extends LongKeyedMapper[TForm] with IdPK with ManyToMany { def getSingleton = TForm object label extends MappedString(this, 40) object pattern extends MappedString(this, 200) object assignments extends MappedManyToMany( AssignmentformLink, AssignmentformLink.assignment, AssignmentformLink.form, TForm) } object AssignmentformLink extends AssignmentformLink with LongKeyedMetaMapper[AssignmentformLink] { override def dbIndexes = Index

Lift Case Class Exceeding 22 Arguments

☆樱花仙子☆ 提交于 2019-12-06 12:18:56
问题 Using Lift, I'm trying to "extract" (get a case class representation of) my JSON. val json: JValue = getJson() case class BigObj(name: String, age: Int, ...) json.extract[BigObj] When using more than 22 arguments, I get a JVM run-time exception that case classes cannot exceed 22 arguments. How can I work around this limit? 回答1: As has been mentioned, you can't overcome that limit with a case class explicitly, however you can use the extract method without a case class. See this example, which

i need sbt 0.11.2 to build the mongo auth app for lift

有些话、适合烂在心里 提交于 2019-12-06 10:53:00
For some reason sbt bails on .11.3 when working with the mongodb-record auth project, and it seems to me that's the only version i can download from the git site. The idiomatic way is to specify sbt version in build.properties as sbt.version=0.11.2 But since group id in 0.11.3 was changed from org.scala-tools.sbt to org.scala-sbt , sbt can't resolve older versions. But you still can manually download older version of launcher from typesafe repo . 来源: https://stackoverflow.com/questions/10516610/i-need-sbt-0-11-2-to-build-the-mongo-auth-app-for-lift

Get json data in d3 from lift snippet

依然范特西╮ 提交于 2019-12-06 10:50:00
I am currently implementing a graph using d3 and a json object for data. A working example of such a graph can be found here: http://bl.ocks.org/950642 . If you know d3 you can certainly directly jump to the My Problem part. Quick overview of code So, basically in my template I have the minimum code necessary: <div id="main" class="lift:surround?with=default;at=content"> <div class="lift:GraphVisual.showGraph"></div> </div> Then in my snippet ( GraphVisual.scala ) I have the following: def showGraph = { <h3>Bachelor 5/6 - Communication Systems</h3> ++ <div id="graph-container" width="500px"

Handling exceptions in Scala object constructors

亡梦爱人 提交于 2019-12-06 05:29:35
I'm trying to use Lift JPA and when I reference Model, it calls the super constructor I'm getting an exception: object Model extends LocalEMF("LiftPersistenceUnit") with RequestVarEM The problem is that the exception is hidden behind this exception: java.lang.NoClassDefFoundError: Could not initialize class... So, my question is: what is the best way to log/handle exceptions in this case? Alternatively, can anyone recommend another pattern to use Lift JPA? The way Model has been code is the recommended way, but it's not very user-friendly IMO. The idea is to have a singleton entity manager

Background task in Liftweb environment

落爺英雄遲暮 提交于 2019-12-06 04:24:52
I must write daemon and I want to use Models for connecting to the database and some useful Lift classes. Is it possible to run analog of Rails's rake tasks? There is similar question on the Scala community group. The answer is to use Actors to do background processing. http://groups.google.com/group/liftweb/browse_thread/thread/ce536649e6e83867/ffde3a3d619adf9d?lnk=gst&q=background#ffde3a3d619adf9d 来源: https://stackoverflow.com/questions/3383076/background-task-in-liftweb-environment

Using LiftScreen field or text

被刻印的时光 ゝ 提交于 2019-12-06 03:58:28
问题 I'm using the LiftScreen trait and I have a doubt about the field and text methods. The text method use the makeField method and then the SHtml.text to render the field, while field method use a FormVendor trait to render the html. So which is the best way to add a field? I had to use the field method or the text/password/etc methods? Thank you. 回答1: The field method is a bit of syntactic sugar to create fields using field generators. It uses default values from that generator to create the