home | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Lift Framework example source code file (JsonCmd.scala)

This example Lift Framework source code file (JsonCmd.scala) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Lift Framework tags/keywords

any, box, box, jsoncmd, jstring, jstring, jvalue, map, option, option, responseinfoholder, some, string, string

The Lift Framework JsonCmd.scala source code

 * Copyright 2006-2011 WorldWide Conferencing, LLC
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *     http://www.apache.org/licenses/LICENSE-2.0
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * See the License for the specific language governing permissions and
 * limitations under the License.

package net.liftweb
package util

import common._
import xml.NodeSeq

trait HasParams {
  def param(name: String): Box[String]

 * Impersonates a JSON command
case class JsonCmd(command: String, target: String, params: Any,
                   all: scala.collection.Map[String, Any])

import net.liftweb.json.JsonAST._

* A helpful extractor to take the JValue sent from the client-side JSON stuff and
* make some sense of it.
object JsonCommand {
  implicit def iterableToOption[X](in: Iterable[X]): Option[X] = in.toSeq.headOption

  def unapply(in: JValue): Option[(String, Option[String], JValue)] =
  for {
    JString(command) <- in \ "command"
    params <- in \ "params"
    if params != JNothing
  } yield {
    val target = (in \ "target") match {
      case JString(t) => Some(t)
      case _ => None
    (command, target, params)
  // Some((in.command, in.target, in.params, in.all))

 * Holds information about a response
class ResponseInfoHolder {
  var headers: Map[String, String] = Map.empty
  private var _docType: Box[String] = Empty
  private var _setDocType = false

  def docType = _docType

  def docType_=(in: Box[String]) {
    _docType = in
    _setDocType = true

  def overrodeDocType = _setDocType

Other Lift Framework examples (source code examples)

Here is a short list of links related to this Lift Framework JsonCmd.scala source code file:

my book on functional programming


new blog posts


Copyright 1998-2019 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.