Class Form
- All Implemented Interfaces:
Animatable<Form>
,CanDrop<Form>
,Draggable<Form>
,Focusable<Form>
,HandleHotKey<Form>
,HandleMouseEvents<Form>
,BasedOnDataDescriptor<Form>
,Scrollable<Form>
Form component
The form component display a form on the interface, in which the user can input various data. The component is able to create and handle an entire form, based on a DataDescriptor. It also allows the inputted data to be validated, and handles the events related to editing data. The component implements the database data saving and data editing operations. It is compatible by the framework's DataDescriptor and records.
The component also allows the inputted data to be sent to a servlet, that can be implemented in the application, or an outside one. The data can be sent, according to HTML standards, with a POST or GET message, but this is not needed during normal use, since every data inputted by the user is accessible on the server side, at all times as well.
The form handles every form item component, thus the modification and query of the individual form item values are handled. If the form component is used to edit data, then the values of the form items can be accessed through the form.
The data inputted by the user can also be validated through the form. By default this only checks if mandatory fields are filled out, but a custom validator class can be created by
implementing the FormValidator
interface. In this case, the default validator will not function, only the custom one.
The custom validator can be passed to the form by using the setFormValidator(FormValidator)
method
The form component supports multiple display types, allowing for the implementation of simple and complex forms. By default the DefaultFormBuilder
is used, that creates a simple form.
The framework offers other form builder classes, these are described in the FormBuildType
enum. A custom form builder can also be created, by implementing the FormBuilder
interface. The custom form builder implementation can be set by using the setBuildType(FormBuildType, FormBuilder)
method.
Supported events:
AnimationStart
AnimationEnd
,
Focus
FocusOut
FocusIn
LosesFocus
MouseDown
,
MouseDown
,
MouseLeave
,
MouseMove
,
MouseOver
,
MouseOut
,
MouseUp
,
Wheel
,
Scrollable
Drop
,
DragStart
,
DragEnd
HotKey
- Since:
- 4.0
- Author:
- JBStrap
- See Also:
-
Field Summary
Fields inherited from class com.jbstrap.ui.Component
animation, attributes, backgroundColor, borderColor, color, defaultHotKeyHandler, handlers, hotKeys, styleClasses, textAlign, toolTip, toolTipPosition
-
Constructor Summary
ConstructorDescriptionForm()
Creates an empty form componentForm
(DataDescriptor dataDescriptor) Creates a form, based on the specified DataDescriptor.Form
(DataDescriptor dataDescriptor, String language) Creates a form, based on the specified DataDescriptor, with the specified language.Form
(FormEncoding encode) Creates an empty form component, with the specified encoding.Form
(FormEncoding encode, String language) Creates an empty form component, with the specified encoding and language code.Form
(FormMethod method) Creates an empty form component, and sets the form send type.Form
(FormMethod method, String language) Creates an empty form component, sets the form send type and language code.Creates an empty form component, with the specified languageForm
(String id, DataDescriptor dataDescriptor) Creates a form, based on the specified DataDescriptor.Form
(String id, DataDescriptor dataDescriptor, String language) Creates a form, based on the specified DataDescriptor, with the specified language.Form
(String id, FormEncoding encode) Creates an empty form component, with the specified encoding.Form
(String id, FormEncoding encode, String language) Creates an empty form component, with the specified encoding and language code.Form
(String action, FormMethod method, FormEncoding encode) Creates an empty form, with the specified action, encoding, and method.Form
(String action, FormMethod method, FormEncoding encode, String language) Creates an empty form, with the specified action, encoding, method and language.Creates an empty form component, with the specified languageForm
(String id, String action, FormMethod method, FormEncoding encode) Creates an empty form, with the specified action, encoding, and method.Form
(String id, String action, FormMethod method, FormEncoding encode, String language) Creates an empty form, with the specified action, encoding, method and language. -
Method Summary
Modifier and TypeMethodDescriptionfinal Form
Creates a form block on the formfinal Form
Creates a form column on the formaddComponent
(Component<?> component) Adds the specified component as a subcomponent, and redraws the component immediatelyfinal Form
addTabPage
(String tabPageName, Icon icon, String title) Creates a tab page on the formeditRecord
(Record record) Starts the editing of the specified record in the form component.final String
Gets the form actionfinal FormBlock
Gets the specified block, by using its namefinal FormColumn
Gets a column, specified by its namefinal DataDescriptor
Gets the form's DataDescriptor.Gets the name of every form item on the form.Gets the form encoding.final FormItem<?,
?> getFormItem
(String fieldName) Gets the specified form item component, specified by its name.Gets a list of every form itemfinal FormMethod
Gets the form methodGets the form type.final FormItemLabelPosition
Gets the form item label positiongetOriginalValue
(String fieldName) Gets the original value of the specified form item.final Record
Gets the current state of the record that is being edited on the formfinal TabPage
getTabPage
(String tabPageName) Gets a tab, specified by its nameGets the actual value of a form item.getValueAsBoolean
(String fieldName) Gets the value of a form item in a Boolean format.The method will look for the specified form item first.getValueAsDate
(String fieldName) Gets the value of a form item in aDate
format.getValueAsDouble
(String fieldName) Gets the value of a form item in a Double format.getValueAsFloat
(String fieldName) Gets the value of a form item in a Float format.getValueAsInteger
(String fieldName) Gets the value of a form item in an Integer format.getValueAsLong
(String fieldName) Gets the value of a form item in a Long format.getValueAsString
(String fieldName) Gets the value of a form item in a String format.final boolean
Determines if any of the form items were modified by the userboolean
isValid()
Determines the form content is valid.final Form
Starts the editing of a new record in the form component.rebuild()
final Form
Recalculates the fields on the form.Every component cannot be removed from the formsave()
Saves the form's current state to the databasesave
(Transaction transaction) Saves the form within the specified database transactionfinal Form
Sets the form actionfinal Form
setBuildType
(FormBuildType buildType) Sets the form builder class.final Form
setBuildType
(FormBuildType buildType, FormBuilder builder) Sets the builder class, by specifiyng the builder class instance.final Form
setDataDescriptor
(DataDescriptor dataDescriptor) Sets the form's DataDescriptor.final Form
setFormChangeHandler
(FormChangeHandler handler) Sets the form change event handler implementationfinal Form
setFormEncode
(FormEncoding encode) Sets the form encoding.final Form
setFormMethod
(FormMethod method) Sets the form method.setFormType
(FormType formType) Sets the form type.final Form
setFormValidator
(FormValidator validator) Sets a custom form validator on the form componentsetHierarchy
(ComplexBuilderHierarchy hierachy) Sets the builder hierarchy (used when using a complex form builder).final Form
setLabelPosition
(FormItemLabelPosition position) Sets the label position of the form items.setOriginalValue
(String fieldName, Object value) Sets the original value of a form item.setTabType
(TabType tabType) Sets the type of the tabs, that are used on the form.Sets the value of a form item.final Form
submit()
Submits the formboolean
writeHTML
(StringWriter writer) Creates the component's HTML equivalentMethods inherited from class com.jbstrap.ui.Component
_hide, _setAttribute, addAllowedRole, addComponent, addComponents, addDeniedRole, addHandler, addStyle, addStyleClass, addStyleClasses, afterDraw, clearfix, closeTag, combinateAccess, containsStyle, containsStyleClass, draw, drawSubComponents, error, flattendComponentTree, getAccess, getAccessMode, getAllowedRoles, getAttribute, getAttributes, getBackgroundColor, getBorderColor, getClient, getComponentById, getComponents, getComponents, getComponentsByClass, getData, getDeniedRoles, getHandlers, getId, getLanguageCode, getName, getParent, getParent, getRegisteredEvents, getStyle, getStyleClasses, getTextAlign, getTextColor, getToolTip, getToolTipPosition, getTypeName, getUI, init, insertComponentAfter, insertComponentBefore, isAccess, isDrawn, isEnabled, isEventBubbling, isVisible, onHide, onHotKeyEventHandler, onShow, openTag, redraw, removeAllowedRole, removeAllStyleClasses, removeAttribute, removeComponent, removeComponent, removeComponents, removeDeniedRole, removeHandler, removeStyle, removeStyle, removeStyleClass, removeStyleClasses, replaceComponent, replaceStyleClass, runAfterDraw, runJavaScript, runJavaScript, runJavaScript, runOnHide, runOnShow, say, setAttribute, setBackgroundColor, setBorder, setBorderColor, setData, setDisplayType, setEnabled, setEventBubbling, setFlex, setFloating, setHeight100, setHeight25, setHeight50, setHeight75, setHeightAuto, setLanguage, setMargin, setName, setOverflow, setPadding, setParent, setScrollable, setSelectionType, setShadow, setStyle, setTextAlign, setTextColor, setToolTip, setToolTipPosition, setVisible, setWidth100, setWidth25, setWidth50, setWidth75, setWidthAuto, showNotification, showNotification, showProcessIndicator, toggleStyleClass
Methods inherited from class com.jbstrap.core.messagebus.MessageBus
closeMessageBus, messageBusOpened, openMessageBus, renewSubscription, sendMessageToMessageBus, subscribeMessageBus, unsubscribeAllListeners, unsubscribeMessageBus
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.jbstrap.ui.Animatable
addAnimationEndHandler, addAnimationStartHandler, getAnimation, removeAnimation, setAnimation
Methods inherited from interface com.jbstrap.ui.CanDrop
addDropEventHandler
Methods inherited from interface com.jbstrap.ui.Draggable
addDragEndEventHandler, addDragStartEventHandler, setDraggable
Methods inherited from interface com.jbstrap.ui.Focusable
addFocusHandler, addFocusInHandler, addFocusOutHandler, addLosesFocusHandler, setFocus
Methods inherited from interface com.jbstrap.ui.HandleHotKey
addHotKey, addHotKey, removeHotKey, removeHotKeys
Methods inherited from interface com.jbstrap.ui.HandleMouseEvents
addMouseDownHandler, addMouseEnterHandler, addMouseLeaveHandler, addMouseMoveHandler, addMouseOutHandler, addMouseOverHandler, addMouseUpHandler, addMouseWheelHandler
Methods inherited from interface com.jbstrap.ui.Scrollable
addScrollHandler
-
Constructor Details
-
Form
public Form()Creates an empty form component -
Form
Creates an empty form component, with the specified language- Parameters:
language
- The language code to be used by the form. If not specified, ornull
the default language will be used. The framework's default language can be set by theJBStrapParamType.DEFAULT_LANGUAGE
JBStrap parameter
-
Form
Creates an empty form component, with the specified language- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)language
- The language code to be used by the form. If not specified, ornull
the default language will be used. The framework's default language can be set by theJBStrapParamType.DEFAULT_LANGUAGE
JBStrap parameter
-
Form
Creates an empty form component, with the specified encoding. Default encoding:FormEncoding.MULTIPART
- Parameters:
encode
- The form encoding. Usable values can be found in theFormEncoding
enum
-
Form
Creates an empty form component, with the specified encoding. Default encoding:FormEncoding.MULTIPART
- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)encode
- The form encoding. Usable values can be found in theFormEncoding
enum
-
Form
Creates an empty form component, with the specified encoding and language code. Default encoding:FormEncoding.MULTIPART
.- Parameters:
encode
- The form encoding. Usable values can be found in theFormEncoding
enumlanguage
- The language code to be used by the form. If not specified, ornull
the default language will be used. The framework's default language can be set by theJBStrapParamType.DEFAULT_LANGUAGE
JBStrap parameter
-
Form
Creates an empty form component, with the specified encoding and language code. Default encoding:FormEncoding.MULTIPART
.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)encode
- The form encoding. Usable values can be found in theFormEncoding
enumlanguage
- The language code to be used by the form. If not specified, ornull
the default language will be used. The framework's default language can be set by theJBStrapParamType.DEFAULT_LANGUAGE
JBStrap parameter
-
Form
Creates an empty form component, and sets the form send type. By default this isFormMethod.POST
- Parameters:
method
- The form sending method. Usable ones can be found in theFormMethod
enum
-
Form
Creates an empty form component, sets the form send type and language code. By default, the method isFormMethod.POST
- Parameters:
method
- The form sending method. Usable ones can be found in theFormMethod
enumlanguage
- The language code to be used by the form. If not specified, ornull
the default language will be used.
-
Form
Creates an empty form, with the specified action, encoding, and method.- Parameters:
action
- The form actionmethod
- The form sending method. Usable ones can be found in theFormMethod
enumencode
- The form encoding. Usable values can be found in theFormEncoding
enum
-
Form
Creates an empty form, with the specified action, encoding, and method.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)action
- The form actionmethod
- The form sending method. Usable ones can be found in theFormMethod
enumencode
- The form encoding. Usable values can be found in theFormEncoding
enum
-
Form
Creates an empty form, with the specified action, encoding, method and language.- Parameters:
action
- The form actionmethod
- The form sending method. Usable ones can be found in theFormMethod
enumencode
- The form encoding. Usable values can be found in theFormEncoding
enumlanguage
- The language code to be used by the form. If not specified, ornull
the default language will be used.
-
Form
Creates an empty form, with the specified action, encoding, method and language.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)action
- The form actionmethod
- The form sending method. Usable ones can be found in theFormMethod
enumencode
- The form encoding. Usable values can be found in theFormEncoding
enumlanguage
- The language code to be used by the form. If not specified, ornull
the default language will be used.
-
Form
Creates a form, based on the specified DataDescriptor. The form item components in the DataDescriptor columns, (which do not have the visibility ofColumnVisibleType.ONLY_LIST
,ColumnVisibleType.LIST
orColumnVisibleType.HIDDEN
) will be set to the form component. The type of form item is decided by the column'sEditorType
setting. Each form item has its parameters specified by the appropriate column of the DataDescriptor. The usable form item parameters are described in the description of the form item components. If the specified column cannot create a form item component, or if an error is encountered, the error will be logged in the server log.- Parameters:
dataDescriptor
- The DataDescriptor- See Also:
-
Form
Creates a form, based on the specified DataDescriptor. The form item components in the DataDescriptor columns, (which do not have the visibility ofColumnVisibleType.ONLY_LIST
,ColumnVisibleType.LIST
orColumnVisibleType.HIDDEN
) will be set to the form component. The type of form item is decided by the column'sEditorType
setting. Each form item has its parameters specified by the appropriate column of the DataDescriptor. The usable form item parameters are described in the description of the form item components. If the specified column cannot create a form item component, or if an error is encountered, the error will be logged in the server log.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)dataDescriptor
- The DataDescriptor- See Also:
-
Form
Creates a form, based on the specified DataDescriptor, with the specified language. The form item components in the DataDescriptor columns, (which do not have the visibility ofColumnVisibleType.ONLY_LIST
,ColumnVisibleType.LIST
orColumnVisibleType.HIDDEN
) will be set to the form component. The type of form item is decided by the column'sEditorType
setting. Each form item has its parameters specified by the appropriate column of the DataDescriptor. The usable form item parameters are described in the description of the form item components. If the specified column cannot create a form item component, or if an error is encountered, the error will be logged in the server log.- Parameters:
dataDescriptor
- The DataDescriptorlanguage
- The language code to be used by the form. If not specified, ornull
the default language will be used.- See Also:
-
Form
Creates a form, based on the specified DataDescriptor, with the specified language. The form item components in the DataDescriptor columns, (which do not have the visibility ofColumnVisibleType.ONLY_LIST
,ColumnVisibleType.LIST
orColumnVisibleType.HIDDEN
) will be set to the form component. The type of form item is decided by the column'sEditorType
setting. Each form item has its parameters specified by the appropriate column of the DataDescriptor. The usable form item parameters are described in the description of the form item components. If the specified column cannot create a form item component, or if an error is encountered, the error will be logged in the server log.- Parameters:
id
- The component ID. The ID specified here will appear in the HTML tag as an ID attribute. If there are multiple components displayed, that have the same ID, the ID numbers will be numbered, in the order they are displayed. (For example, if the ID is 'COMPONENT' then it will be numbered like this: COMPONENT, COMPONENT_1, COMPONENT_2 etc.)dataDescriptor
- The DataDescriptorlanguage
- The language code to be used by the form. If not specified, ornull
the default language will be used.- See Also:
-
-
Method Details
-
setBuildType
Sets the form builder class. By default, the form uses theDefaultFormBuilder
class.- Parameters:
buildType
- The builder type. Usable types:FormBuildType
- Returns:
- The form component
- See Also:
-
setBuildType
Sets the builder class, by specifiyng the builder class instance. If using a built-in builder, the class instance does not need to be specified, the method will ignore it. If using a cusotm implementation, then it must be set to CUSTOM, and the builder class instance must be specified.- Parameters:
buildType
- The builder type. Usable types:FormBuildType
. If using a custom implementation, this value must beFormBuildType.CUSTOM
.builder
- The form builder class instance. If using a built in builder, this parameter will be ignored (can be defined asnull
). If using a custom one, the builder instance must be specified. The class must implement theFormBuilder
interface.- Returns:
- The form component
- Throws:
NullPointerException
- AIf the builder type is CUSTOM, and the builder instance isnull
- See Also:
-
setFormType
Sets the form type. By default theFormType.HORIZONTAL
type is used, meaning that the items are under each other.- Parameters:
formType
- The form type. The usable types can be found in theFormType
enum- Returns:
- The form component
-
getFormType
Gets the form type.- Returns:
- The form type, or
null
, if cannot be defined
-
getDataDescriptor
Gets the form's DataDescriptor.- Specified by:
getDataDescriptor
in interfaceBasedOnDataDescriptor<Form>
- Returns:
- The DataDescriptor instance, that is used to build the form or
null
, if no DataDescriptor is used
-
setDataDescriptor
Sets the form's DataDescriptor. The form item components in the DataDescriptor columns, (which do not have the visibility ofColumnVisibleType.ONLY_LIST
,ColumnVisibleType.LIST
orColumnVisibleType.HIDDEN
) will be set to the form component. The type of form item is decided by the column'sEditorType
setting. Each form item has its parameters specified by the appropriate column of the DataDescriptor. The usable form item parameters are described in the description of the form item components. If the specified column cannot create a form item component, or if an error is encountered, the error will be logged in the server log.- Specified by:
setDataDescriptor
in interfaceBasedOnDataDescriptor<Form>
- Parameters:
dataDescriptor
- The DataDescriptor instance- Returns:
- The form component
- See Also:
-
setAction
Sets the form action- Parameters:
action
- The form action- Returns:
- The form component
-
getAction
Gets the form action- Returns:
- The form action or
null
, if not specified
-
setFormEncode
Sets the form encoding. The default encoding isFormEncoding.MULTIPART
- Parameters:
encode
- The form encoding. Usable values can be found in theFormEncoding
enum- Returns:
- The form component
-
getFormEncode
Gets the form encoding.- Returns:
- The form encoding or
null
if not set, or an encoding type that the framework does not recognize
-
setFormMethod
Sets the form method. The default method is theFormMethod.POST
- Parameters:
method
- The form method. Applicable values can be found in theFormMethod
enum- Returns:
- The form component
-
getFormMethod
Gets the form method- Returns:
- The form method or
null
if not set, or is a type that the framework does not recognize
-
newRecord
Starts the editing of a new record in the form component.
The method deletes all previous data from the form, and starts editing a new one. In this case, every form item value will revert to the default value, or if not specified, to an empty value. The form change handler (
FormChangeHandler
) is called, the parameter containing the changed form item will be null, and the record parameter will gain the empty recordIf the record editing is started like this, then when saving the form, the new record will also be in the database, with the content that the user specified.
- Returns:
- The form component
-
editRecord
Starts the editing of the specified record in the form component.
The method uses the specified record to load values in the form item components. The method will go through every form item, and if it finds an attribute, that corresponds to a form item name, it will give that form item the value from the attribute. If not found, the form item will have its default value set to it. If it does not have a default value, it will receive a null value.
The form change handler (
FormChangeHandler
) is called, the parameter containing the changed form item will be null, and the record parameter will gain the edited record.If the record editing is started like this, then when saving the form, the edited record will also be edited the database, with the content that the user specified. If the specified record did not exist in the database, it will be added to it.
- Parameters:
record
- The record is to be edited- Returns:
- The form component
- Throws:
NullPointerException
- If the record isnull
-
getRecord
Gets the current state of the record that is being edited on the form- Returns:
- The record being edited or
null
, if no record is being edited
-
setValue
Sets the value of a form item. The method sets the value of the form item that was specified. The new value will also be set in the form record. If the form item is not found, the value is only set in the record.- Parameters:
fieldName
- The name of the field or form item.value
- The new value to be set to the specified item or field. Must be in the correct format- Returns:
- The form component
- Throws:
NullPointerException
- If the field name isnull
-
setOriginalValue
Sets the original value of a form item. The item is specified by its name. If not found, the method won't do anything.- Parameters:
fieldName
- The name of the form itemvalue
- The original value, in the format of the specified field- Returns:
- The form component
-
getOriginalValue
Gets the original value of the specified form item. If not found, the method will look for the attribute with the same name in the record, and return its value.- Parameters:
fieldName
- The name of the form item or field- Returns:
- The original value. If the form item is not found, it will look for it in the record. If not found there either, or cannot be defined, it will return with
null
-
getValue
Gets the actual value of a form item. The method will look for the specified form item first. If not found, it will look in the record, for the attribute with the specified name.- Parameters:
fieldName
- The name of the form item or field- Returns:
- The actual value. If the form item is not found, it will look for it in the record. If not found there either, or if it has a null value, it will return with
null
-
getValueAsLong
Gets the value of a form item in a Long format. The method will look for the specified form item first. It will return the form item value, if it's aNumber
. If not, it will return withnull
. If the form item is not found, the method will look in the current record for an attribute of the specified name. If found, then it will return with its value, in a Long format, if it is aNumber
, or if it is a text value that can be converted into Long.- Parameters:
fieldName
- The name of the form item or field.- Returns:
- The specified form item's actual value as Long, or
null
if not found, or if its value isnull
- Throws:
ParseException
- If no form item is found with the specified name, but an attribute in the record is found, but its value is not aNumber
or it can't be converted to Long
-
getValueAsString
Gets the value of a form item in a String format. The method will look for the specified form item first. It will return the form item value. If the form item is not found, the method will look in the current record for an attribute of the specified name. If found, then it will return with its value, in a String format. IF not found at all, it will return withnull
.- Parameters:
fieldName
- The name of the form item or field.- Returns:
- The specified form item's actual value as String, or
null
if not found, or if its value isnull
-
getValueAsInteger
Gets the value of a form item in an Integer format. The method will look for the specified form item first. It will return the form item value, if it's aNumber
. If not, it will return withnull
. If the form item is not found, the method will look in the current record for an attribute of the specified name. If found, then it will return with its value, in an Integer format, if it is aNumber
, or if it is a text value that can be converted into Integer. If this also fails, it will return with an error- Parameters:
fieldName
- The name of the form item or field.- Returns:
- The specified form item's actual value as an Integer, or
null
if not found, or if its value isnull
- Throws:
ParseException
- If no form item is found with the specified name, but an attribute in the record is found, but its value is not aNumber
or it can't be converted to Integer
-
getValueAsDouble
Gets the value of a form item in a Double format. The method will look for the specified form item first. It will return the form item value, if it's aNumber
. If not, it will return withnull
. If the form item is not found, the method will look in the current record for an attribute of the specified name. If found, then it will return with its value, in a Double format, if it is aNumber
, or if it is a text value that can be converted into Double. If this also fails, it will return with an error- Parameters:
fieldName
- The name of the form item or field.- Returns:
- The specified form item's actual value as a Double, or
null
if not found, or if its value isnull
- Throws:
ParseException
- If no form item is found with the specified name, but an attribute in the record is found, but its value is not aNumber
or it can't be converted to Double
-
getValueAsDate
Gets the value of a form item in aDate
format. The method will look for the specified form item first. It will return the form item value, if it's a Date, if the value is aDate
. If it is not, it will return withnull
. If the form item is not found, the method will look in the current record for an attribute of the specified name. If found, then it will return with its value, in a Date format, if it is aDate
, or if it is a text value that can be converted into a Date. If this also fails, it will return with an error.- Parameters:
fieldName
- The name of the form item or field.- Returns:
- The specified form item's actual value as a Date, or
null
if not found, or if its value isnull
- Throws:
ParseException
- If no form item is found with the specified name, but an attribute in the record is found, but its value is not aDate
or it can't be converted to Date
-
getValueAsFloat
Gets the value of a form item in a Float format. The method will look for the specified form item first. It will return the form item value, if it's aNumber
. If not, it will return withnull
. If the form item is not found, the method will look in the current record for an attribute of the specified name. If found, then it will return with its value, in a Float format, if it is aNumber
, or if it is a text value that can be converted into Float. If this also fails, it will return with an error- Parameters:
fieldName
- The name of the form item or field.- Returns:
- The specified form item's actual value as a Float, or
null
if not found, or if its value isnull
- Throws:
ParseException
- If no form item is found with the specified name, but an attribute in the record is found, but its value is not aNumber
or it can't be converted to Float
-
getValueAsBoolean
Gets the value of a form item in a Boolean format.The method will look for the specified form item first. It will return the form item value, if it's aBoolean
. If not, it will return withfalse
. If the form item is not found, the method will look in the current record for an attribute of the specified name. If found, then it will return with its value, in a Boolean format, if it is aBoolean
value. If it is not, the method will try to convert it, using theBooleanConverter.parseBoolean(Object)
method. If no attribute with the specified name is found, it will return withnull
.- Parameters:
fieldName
- The name of the form item or field.- Returns:
- The specified form item's actual value as a Boolean, or
null
if not found
-
setFormValidator
Sets a custom form validator on the form component- Parameters:
validator
- The instance of the custom form validator class. Ifnull
, the previously set validator will be deleted, and the default validator will be used. The default validator only checks for the mandatory fields being filled.- Returns:
- The form component
-
isValid
public boolean isValid()Determines the form content is valid. Uses the custom validator if one was specified, otherwise it will use the default one. If using the default validator, the form will be valid if the mandatory items are filled out (ie, they do not have If either mandatory item isnull
, then the form will be invalid.- Returns:
- If
true
, the form is valid, otherwisefalse
-
getFormItem
Gets the specified form item component, specified by its name.- Parameters:
fieldName
- The name of the form item- Returns:
- The name with the specified name or
null
, if not found
-
getFieldNames
Gets the name of every form item on the form.- Returns:
- A list of every form item that is on the form. If there are none, the list will be empty
-
submit
Submits the form- Returns:
- The form component
-
save
Saves the form's current state to the database- Returns:
- The saved form. The returned record's automatically filled fields, and the fields that get their values from the sequence are filled out.
- Throws:
SaveException
- If the form has no DataDescriptor set, or if an error was encountered during the saveDataAccessException
- If the user has no rights to modify the data
-
save
Saves the form within the specified database transaction- Parameters:
transaction
- The opened database transaction- Returns:
- The saved form. The returned record's automatically filled fields, and the fields that get their values from the sequence are filled out.
- Throws:
SaveException
- If the form has no DataDescriptor set, or if an error was encountered during the saveDataAccessException
- If the user has no rights to modify the data
-
rebuild
- Returns:
- The form component
-
writeHTML
Description copied from class:Component
Creates the component's HTML equivalentThis method doesn't need to be used during application development. This method is used when developing a custom component. When creating a custom component, this method needs to be implemented. In the parameter (
StringWriter
class) the component's HTML equivalent must be specified, and the method has to return with a Boolean value. This boolean value determines if the component was drawn. If the user doesn't have access right to the component, or if the component couldn't be drawn, it should return withfalse
. Otherwise, it must return withtrue
. -
isModified
public final boolean isModified()Determines if any of the form items were modified by the user- Returns:
- If
true
, the items were modified, otherwisefalse
-
setFormChangeHandler
Sets the form change event handler implementation- Parameters:
handler
- The form change event handler implementation- Returns:
- The form component
-
recalcAutoCalculateFields
Recalculates the fields on the form. A filed will be recalculated, if it has a calculation implementation- Returns:
- The form component
-
getFormItems
Gets a list of every form item- Returns:
- A list of every form item component. If there are none, the list will be empty
-
setLabelPosition
Sets the label position of the form items. Applies to every form item label. The default position is theFormItemLabelPosition.LEFT
, meaning it will be on the left side of the input field.- Parameters:
position
- The form item label position. The usable values can be found in theFormItemLabelPosition
enum. Ifnull
, the default one will be used- Returns:
- The form component
-
getLabelPosition
Gets the form item label position- Returns:
- The form item label position
-
addComponent
Description copied from class:Component
Adds the specified component as a subcomponent, and redraws the component immediately- Overrides:
addComponent
in classComponent<Form>
- Parameters:
component
- The component to be added- Returns:
- The component
-
addBlock
Creates a form block on the form- Parameters:
blockName
- The name of the block, must be unique within the formblockTitle
- The title of the block. Ifnull
, no title will be displayed- Returns:
- The form component
- Throws:
NullPointerException
- If the name isnull
UnsupportedOperationException
- If the set builder class does not support blocks
-
getBlock
Gets the specified block, by using its name- Parameters:
name
- The name of the block- Returns:
- The block with the specified name or
null
, if not found - Throws:
UnsupportedOperationException
- If the set builder class does not support blocks
-
addColumn
Creates a form column on the form- Parameters:
columnName
- The name of the column, must be unique within the form- Returns:
- The form component
- Throws:
NullPointerException
- If the name isnull
UnsupportedOperationException
- If the set builder class does not support columns
-
getColumn
Gets a column, specified by its name- Parameters:
columnName
- The name of the column- Returns:
- The column with the specified name or
null
, if not found - Throws:
UnsupportedOperationException
- If the set builder class does not support columns
-
addTabPage
Creates a tab page on the form- Parameters:
tabPageName
- The name of the tab page, that must be unique within the formicon
- The icon of the tab. The icons can be found in theIcon
enum. Ifnull
, no icon will be usedtitle
- The title of the tab. Ifnull
, no title will be used- Returns:
- The form component
- Throws:
NullPointerException
- If the name isnull
UnsupportedOperationException
- If the set builder class does not support tabs
-
getTabPage
Gets a tab, specified by its name- Parameters:
tabPageName
- The name of the tab- Returns:
- The tab with the specified name or
null
, if not found - Throws:
UnsupportedOperationException
- If the set builder class does not support tabs
-
setTabType
Sets the type of the tabs, that are used on the form. By default this is theTabType.DEFAULT
type. This method only functions if the form has a builder class that supports the use of tabs- Parameters:
tabType
- The tab type. The usable types can be found in theTabType
enum- Returns:
- The form component
-
setHierarchy
Sets the builder hierarchy (used when using a complex form builder). The default hierarchy is theComplexBuilderHierarchy.TAB_BLOCK_COLUMN
.- Parameters:
hierachy
- The hierarchy to be used by the form. The usable hierarchies can be found in theComplexBuilderHierarchy
enum. Ifnull
, the default hierarchy will be used.- Returns:
- The form component
- Throws:
UnsupportedOperationException
- If the complex form builder is not used
-
removeAllComponents
Every component cannot be removed from the form- Overrides:
removeAllComponents
in classComponent<Form>
- Returns:
- The component
- Throws:
UnsupportedOperationException
- Every time the method is called
-