org.scalatra.commands

Command

trait Command extends BindingSyntax with ParamsValueReaderProperties

Trait that identifies a Command object, i.e. a Scala class instance which fields are bound to external parameters taken from Scalatra' params object.

An usage example can be seen below:

class PersonForm extends Command {

 import Command._

 val name = bind[String]("f_name")
 val surname = bind[String]("f_surname")
 val age = bind[Int]("f_age")
 val registeredOn = bind[Date]("f_reg_date" -> "yyyyMMdd")
}

In the example above, class field name will be bound, at runtime, with a parameter named f_name and so on. The binding is typed and for every registered type T (see DefaultImplicitConversions for a list of all availables) an automatic conversion (String) => T will take place during binding phase.

After that binding has been performed (i.e. after that org.scalatra.commands.Command#bindTo() has been called) on a specific instance, it is possible retrieve field values as scalaz.Validation, i.e.:

val form = new PersonForm
form.doBinding(params)
val registrationDate = form.registeredOn.value.getOrElse(new Date())
Version

0.1

Linear Supertypes
Known Subclasses
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. Hide All
  2. Show all
  1. Command
  2. ParamsValueReaderProperties
  3. BindingSyntax
  4. BindingValidatorImplicits
  5. AnyRef
  6. Any
Visibility
  1. Public
  2. All

Type Members

  1. abstract type CommandTypeConverterFactory[T] <: TypeConverterFactory[T]

Value Members

  1. final def !=(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  2. final def !=(arg0: Any): Boolean

    Definition Classes
    Any
  3. final def ##(): Int

    Definition Classes
    AnyRef → Any
  4. final def ==(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  5. final def ==(arg0: Any): Boolean

    Definition Classes
    Any
  6. def afterBinding(action: ⇒ Any): Unit

    Add an action that will be evaluated after field binding has been done.

    Add an action that will be evaluated after field binding has been done.

    Attributes
    protected
  7. def asBigDecimal(name: String): FieldDescriptor[BigDecimal]

    Definition Classes
    BindingSyntax
  8. def asBoolean(name: String): FieldDescriptor[Boolean]

    Definition Classes
    BindingSyntax
  9. def asByte(name: String): FieldDescriptor[Byte]

    Definition Classes
    BindingSyntax
  10. def asDate(name: String): FieldDescriptor[Date]

    Definition Classes
    BindingSyntax
  11. def asDateTime(name: String): FieldDescriptor[DateTime]

    Definition Classes
    BindingSyntax
  12. def asDouble(name: String): FieldDescriptor[Double]

    Definition Classes
    BindingSyntax
  13. def asFloat(name: String): FieldDescriptor[Float]

    Definition Classes
    BindingSyntax
  14. final def asInstanceOf[T0]: T0

    Definition Classes
    Any
  15. def asInt(name: String): FieldDescriptor[Int]

    Definition Classes
    BindingSyntax
  16. def asLong(name: String): FieldDescriptor[Long]

    Definition Classes
    BindingSyntax
  17. def asSeq[T](name: String)(implicit arg0: Manifest[T]): FieldDescriptor[Seq[T]]

    Definition Classes
    BindingSyntax
  18. def asShort(name: String): FieldDescriptor[Short]

    Definition Classes
    BindingSyntax
  19. def asString(name: String): FieldDescriptor[String]

    Definition Classes
    BindingSyntax
  20. implicit def asType[T](name: String)(implicit arg0: DefaultValue[T], arg1: Manifest[T]): FieldDescriptor[T]

    Definition Classes
    BindingSyntax
  21. implicit def autoBind[T](fieldName: String)(implicit arg0: Manifest[T], arg1: DefaultValue[T], arg2: TypeConverterFactory[T]): Field[T]

  22. def beforeBinding(action: ⇒ Any): Unit

    Add an action that will be evaluated before field binding occurs.

    Add an action that will be evaluated before field binding occurs.

    Attributes
    protected
  23. implicit def bind[T](field: FieldDescriptor[T])(implicit arg0: DefaultValue[T], arg1: Manifest[T], arg2: TypeConverterFactory[T]): FieldDescriptor[T]

  24. def bindTo[S, I](data: S, params: MultiParams, headers: Map[String, String])(implicit r: (S) ⇒ ValueReader[S, I], df: DefaultValue[I], ds: DefaultValue[S], mi: Manifest[I], multiParams: (MultiParams) ⇒ ValueReader[MultiParams, Seq[String]]): Command.this.type

  25. implicit def binding2field[T](field: FieldDescriptor[T])(implicit arg0: DefaultValue[T], arg1: Manifest[T], arg2: TypeConverterFactory[T]): Field[T]

  26. def clone(): AnyRef

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  27. var commandDescription: String

  28. var commandName: String

  29. final def eq(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  30. def equals(arg0: Any): Boolean

    Definition Classes
    AnyRef → Any
  31. def errors: Seq[Binding]

    Return a Map of all field command error keyed by field binding name (NOT the name of the variable in command object).

  32. def finalize(): Unit

    Attributes
    protected[lang]
    Definition Classes
    AnyRef
    Annotations
    @throws()
  33. final def getClass(): java.lang.Class[_]

    Definition Classes
    AnyRef → Any
  34. def hashCode(): Int

    Definition Classes
    AnyRef → Any
  35. final def isInstanceOf[T0]: Boolean

    Definition Classes
    Any
  36. def isInvalid: Boolean

  37. def isValid: Boolean

    Check whether this command is valid.

  38. implicit def multiMapHeadViewMapValueReader[T <: MultiMapHeadView[String, String]](d: T): ValueReader[T, String]

    Definition Classes
    ParamsValueReaderProperties
  39. implicit def multiParamsValueReader(d: MultiParams): ValueReader[MultiParams, Seq[String]]

    Definition Classes
    ParamsValueReaderProperties
  40. final def ne(arg0: AnyRef): Boolean

    Definition Classes
    AnyRef
  41. final def notify(): Unit

    Definition Classes
    AnyRef
  42. final def notifyAll(): Unit

    Definition Classes
    AnyRef
  43. implicit def stringMapValueReader(d: Map[String, String]): ValueReader[Map[String, String], String]

    Definition Classes
    ParamsValueReaderProperties
  44. final def synchronized[T0](arg0: ⇒ T0): T0

    Definition Classes
    AnyRef
  45. def toString(): String

    Definition Classes
    Command → AnyRef → Any
  46. def typeConverterBuilder[I](tc: Command.this.CommandTypeConverterFactory[_]): PartialFunction[org.scalatra.util.ValueReader[_, _], org.scalatra.util.conversion.package.TypeConverter[I, _]]

  47. implicit def validatableGenericBinding[T](b: FieldDescriptor[T]): ValidatableGenericBinding[T]

    Definition Classes
    BindingValidatorImplicits
  48. implicit def validatableOrderedBinding[T](b: FieldDescriptor[T])(implicit arg0: (T) ⇒ Ordered[T]): ValidatableOrdered[T]

    Definition Classes
    BindingValidatorImplicits
  49. implicit def validatableSeqBinding[T <: Seq[_]](b: FieldDescriptor[T]): ValidatableSeq[T]

    Definition Classes
    BindingValidatorImplicits
  50. implicit def validatableStringBinding(b: FieldDescriptor[String]): ValidatableStringBinding

    Definition Classes
    BindingValidatorImplicits
  51. final def wait(): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  52. final def wait(arg0: Long, arg1: Int): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()
  53. final def wait(arg0: Long): Unit

    Definition Classes
    AnyRef
    Annotations
    @throws()

Inherited from BindingSyntax

Inherited from BindingValidatorImplicits

Inherited from AnyRef

Inherited from Any