FieldΒΆ
-
/libs/granite/ui/components/foundation/form/field
Field is an abstract component that is extended by the actual field implementation, such as
textfield
. It is created to make creating a form field easier. It handles:- field label and field description
- read-only mode
- root field (
com.adobe.granite.ui.components.ComponentHelper.Options#rootField
)
Life Cycle
It will call the following scripts in order:
- init.jsp
- This script needs to set a ValueMap to the request attribute, like so
request.setAttribute(com.adobe.granite.ui.components.Field.class.getName(), vm);
. The value map needs to contain at least property namedvalue
that is storing the value of the field. The implementor is free to put any property to this map, though it is encouraged to namespace the property name to avoid future conflict. By default Field is giving default implementation of init.jsp, setting the value to ofvalue
property of typeStringEL
. This map is also available during the calling ofrender.jsp
. - render.jsp
This is where the actual rendering of the actual field is performed.
At this point the field also set
labelId
key to ValueMap described atinit.jsp
. This labelId is used to set theid
attribute of the label. The actual field should make use of this labelId to set the appropriate ARIA attribute (e.g.aria-labelledby
) accordingly.
Read-only Mode
This feature is enabled by setting
renderReadOnly
property to true. The read-only version of the component is rendered by including the read-only resource type. Consultcom.adobe.granite.ui.components.ComponentHelper#getReadOnlyResourceType
for details. If read-only resource type is not available, no read-only version is rendered. The value set duringinit.jsp
will be inspected to check if it is empty. If it is empty the read-only mode will be hidden, unlessshowEmptyInReadOnly
property is set to true in the content.Content Structure
-
granite:FormField
- granite:renderCondition
- fieldLabelstring
- i18n
The label of the component.
- fieldDescriptionstring
- i18n
The description of the component.
- renderReadOnlyboolean
Renders the read-only markup as well.
- showEmptyInReadOnlyboolean
Shows read-only version even when it has empty value or unchecked.
- renderHiddenboolean
true
to hide the whole field (including the wrapper);false
otherwise.