This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var cometName= $('#cometName').val(); | |
//alert(cometName); | |
jQuery.ajax({ | |
type: 'PUT', | |
contentType: "application/json", | |
//url: "http://" + window.location.hostname + | |
// ":"+window.document.location.port+"/v1/rest/cities", | |
url: "http://dmedina.scala-tools.org/2/v1/rest/cities", | |
dataType: "json", | |
data: "{\"comet_name\":\""+ cometName +"\",\"id\":\"" + url +"\"}", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Build a JavaScript function that will perform an AJAX call based on a value calculated in JavaScript | |
* | |
* @param jsCalcValue the JavaScript that will be executed on the client to calculate the value to be sent to the server | |
* @param func the function to call when the data is sent | |
* | |
* @return the function ID and JavaScript that makes the call | |
*/ | |
def ajaxCall(jsCalcValue: JsExp, func: String => JsCmd): (String, JsExp) = ajaxCall_*(jsCalcValue, SFuncHolder(func)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Build a JavaScript function that will perform a JSON call based on a value calculated in JavaScript | |
* | |
* @param jsCalcValue the JavaScript to calculate the value to be sent to the server | |
* @param func the function to call when the data is sent | |
* | |
* @return the function ID and JavaScript that makes the call | |
*/ | |
def jsonCall(jsCalcValue: JsExp, func: Any => JsCmd): (String, JsExp) = | |
jsonCall_*(jsCalcValue, SFuncHolder(s => JSONParser.parse(s).map(func) openOr Noop)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[info] Compiling main sources... | |
[error] /home/wizard/Desktop/fmpwizard/public/lift-comet-history/src/main/scala/code/comet/MyLiftActor2.scala:76: overloaded method value apply with alternatives: | |
[error] (command: net.liftweb.http.js.JsExp,params: net.liftweb.http.js.JsExp)net.liftweb.http.js.JsCmds.Run <and> | |
[error] (command: String,params: net.liftweb.http.js.JsExp)net.liftweb.http.js.JsCmds.Run | |
[error] cannot be applied to (net.liftweb.http.js.JE.JsRaw, (Any) => net.liftweb.http.js.JsCmd) | |
[error] ".ajaxLinks [name]" #> jsonCall( | |
[error] ^ | |
[error] one error found | |
[info] == compile == | |
[error] Error running compile: Compilation failed |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def updateCity(x: Any) : JsCmd = { | |
val (cometName: String, cityId) = Full(x).asA[Map[String, Any]] match { | |
case Full(m) => ( | |
m.get("cometName").getOrElse("No comet Name"), | |
m.get("cityId").getOrElse("1") | |
) | |
case _ => ("No Comet Name", "1") | |
} | |
... | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* This would normally be a call to your database | |
*/ | |
object CitiesAndStates { | |
val cityStateMap= | |
Map( | |
1 -> List("Asheville" -> "North Carolina"), | |
2 -> List("San Francisco" -> "California"), |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import org.specs2._ | |
import specification._ | |
import matcher._ | |
import lib.{OptionFormatter => OF} | |
import net.liftweb.common.Logger | |
import net.liftweb.mapper.Like | |
import model._ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
scala> val o= Some(3) | |
o: Some[Int] = Some(3) | |
scala> ~o | |
res27: Int = 3 | |
scala> val oo= None: Option[Int] | |
oo: Option[Int] = None | |
scala> ~oo |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.fmpwizard.sample.code | |
package myScalaz | |
import net.liftweb.common.{Box, Full, Empty} | |
import scalaz._ | |
sealed trait BoxW[A] extends PimpedType[Box[A]] { | |
import Scalaz._ | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
subcategoryObj.is.category_id.set( | |
(subcategorySelect.selectedItem.now map { | |
x: Categories => x.id.is.toLong | |
}).getOrElse(0L) | |
) | |
and now I have: | |
subcategoryObj.is.category_id.set( ~(subcategorySelect.selectedItem.now map {x: Categories => x.id.is}) ) |