Overview | File | Class | Tree | Index | Help
| Jala 1.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## Class jala.Form.Component.Input

    Object
       |
       +--jala.Form.Component.Input

Direct Known Subclasses:
  jala.Form.Component.Hidden, jala.Form.Component.Checkbox, jala.Form.Component.File, jala.Form.Component.Password, jala.Form.Component.Button, jala.Form.Component.Select, jala.Form.Component.Textarea, jala.Form.Component.Date

class jala.Form.Component.Input

Instances of this class represent a single form input field.
Defined in Form.js

Constructor Summary
`jala.Form.Component.Input (<String> name)` Creates a new input component instance.

Method Summary
`String` | `checkLength(<Object> reqData)` Checks user input for maximum length, minimum length and require if the corresponding options have been set using the require method.
`String` | `checkRequirements(<Object> reqData)` Checks user input against options set using the require method.
`void` | `class_macro()` Renders this component's class name.
`void` | `controls_macro()` Renders the control(s) of this component
`void` | `error_macro()` Renders this component's error message (if set) directly to response
`Object` | `getControlAttributes()` Creates a new attribute object for this element.
`String|Number|Date` | `getValue()` Retrieves the property which is edited by this component.
`void` | `help_macro()` Renders this component's help text, if set.
`void` | `id_macro()` Renders this component's id
`void` | `label_macro()` Renders this component's label.
`void` | `name_macro()` Renders this component's name
`Object` | `parseValue(<Object> reqData)` Parses the string input from the form and creates the datatype that is edited with this component.
`void` | `render()` Renders this component including label, error and help messages directly to response.
`void` | `render_macro()` Renders this component including label, error and help messages directly to response
`void` | `renderControls(<Object> attr, <Object> value, <Object> reqData)` Renders the html form elements to the response.
`String` | `renderError()` If the error tracker holds an error message for this component, it is wrapped in a div-tag and returned as a string.
`String` | `renderHelp()` If this component contains a help message, it is wrapped in a div-tag and returned as a string.
`String` | `renderLabel()` Returns the rendered label of this component
`void` | `save(<jala.Form.Tracker> tracker, <Object> destObj)` Saves the parsed value using setValue.
`Object` | `setValue(<Object> destObj, <Object> value)` Sets a property of the object passed as argument to the given value.
`void` | `type_macro()` Renders this component's type
`void` | `validate(<jala.Form.Tracker> tracker)` Validates the input provided to this component.

Constructor Detail

### jala.Form.Component.Input

    jala.Form.Component.Input(<String> name)

Creates a new input component instance.

Parameters:

`name` - Name of the component, used as name of the html control.

Method Detail

### checkLength

    String checkLength(<Object> reqData)

Checks user input for maximum length, minimum length and require if the corresponding options have been set using the require method.

Parameters:

`reqData` - request data

Returns:

String containing error message or null if everything is ok.

See:

- require

### checkRequirements

    String checkRequirements(<Object> reqData)

Checks user input against options set using the require method.

Parameters:

`reqData` - request data

Returns:

String containing error message or null if everything is ok.

See:

- checkLength()
- require

### class_macro

    void class_macro()

Renders this component's class name. Note that this is just the class name that has been explicitly assigned using setClassName.

See:

- setClassName

### controls_macro

    void controls_macro()

Renders the control(s) of this component

### error_macro

    void error_macro()

Renders this component's error message (if set) directly to response

### getControlAttributes

    Object getControlAttributes()

Creates a new attribute object for this element.

Returns:

Object with properties id, name, class

### getValue

    String|Number|Date getValue()

Retrieves the property which is edited by this component.

- If no getter is given, the method returns the primitive property of the data object with the same name as the component.
- If a getter function is defined, it is executed with the scope of the data object and the return value is used as default value. The name of the component is passed to the getter function as an argument.

Returns:

The value of the property

### help_macro

    void help_macro()

Renders this component's help text, if set.

### id_macro

    void id_macro()

Renders this component's id

See:

- jala.Form.createDomId()

### label_macro

    void label_macro()

Renders this component's label.

### name_macro

    void name_macro()

Renders this component's name

### parseValue

    Object parseValue(<Object> reqData)

Parses the string input from the form and creates the datatype that is edited with this component. For the input component this method is not of much use, but subclasses that edit other datatypes may use it. For example, a date editor should convert the user input from string to a date object.

Parameters:

`reqData` - request data

Returns:

parsed value

### render

    void render()

Renders this component including label, error and help messages directly to response.

### render_macro

    void render_macro()

Renders this component including label, error and help messages directly to response

### renderControls

    void renderControls(<Object> attr, <Object> value, <Object> reqData)

Renders the html form elements to the response. This method shall be overridden by subclasses of input component.

Parameters:

`attr` - Basic attributes for the html form elements.

`value` - Value to be used for rendering this element.

`reqData` - Request data for the whole form. This argument is passed only if the form is re-rendered after an error occured.

### renderError

    String renderError()

If the error tracker holds an error message for this component, it is wrapped in a div-tag and returned as a string.

Returns:

Rendered string

### renderHelp

    String renderHelp()

If this component contains a help message, it is wrapped in a div-tag and returned as a string.

Returns:

The rendered help message

### renderLabel

    String renderLabel()

Returns the rendered label of this component

Returns:

The rendered label of this component

### save

    void save(<jala.Form.Tracker> tracker, <Object> destObj)

Saves the parsed value using setValue.

Parameters:

`tracker` - Tracker object collecting request data, error messages and parsed values.

`destObj` - (optional) object whose values will be changed.

See:

- setValue()

### setValue

    Object setValue(<Object> destObj, <Object> value)

Sets a property of the object passed as argument to the given value.
- If no setter is set at the component, the primitive property of the data object is changed.
- If a setter function is defined it is executed with the data object as scope and with the name and new value provided as arguments
- If the setter is explicitly set to null, no changes are made at all.

Parameters:

`destObj` - (optional) object whose values will be changed.

`value` - The value to set the property to

Returns:

True in case the update was successful, false otherwise.

See:

- jala.Form.setter

### type_macro

    void type_macro()

Renders this component's type

### validate

    void validate(<jala.Form.Tracker> tracker)

Validates the input provided to this component. First, checkRequirements is called. If no error occurs, the input is parsed using parseValue and passed on to the validator function.

Parameters:

`tracker` - Tracker object collecting request data, error messages and parsed values.

See:

- checkRequirements()
- parseValue()

Overview | File | Class | Tree | Index | Help
| Jala 1.2
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

Documentation generated by JSDoc on Tue May 29 10:26:15 2007