Class

com.hacklanta.formality

BaseFieldHolder

Related Doc: package formality

Permalink

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

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.

Linear Supertypes
FieldHolderBase[FieldValueType], AnyRef, Any
Known Subclasses
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. BaseFieldHolder
  2. FieldHolderBase
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new BaseFieldHolder(selector: String, initialValue: Box[FieldValueType], validations: List[Validation[ValidationType]], boxedValidations: List[Validation[Box[ValidationType]]], eventHandlers: List[EventHandler[EventHandlerType]])(implicit eventHandlerValueConverter: (String) ⇒ Box[FieldValueType])

    Permalink

    selector

    The CSS selector that identifies the field we'll be binding to in the template. Note that the minimum amount of changes are made to that field. For example, the type of the field (type="string", number, etc) is left up to the template.

    initialValue

    The initial value of the form field. This will be serialized using the valueSeralizer.

    eventHandlerValueConverter

    In most cases the same as the valueConverter. File uplaods, as one example of when this isn't the case, convert a FileParamHolder, but their event handlers still get a String.

Abstract Value Members

  1. abstract def convertValue(incomingValue: IncomingValueType): Box[FieldValueType]

    Permalink
    Attributes
    protected
  2. abstract def generateFunctionIdAndHandler: String

    Permalink

    Creates a handler function, maps it (potentially using S.fmapFunc), and returns the resulting function id to bind to the HTML field.

    Creates a handler function, maps it (potentially using S.fmapFunc), and returns the resulting function id to bind to the HTML field. See the implementation in SimpleFieldHolder for a sample.

    Attributes
    protected
  3. abstract def handlingEvent(eventHandler: EventHandler[EventHandlerType]): BaseFieldHolder[IncomingValueType, FieldValueType, ValidationType, EventHandlerType]

    Permalink

    This should return a copy of this BaseFieldHolder with the specified event handler attached.

    This should return a copy of this BaseFieldHolder with the specified event handler attached. Left abstract because by far the best implementation is using a case class copy method.

  4. abstract def serializeValue(value: FieldValueType): String

    Permalink
    Attributes
    protected
  5. abstract def validatingWith(boxedValidation: Validation[Box[ValidationType]])(implicit dummy: DummyImplicit): BaseFieldHolder[IncomingValueType, FieldValueType, ValidationType, EventHandlerType]

    Permalink

    This should return a copy of this BaseFieldHolder with the specified validation attached.

    This should return a copy of this BaseFieldHolder with the specified validation attached. Left abstract because by far the best implementation is using a case class copy method.

  6. abstract def validatingWith(validation: Validation[ValidationType]): BaseFieldHolder[IncomingValueType, FieldValueType, ValidationType, EventHandlerType]

    Permalink

    This should return a copy of this BaseFieldHolder with the specified validation attached.

    This should return a copy of this BaseFieldHolder with the specified validation attached. Left abstract because by far the best implementation is using a case class copy method.

