Package

com.hacklanta

formality

Permalink

package formality

Visibility
  1. Public
  2. All

Type Members

  1. case class AjaxFormalityForm[FieldList <: HList, FieldBoxList <: HList, FieldValueList <: HList, FunctionType, BoxedFunctionType](fields: FieldList, computeValues: () ⇒ (FieldBoxList, Result[FieldValueList]), bindFields: CssSel, submissionHandlers: List[(FieldBoxList) ⇒ Unit], successHandlers: List[(FieldValueList) ⇒ JsCmd], failureHandlers: List[(List[Failure]) ⇒ JsCmd]) extends FormalityForm[FieldList, FieldBoxList, FieldValueList, JsCmd, FunctionType, BoxedFunctionType] with Product with Serializable

    Permalink
  2. abstract class BaseFieldHolder[IncomingValueType, FieldValueType, ValidationType >: FieldValueType, EventHandlerType >: FieldValueType] extends FieldHolderBase[FieldValueType]

    Permalink

    FieldHolder represents a form field that processes a value of type FieldValueType, and that can run a set of validations on the incoming field value when it is submitted.

    FieldHolder represents a form field that processes a value of type FieldValueType, and that can run a set of validations on the incoming field value when it is submitted. It can also attach event handler callbacks that call back to the server with the current inputted value when certain events occur on the client.

    This base provides about 80% of the structure that most fields will share. It provides an overridable handler function that will handle the field when it is submitted in a form. This can be overridden by child classes for e.g. file handling.

  3. case class CheckboxFieldHolder(selector: String, initialValue: Boolean, validations: List[Validation[Boolean]], boxedValidations: List[Validation[Box[Boolean]]], eventHandlers: List[EventHandler[Boolean]]) extends BaseFieldHolder[String, Boolean, Boolean, Boolean] with Product with Serializable

    Permalink
  4. case class EventHandler[T](eventName: String, eventHandler: (T) ⇒ JsCmd, invalidValueHandler: Box[(ParamFailure[String]) ⇒ JsCmd] = Empty) extends Product with Serializable

    Permalink

    EventHandler is a simple class that binds an event on a field to a server-side function that will be invoked with the converted value of the field whenever that event fires on the client.

    EventHandler is a simple class that binds an event on a field to a server-side function that will be invoked with the converted value of the field whenever that event fires on the client. Optionally, you can also specify a function to be invoked in case the value arrives but cannot be converted to the target type.

    invalidValueHandler

    If Full, this specifies a function that will run if the specified event triggers on the client, but the value in the field on the client cannot be converted to the expected type T. In this case, the provided function is invoked with ParamFailure that carries the error associated with the conversion failure, and whose param is the value on the client, as an unconverted String.

  5. case class FieldGroup[CombinedType, FieldBoxList <: HList, HeadFieldValueType, RestFieldValueTypes <: HList](scopingSelector: Option[String], converter: Either[(:+:[HeadFieldValueType, RestFieldValueTypes]) ⇒ Box[CombinedType], (FieldBoxList) ⇒ Box[CombinedType]], computeValues: () ⇒ (FieldBoxList, CombinableBox[HeadFieldValueType, RestFieldValueTypes]), bindFields: CssSel) extends FieldHolderBase[CombinedType] with Product with Serializable

    Permalink
  6. case class FieldGroupBase extends Product with Serializable

    Permalink
  7. trait FieldHolderBase[FieldValueType] extends AnyRef

    Permalink

    A FieldHolder, at its most basic, has a value that is a Box of its value type and can provide a CSS selector to transform an HTML template annotating a form field with the appropriate information to extract that value during a form submission.

  8. trait FieldValueHelpers extends AnyRef

    Permalink

    Two things live here: value serializers, value converters.

    Two things live here: value serializers, value converters. Value serializers are T=>String functions, value converters are String=>Box[T] functions (the round trips to/from Strings for field values).

    These are all implicits so that they can be plugged into implicit resolution for FieldHolders.

  9. case class FileFieldHolder[FieldValueType, ValidationType >: FieldValueType, EventHandlerType >: FieldValueType](selector: String, validations: List[Validation[ValidationType]], boxedValidations: List[Validation[Box[ValidationType]]], eventHandlers: List[EventHandler[EventHandlerType]])(implicit valueConverter: (FileParamHolder) ⇒ Box[FieldValueType]) extends BaseFieldHolder[FileParamHolder, FieldValueType, ValidationType, EventHandlerType] with Product with Serializable

    Permalink

    This case class creates a field holder for a field that gets a FileParamHolder from the client.

    This case class creates a field holder for a field that gets a FileParamHolder from the client. File upload fields behave this way.

    Note that FileFieldHolders do not have value serializers: they always produce an empty string for their serialized value when setting a value on the client. It also takes no initial value for the same reason.

  10. abstract class FormalityForm[FieldList <: HList, FieldBoxList <: HList, FieldValueList <: HList, RequestResultType, FunctionType, BoxedFunctionType] extends AnyRef

    Permalink
  11. case class FormalityFormBase extends Product with Serializable

    Permalink
  12. case class FormalityFormProto[FieldList <: HList, FieldBoxList <: HList, HeadFieldValueType, RestFieldValueTypes <: HList] extends Product with Serializable

    Permalink

    FormalityFormProto is the starting point for creating a formality form.

    FormalityFormProto is the starting point for creating a formality form. It uses a lot of type magic, so that is going to be detailed here. At its most basic, however, it simply tracks a type-preserving list of FieldHolderBases and provides a single function, withField, to add a new such field to the form.

    Once you've added all the fields you want, call formalize. This returns a FormalityForm, on which you can set success/failure/submission handlers, and which provides the facility to convert the form down to a single CssSel instance that will properly set up the form and all of its fields.

    Typing discussion ---------------

    shapeless lets us track our list of fields that can be String fields, Int fields, DateMidnight fields, or any other arbitrary type, while preserving those types and their order. As we build this list up, we call withField and add fields to the list one by one.

    Because of what we need to do once we convert to a FormalityForm.

  13. trait Html5Validations extends AnyRef

    Permalink
  14. case class MultiSelectFieldHolder[FieldValueType, ValidationType >: FieldValueType, EventHandlerType >: FieldValueType](selector: String, initialValues: List[FieldValueType], options: List[net.liftweb.http.SHtml.SelectableOption[FieldValueType]], validations: List[Validation[List[ValidationType]]], boxedValidations: List[Validation[Box[List[ValidationType]]]], eventHandlers: List[EventHandler[List[EventHandlerType]]], asCheckboxes: Boolean) extends BaseFieldHolder[String, List[FieldValueType], List[ValidationType], List[EventHandlerType]] with Product with Serializable

    Permalink

    This case class creates a field holder for a multi select field that gets a list of Strings from the client.

    This case class creates a field holder for a multi select field that gets a list of Strings from the client. If asCheckboxes is true, the binder created for this select field is designed to bind to checkboxes and their labels instead of producing a select field.

    When dealing with select elements (i.e., asCheckboxes is false), the whole element specified by selector will be replaced by a new select element.

    When asCheckboxes is true, the element specified by selector will be repeated once for each of the passed options. The option label will be used to set the text of the label. If the checkbox is nested in the label, it will be left at the end of the label. If a given SelectableOption specifies an id attribute, in addition to that attribute being set on the checkbox, the for attribute of the label element (if present) will be set to the same value.

  15. case class SelectFieldHolder[FieldValueType, ValidationType >: FieldValueType, EventHandlerType >: FieldValueType](selector: String, initialValue: Box[FieldValueType], options: List[net.liftweb.http.SHtml.SelectableOption[FieldValueType]], validations: List[Validation[ValidationType]], boxedValidations: List[Validation[Box[ValidationType]]], eventHandlers: List[EventHandler[EventHandlerType]], asRadioButtons: Boolean) extends BaseFieldHolder[String, FieldValueType, ValidationType, EventHandlerType] with Product with Serializable

    Permalink

    This case class creates a field holder for a select field that gets a String from the client.

    This case class creates a field holder for a select field that gets a String from the client. If asRadioButtons is true, the binder created for this select field is designed to bind to radio buttons and their labels instead of producing a select field.

    When dealing with select elements (i.e., asRadioButtons is false), the whole element specified by selector will be replaced by a new select element.

    When asRadioButtons is true, the element specified by selector will be repeated once for each of the passed options. The option label will be used to set the text of the label. If the radio button is nested in the label, it will be left at the end of the label. If a given SelectableOption specifies an id attribute, in addition to that attribute being set on the radio button, the for attribute of the label element (if present) will be set to the same value.

  16. case class SimpleFieldHolder[FieldValueType, ValidationType >: FieldValueType, EventHandlerType >: FieldValueType](selector: String, initialValue: Box[FieldValueType], validations: List[Validation[ValidationType]], boxedValidations: List[Validation[Box[ValidationType]]], eventHandlers: List[EventHandler[EventHandlerType]])(implicit valueConverter: (String) ⇒ Box[FieldValueType], valueSerializer: (FieldValueType) ⇒ String) extends BaseFieldHolder[String, FieldValueType, ValidationType, EventHandlerType] with Product with Serializable

    Permalink

    This case class creates a field holder for a simple field that gets a String from the client.

  17. case class StandardFormalityForm[FieldList <: HList, FieldBoxList <: HList, FieldValueList <: HList, FunctionType, BoxedFunctionType](fields: FieldList, computeValues: () ⇒ (FieldBoxList, Result[FieldValueList]), bindFields: CssSel, submissionHandlers: List[(FieldBoxList) ⇒ Unit], successHandlers: List[(FieldValueList) ⇒ Unit], failureHandlers: List[(List[Failure]) ⇒ Unit]) extends FormalityForm[FieldList, FieldBoxList, FieldValueList, Unit, FunctionType, BoxedFunctionType] with Product with Serializable

    Permalink
  18. trait Validation[T] extends (T) ⇒ Box[String]

    Permalink

    A Validation that validates a value of type T.

    A Validation that validates a value of type T. It should return a Box[String] that is Full with a validation error if there are validation problems, or an empty box if there are no such problems.

    Validations can provide a css selector that attaches validation-related attributes to the input field.

    There is an implicit conversion from a (T)=>Box[String] function to a Validation[T] that simply makes no changes to the relevant input field

  19. class basicInRange extends Validation[Int]

    Permalink

    Provides basic checking that a number is within a range.

    Provides basic checking that a number is within a range. This can be used standalone, but it's recommended that you use it via one of its subclasses that also provides client-side annotations for the range.

    The range is inclusive.

    Example: myField ? basicInRange(0, 100)

  20. class basicNotEmpty extends Validation[Box[String]]

    Permalink

    Provides basic checking that a string is not empty.

    Provides basic checking that a string is not empty. This can be used standalone, but it's recommended that you use it via one of its subclasses that also provides client-side annotations for the range.

    Example: myField ? basicNotEmpty

Value Members

  1. object AjaxFormalityForm extends Serializable

    Permalink
  2. object FieldGroup extends Serializable

    Permalink
  3. object Formality extends FieldValueHelpers

    Permalink
  4. object FormalityFormHelper

    Permalink
  5. object FormalityFormProto extends Serializable

    Permalink
  6. object Html5Validations extends Html5Validations

    Permalink

    Contains validations that apply HTML5 attributes to support them on the client.

  7. object ParsleyValidations extends Html5Validations

    Permalink

    Contains validations that apply parsley.js attributes to support them on the client.

    Contains validations that apply parsley.js attributes to support them on the client. Validation names follow parsley.js names.

    FIXME These are incomplete.

  8. object StandardFormalityForm extends Serializable

    Permalink
  9. object Validation

    Permalink
  10. object basicInRange

    Permalink
  11. object basicNotEmpty

    Permalink

Ungrouped