Simple Attributes

 

Each vector layer has a series of attributes attached to each feature. These attributes are defined in the FeatureType, and are separated into simple attributes and associations. This page will show you how to configure simple attributes. That means attribute of the following types: 

boolean, short, integer, long, float, double, string, date

 

The basics of attributes

Let us first examine an example, take from the african countries layer from the tutorial application shipped with geomajas 1.3.1: 

<attribute>
	<label>OPEC</label>
	<name>OPEC</name>
	<editable>true</editable>
	<identifying>true</identifying>
	<type>integer</type>
	<validator>
		<constraints>{min:0, max:1}</constraints>
		<required>true</required>
		<promptMessage>Member of OPEC?</promptMessage>
		<invalidMessage>Invalid value</invalidMessage>
		<rangeMessage>Out of range</rangeMessage>
	</validator>
</attribute>
Let us now go over the different tags:
  • label : The label for the attribute, used on the client.
  • name : The actual name of the attribute as known by the layermodel. These name are different for different LayerModels:
    • ShapeInMemLayerModelFactory : Use the names as they are in the .DBF file. Capitals letters!
    • GeotoolsLayerModelFactory : Use the names of the attributes of the geotools featuretypes.
    • HibernateLayerModelFactory : Use the names as they are derived from the getters of the JAVA object. When you have a getter called "getPopulation()", fill in "population".
  • editable : Is this attribute editable or not? (true or false)
  • identifying : Is this one of the base attributes or not (true or false)? If false it will not be shown in the FeatureListTable widget, but only when checking the feature in detail.
  • type : One of the following: boolean, short, integer, long, float, double, string, date
  • validator (optional) : Adds the possibility to validate values when the attribute is being edited. See next paragraph.

 

The optional validator

If the validator is present in the attribute definition, then it must contain the following tags:

  • constraints : A JSON string with constraints. It is necessary that the keys and values declared herein can be interpreted by the Dojo widgets that are used when editing this attribute. See the Dojo documentation for more information on this.
  • required : Can this value be empty or not? (true or false) If true, it can never be empty!
  • promptMessage : General message explaining what this attribute represents.
  • invalidMessage : Message displayed when the user is typing unacceptabled input. (for example when a string in being typed for an integer type attribute, or when the constraints are simply not obeyed)
  • rangeMessage : In case of number or date attributes, this message is used when the maximum allowed range is exceeded.