lift

SCALA Lift - S.param access within Comet Actor

十年热恋 提交于 2019-12-18 04:28:06
问题 I'm attempting to retrieve a url parameter within a CometActor to validate that the source of the data matches the destination, e.g A user sends a message from room A, which should be received and displayed only in room A, not B or C. I've tried: S.param("message").openOr("") But it's always empty, can this be done? Or is there another way to stop Comet messages going where they shouldn't? Thanks in advance for any help, much appreciated :) 回答1: CometActors exist outside of the session and so

How to use lift-json's class extractor constructor mongo bson array?

谁都会走 提交于 2019-12-13 06:47:08
问题 I'm use lift-json render a bson string with class extractor, after that, use mongo Document class constructor a document instance with that bson string. A problem is how about represent $or bson.It seems not a classic json array. {"$or": [ {"username": "administrator"}, {"phone":"110"}, {"email":"123@xxx.com"}, {"pen_name":"lorancechen"} ]} How to use lift class extractor represent this bson array? Besides, the reason of use string between app and mongo is they are communicate under a simple

How to create stand-alone lift web application?

谁说胖子不能爱 提交于 2019-12-12 08:09:48
问题 How to make a standalone lift application? Which tools/libraries to use? How does the performance compare to using lift application as a war in some application server? 回答1: With onejar maven plugin http://onejar-maven-plugin.googlecode.com/svn/mavensite/usage.html and maven I could package jetty and project with dependencies inside one jar. 回答2: The part of the question on performance doesn't really fit with the rest. You are primarily asking how to package the Lift application as a single

Lift Record: empty value for required field but no validation errors

若如初见. 提交于 2019-12-12 04:41:16
问题 I've been trying to figure out how to do this without manually defining a validation but without any success so far. I have a StringField class Foo private() extends MongoRecord[Foo] with ObjectIdKey[Foo] { ... object externalId extends StringField(this, 255) { // none of these seem to have any effect on validation whatsoever: override def optional_? = false override def required_? = true override def defaultValueBox = Empty } ... } Now when I call .validate on a Foo , it returns no errors:

Is there a JsAnd or JsOr when generate JS in lift?

女生的网名这么多〃 提交于 2019-12-11 13:04:34
问题 I know this is very much a noob question... I see lift provides utilities methods to generate javascript commands. I want to do the equivalent of: JsIf((JsEq(ValById("disable-production"),JsTrue) || JsEq(ValById("disable-production"), JsTrue) , { Alert("Do something interesting...") }) Thanks. 回答1: Yes, there is: import net.liftweb.http.js.JsCmds._ import net.liftweb.http.js.JE._ val conditional = JsIf( JsOr( JsEq(ValById("disable-production"), JsTrue), JsEq(ValById("disable-something-else"),

Scala: Parse HTML-fragment

Deadly 提交于 2019-12-11 12:13:34
问题 Our database stores HTML fragments like f.ex. <p>A.</p><p>B.</p> . I want to include the Html fragements from the database into a Lift snippet. To do that, I tried to use the XML.loadString() -method to convert the fragement into a scala.xml.Elem , but this only works for full valid XML-documents: import scala.xml.XML @Test def doesnotWork() { val result = XML.loadString("<p>A</p><p>B</p>") assert(result === <p>A</p><p>B</p>) } @Test def thisWorks() { val result = XML.loadString("<test><p>A<

Modify attribute of element

早过忘川 提交于 2019-12-11 11:19:55
问题 I would like to know if there exists a way to modify the attributes of an element (for example a select ) using a JsCmd in lift. Here the working version I have for now, running the javascript string. Run("document.getElementById(\"select_id\").setAttribute(\"width\", \"30px\");") Thanks in advance. 回答1: You can use the JqJE library included in Lift which provides a programatic wrapper around JQuery. The following snippet will create a link that will set the width attribute of #select_id to

How to package a hidden folder inside the root of a WAR file, using SBT?

天涯浪子 提交于 2019-12-11 04:44:34
问题 I am trying to build a WAR file (containing a Lift project) suitable for deployment to Elastic Beanstalk. I also need to configure my application using .ebextensions. .ebextensions should be stored in the root of a WAR file. Where should resources be placed so they end up in the root of a WAR file in SBT package ? Using src/main/resources appears to place resources in WEB-INF/classes . Even when I place the .ebextensions folder in, say, my src/main/resources folder and package the WAR file,

Parse json using liftweb in scala with no usable value

女生的网名这么多〃 提交于 2019-12-10 23:58:48
问题 I'm using liftweb to parse JSON from String in scala, some of record have 3 field val a = {"name": "Alice", "age": 21, "job": "nurse"} but some other have only 2 field val b = {"name": "Bob", "age": 30} I created case class Person(name: String, age: Long, job: String) and when I call parse(a) it return value successfully, but when I call parse(b) it appear exception net.liftweb.json.MappingException: No usable value for algorithm Did not find value which can be converted into java.lang.String

How to get parameters in an HTML page passed from a snippet with Lift framework

﹥>﹥吖頭↗ 提交于 2019-12-10 17:38:29
问题 I want to develop a Lift web app, I've an index page that has in here body: <div id="main" class="lift:surround?with=default&at=content"> <div> App </div> <div> <form method="post" class="lift:DumbForm"> <table> <tr><td> Email:</td> <td><input name="email" type="text"></td></tr> <tr><td> Password:</td> <td><input name="pwd" type="password"></td></tr> <tr><td> Name:</td> <td><input name="name" type="text"></td></tr> <tr><td><input type="submit" value="Sign in"></td> <td><input type="reset"