Type (attribute of property)
From JRapid
type is an attribute of property.
Contents |
Description
The data type that defines a property.
A property can be either of a built-in data type, such as string, integer or date, an image or file, or it may be an entity-type.
Each type has it's own autogenerated way of displaying and validating. You can change the way a property is displayed by changing the widget attribute.
If you don't specify a type, the default is the String type.
The type attribute sets the type of data that a property will be able to store. This may be a built-in data type, such as string, integer or date, or it may be an entity-type.
A property may take one of the following data types:
- Numeric
- id: All entities have an implicit autoincremental and primary key int field called id to identify each row. If a transient field named id is added to the entity, it will take the same value as the primary key.
- double
- float
- integer
- long
- boolean.
- Text
- string
- text
- longtext
- enum: each enumeration is added with a subelement of this property. See enum
- Dates
- date - Example value: 28/12/2010
- time - Example value: 15:30
- datetime - Example value: 28/12/2010 14:20
- timerange - Example value: 11:15 - 11:45
- timequantity - Example value: 3d 1h 15m
- Others
- file
- password
- image
- phone
- url
Usage
<entity ...>
<property
name = NAME
label = LABEL
entity = ENTITY | type = TYPE
...
/>
...
<entity/>
Example
- A property of type entity:
<property display="primary" entity="Seller" label="Responsable" name="seller">
The default widget for entity-type properties is an HTML select element.
- A property of type image:
<property label="Image" name="logo" type="image"/>
Image-type properties are displayed as a small box with the image and a filechooser button.
- When using price properties it is important to set them as double types so that they are not considered strings an calculations can be done with them.
<property name="price" label="Price" type="double" />
