Package org.jboss.hal.ballroom.form
Class AbstractForm<T>
- java.lang.Object
-
- org.jboss.elemento.LazyElement
-
- org.jboss.hal.ballroom.form.AbstractForm<T>
-
- All Implemented Interfaces:
org.jboss.elemento.IsElement,Attachable,Form<T>
public abstract class AbstractForm<T> extends org.jboss.elemento.LazyElement implements Form<T>
A generic form with some reasonable UI defaults. Please note that all form items and help texts must be setup before this form is added as an element to the DOM.The form consists of links and three sections:
- empty
- read-only
- editing
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.jboss.hal.ballroom.form.Form
Form.CancelCallback<T>, Form.FinishRemove<T>, Form.FinishReset<T>, Form.Operation, Form.PrepareRemove<T>, Form.PrepareReset<T>, Form.SaveCallback<T>, Form.State
-
-
Constructor Summary
Constructors Constructor Description AbstractForm(String id, StateMachine stateMachine, DataMapping<T> dataMapping, EmptyState emptyState)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddFormValidation(FormValidation<T> formValidation)Makes it possible to validate the form as a whole or to check fields which depend on other fields.voidattach()voidcancel()Executes theForm.Operation.CANCELoperation and calls the registered cancel callback (if any).voidclear()Removes the model reference, executes theForm.Operation.CLEARoperation and callsDataMapping.clearFormItems(Form).voiddetach()voidedit(T model)Executes theForm.Operation.EDIToperation and callsDataMapping.newModel(Object, Form)if the model is transitive otherwiseDataMapping.populateFormItems(Object, Form).Iterable<FormItem>getBoundFormItems()<I> FormItem<I>getFormItem(String name)Iterable<FormItem>getFormItems()StringgetId()TgetModel()StateMachinegetStateMachine()voidremove()Removes the model reference and executes theForm.Operation.REMOVEoperation.voidreset()Executes theForm.Operation.RESEToperation.booleansave()Upon successful validation, executes theForm.Operation.SAVEoperation, callsDataMapping.persistModel(Object, Form)and finally calls the registered save callback (if any).voidsetCancelCallback(Form.CancelCallback<T> cancelCallback)voidsetPrepareRemove(Form.PrepareRemove<T> removeCallback)voidsetPrepareReset(Form.PrepareReset<T> prepareReset)voidsetSaveCallback(Form.SaveCallback<T> saveCallback)voidview(T model)Executes theForm.Operation.VIEWoperation and callsDataMapping.populateFormItems(Object, Form)if the form is not undefined.-
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jboss.hal.ballroom.form.Form
isTransient, isUndefined
-
-
-
-
Constructor Detail
-
AbstractForm
public AbstractForm(String id, StateMachine stateMachine, DataMapping<T> dataMapping, EmptyState emptyState)
-
-
Method Detail
-
addFormValidation
public void addFormValidation(FormValidation<T> formValidation)
Description copied from interface:FormMakes it possible to validate the form as a whole or to check fields which depend on other fields.- Specified by:
addFormValidationin interfaceForm<T>
-
attach
public void attach()
- Specified by:
attachin interfaceAttachable
-
detach
public void detach()
- Specified by:
detachin interfaceAttachable
-
view
public final void view(T model)
Executes theForm.Operation.VIEWoperation and callsDataMapping.populateFormItems(Object, Form)if the form is not undefined.
-
clear
public void clear()
Removes the model reference, executes theForm.Operation.CLEARoperation and callsDataMapping.clearFormItems(Form).
-
edit
public final void edit(T model)
Executes theForm.Operation.EDIToperation and callsDataMapping.newModel(Object, Form)if the model is transitive otherwiseDataMapping.populateFormItems(Object, Form).
-
save
public final boolean save()
Upon successful validation, executes theForm.Operation.SAVEoperation, callsDataMapping.persistModel(Object, Form)and finally calls the registered save callback (if any).
-
setSaveCallback
public void setSaveCallback(Form.SaveCallback<T> saveCallback)
- Specified by:
setSaveCallbackin interfaceForm<T>
-
cancel
public final void cancel()
Executes theForm.Operation.CANCELoperation and calls the registered cancel callback (if any).
-
setCancelCallback
public void setCancelCallback(Form.CancelCallback<T> cancelCallback)
- Specified by:
setCancelCallbackin interfaceForm<T>
-
setPrepareReset
public void setPrepareReset(Form.PrepareReset<T> prepareReset)
- Specified by:
setPrepareResetin interfaceForm<T>
-
reset
public final void reset()
Executes theForm.Operation.RESEToperation.
-
setPrepareRemove
public void setPrepareRemove(Form.PrepareRemove<T> removeCallback)
- Specified by:
setPrepareRemovein interfaceForm<T>
-
remove
public void remove()
Removes the model reference and executes theForm.Operation.REMOVEoperation.
-
getId
public String getId()
-
getModel
public T getModel()
-
getStateMachine
public StateMachine getStateMachine()
- Specified by:
getStateMachinein interfaceForm<T>- Returns:
- the state machine which access to the current state.
-
getFormItem
public <I> FormItem<I> getFormItem(String name)
- Specified by:
getFormItemin interfaceForm<T>
-
getBoundFormItems
public Iterable<FormItem> getBoundFormItems()
- Specified by:
getBoundFormItemsin interfaceForm<T>- Returns:
- only those form items which are bound to the model.
-
getFormItems
public Iterable<FormItem> getFormItems()
- Specified by:
getFormItemsin interfaceForm<T>- Returns:
- return all form items.
-
-