Concrete Value Members

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

    Permalink
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int

    Permalink
    Definition Classes
    AnyRef → Any
  3. def ->(eventHandler: EventHandler[EventHandlerType]): BaseFieldHolder[IncomingValueType, FieldValueType, ValidationType, EventHandlerType]

    Permalink

    Adds the given event handler to the list of event handlers this field will have on the client.

    Adds the given event handler to the list of event handlers this field will have on the client. See EventHandler for more. Meant to be used with Formality.on for fluency (e.g., field -> on("change", checkStuff _)).

    Note that FieldHolders are immutable; this returns a copy of this FieldHolder with an updated event handler list.

    Aliased as handlingEvent for folks who don't like operators.

  4. final def ==(arg0: Any): Boolean

    Permalink
    Definition Classes
    AnyRef → Any
  5. def ?(boxedValidation: Validation[Box[ValidationType]])(implicit dummy: DummyImplicit): BaseFieldHolder[IncomingValueType, FieldValueType, ValidationType, EventHandlerType]

    Permalink

    Adds the given boxed validation to the list of validations run on this field at form processing time.

    Adds the given boxed validation to the list of validations run on this field at form processing time. Note that validations may add attributes to the field to indicate on the client side what types of validations are expected; see the Validation trait for more.

    Note that FieldHolders are immutable; this returns a copy of this FieldHolder with an updated validation list.

    Aliased as validatingWith for folks who don't like operators.

  6. def ?(validation: Validation[ValidationType]): BaseFieldHolder[IncomingValueType, FieldValueType, ValidationType, EventHandlerType]

    Permalink

    Adds the given validation to the list of validations run on this field at form processing time.

    Adds the given validation to the list of validations run on this field at form processing time. Note that validations may add attributes to the field to indicate on the client side what types of validations are expected; see the Validation trait for more.

    Note that FieldHolders are immutable; this returns a copy of this FieldHolder with an updated validation list.

    Aliased as validatingWith for folks who don't like operators.

  7. def addValidationErrors(errorMessages: String*): Unit

    Permalink

    Adds the passed error messages, using S.error.

    Adds the passed error messages, using S.error. Can be overridden to use something other than S.error.

    Attributes
    protected
  8. final def asInstanceOf[T0]: T0

    Permalink
    Definition Classes
    Any
  9. def baseTransform: CssSel

    Permalink

    Defines the base transform that adds the function id and initial value to the HTML field specified in the selector parameter.

    Defines the base transform that adds the function id and initial value to the HTML field specified in the selector parameter. When overriding, it is highly suggested that you call super.baseTransform and append your own transforms to that.

    Attributes
    protected
  10. def binder: CssSel

    Permalink

    Provides the CSS transform that transforms an input field in the template into one that will be processed by this field's value conversion and validation functions, that will have the provided initial value, and that will run this field's associated callbacks for the event handlers it has specified.

    Provides the CSS transform that transforms an input field in the template into one that will be processed by this field's value conversion and validation functions, that will have the provided initial value, and that will run this field's associated callbacks for the event handlers it has specified.

    If you override the binder, please make sure you properly map your handler function, event handlers, and validations. This binder automatically calls generateFunctionIdAndHandler and binds its result to the name of the HTML field, and your code must do something similar to ensure the server-side function you define is called on form submission.

    Definition Classes
    BaseFieldHolderFieldHolderBase
  11. def clone(): AnyRef

    Permalink
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  12. def computeFieldValue: Box[FieldValueType]

    Permalink

    Computes the final field value and applies any validations.

    Computes the final field value and applies any validations. Ensures validations only run once no matter how many times the field value is accessed.

    Attributes
    protected
  13. val computedFieldValue: FieldValueVar[FieldValueType]

    Permalink

    This is the final computed field value after all validations have been handled.

    This is the final computed field value after all validations have been handled. It memoizes the result of computeFieldValue.

    Attributes
    protected
  14. final def eq(arg0: AnyRef): Boolean

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

    Permalink
    Definition Classes
    AnyRef → Any
  16. val fieldName: FieldNameVar

    Permalink

    Stores the field name generated by generateFunctionIdAndHandler.

    Stores the field name generated by generateFunctionIdAndHandler. The current field name should be accessed from here rather than directly through generateFunctionIdAndHandler except in case of clear preference.

    Attributes
    protected
  17. val fieldValue: FieldValueVar[FieldValueType]

    Permalink

    The handler function should set this TransientRequestVar to the appropriate value.

    The handler function should set this TransientRequestVar to the appropriate value.

    Attributes
    protected
  18. def finalize(): Unit

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

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

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

    Permalink
    Definition Classes
    Any
  22. final def ne(arg0: AnyRef): Boolean

    Permalink
    Definition Classes
    AnyRef
  23. final def notify(): Unit

    Permalink
    Definition Classes
    AnyRef
  24. final def notifyAll(): Unit

    Permalink
    Definition Classes
    AnyRef
  25. final def synchronized[T0](arg0: ⇒ T0): T0

    Permalink
    Definition Classes
    AnyRef
  26. def toString(): String

    Permalink
    Definition Classes
    AnyRef → Any
  27. def value: Box[FieldValueType]

    Permalink

    Returns the current value of the field.

    Returns the current value of the field. If no value was seen in the last form submission, invokes boxedValidations and registers any resulting validation errors.

    Definition Classes
    BaseFieldHolderFieldHolderBase
  28. final def wait(): Unit

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

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

    Permalink
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Inherited from FieldHolderBase[FieldValueType]

Inherited from AnyRef

Inherited from Any

Ungrouped