Start page / Plug-In Development / Universal Extensions / Input Components / GOM Form Element / XML Tag Attributes

XML Tag Attributes

Above and beyond the XML tag attributes already specified by AbstractGomFormElement, a GOM form element class may specify additional attributes by implementing method pairs that each include one getter method and one setter method for their respective attribute value. The names of these methods always follow the same pattern:

  • get + attribute name (first letter capitalized, the remaining letters' capitalization is preserved)
  • set + attribute name (first letter capitalized, the remaining letters' capitalization is preserved)

Getter Method Annotations

The getter method must be annotated with @GomDoc, which provides information about the purpose and availability of the attribute.

This annotation as well as optional other annotations are described below:

Annotation

Usage

Notes

@GomDoc
marks the annotated method or class as a GOM object and provides descriptive information.

@GomDoc(description="<text>", since="<version>")

description contains a short description of the annotated method or class.

since contains the version with which the annotated method or class first became available.

Mandatory annotation on all getter methods which are intended to be represented by GOM element attributes.

@Default
specifies a default value for the annotated attribute.

@Default("<value>")

value contains the default value as a String object to document the value which will be applied to the annotated attribute's value if no value is explicitly set.

Only used for documentation.

@InheritAnnotations
causes the annotation processor to apply annotations from a superclass' or an interface's method with the same signature.

@InheritAnnotations

This annotation does not have any parameters.

The superclass' or interface's method must possess explicit annotations or inherit annotations from another source.

   

Example

For example, in order to specify an attribute forceUppercase, implement the methods getForceUppercase() (including @GomDoc annotation) and setForceUppercase(...). Note the CamelCase notation of the attribute name, with its first letter capitalized, while the remaining letters' capitalization is preserved.

...

private YesNo _forceUppercase = YesNo.NO;

@GomDoc(description="Convert all input to UPPERCASE", since="1.47")
@Default("no")
public YesNo getForceUppercase() {
return _forceUppercase;
}

public void setForceUppercase(final YesNo forceUppercase) {
_forceUppercase = forceUppercase;
}

....

Supplying these methods will cause FirstSpirit to accept an attribute forceUppercase in the input component's XML tag:

<CMS_MODULE>
<CUSTOM_INPUT_COMPONENT name="myCustomInputComponent" forceUppercase="no">
<LANGINFOS>
<LANGINFO lang="*" label="Custom InputComponent" />
</LANGINFOS>
</CUSTOM_INPUT_COMPONENT>
</CMS_MODULE>
Important The above code example showing getter and setter methods assume that the YesNo objects these methods operate on are never null. This results in the attribute always being added to a GOM form definition upon code completion or save, even if it has not been explicitly specified. If the attribute should be made truly optional (i.e., not appear in a GOM form definition unless explicitly specified), the getter method as well as the YesNo parameter of the setter method should be annoted as nullable (e.g. @Nullable), and the field (in the example, _forceUppercase) should not be initialized with a default value.

© 2005 - 2024 Crownpeak Technology GmbH | All rights reserved. | FirstSpirit 2024.13 | Data privacy