Package com.axelor.meta.headless
Class FormSpec
java.lang.Object
com.axelor.meta.headless.FormSpec
What a session needs to know about a form, compiled from views once and cached: the model, its
hooks, fields and buttons, the fields a record is read with, the limits of running it without a
browser, and, for each one-to-many, the spec of a line there — a line is a form too.
A spec is built from an action-view (of(String)), a form view (of(Class, String)) or a model alone (of(Class): no hooks, no buttons — defaults, set, save).
Where each part comes from is the web client's rule, applied to the definitions; the user's
personalized views are ignored. Building a spec is the only place that reads views: a session and
a validator of stored steps work on the same spec.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final recordA button or a menu item of the form.static final recordA field of the form's model, a custom field (attrs.color), a dotted field the form shows (customer.email) or a dummy field of the view. -
Method Summary
Modifier and TypeMethodDescriptionThe action-view the spec was built from, or null.The spec of a node of the tree, following the path's collections.buttons()The buttons and menu items, by name.Why a session would refuse the step, or null when it would run it: a path, field, button or chain the form does not have, anaddon a collection without lines, a value aFormLimit.Kind.WIDGETfield cannot hold.The form view the spec was compiled from — extensions merged, view processors applied — or null for a model alone and for a line edited inline.fields()The fields, by the name a step writes them by.formName()The name of the form view the spec was compiled from, or null when it has none.The custom model, for a custom model's form; null otherwise.limits()What a browser would do with this form that a session does not.The spec of a line of a one-to-many: the inline editor's when the collection is edited in its grid, else its line form's.model()static FormSpecThe spec of a model alone: its fields, no hooks, no buttons; its lines as the default form of their model gives them.static FormSpecThe spec of a form view of a model; no action-view context.static FormSpecThe spec of an action-view's form: itsformview by name, else the model's default form.onLoad()onNew()onSave()The fields a record of this form is read with, as the client asks for them.The sub-fields read for each collection the form shows.toString()
-
Method Details
-
of
The spec of an action-view's form: itsformview by name, else the model's default form. The action-view is read as defined, not evaluated: a session evaluates it when it opens, for the context every action carries.- Throws:
IllegalArgumentException- when the action is not an action-view with a model, or it has no form
-
of
The spec of a form view of a model; no action-view context.- Parameters:
formView- the form's name, or null for the model's default form- Throws:
IllegalArgumentException- when there is no such form
-
of
The spec of a model alone: its fields, no hooks, no buttons; its lines as the default form of their model gives them. For an import that wants the server's save rules and nothing else. -
model
-
jsonModel
The custom model, for a custom model's form; null otherwise. -
actionView
The action-view the spec was built from, or null. -
formName
The name of the form view the spec was compiled from, or null when it has none. -
definition
The form view the spec was compiled from — extensions merged, view processors applied — or null for a model alone and for a line edited inline. For readers of what the spec does not model. It is a view of its own, looked up apart from the one the spec reads its widgets and lines from, so nothing a reader does with it changes what a session does. -
onNew
-
onLoad
-
onSave
-
fields
The fields, by the name a step writes them by. -
buttons
The buttons and menu items, by name. -
readFields
The fields a record of this form is read with, as the client asks for them. -
readRelated
The sub-fields read for each collection the form shows. -
limits
What a browser would do with this form that a session does not. -
line
The spec of a line of a one-to-many: the inline editor's when the collection is edited in its grid, else its line form's. A many-to-many holds references and has none.- Returns:
- the line's spec, or null when the name is not a one-to-many of the model
-
at
The spec of a node of the tree, following the path's collections.- Throws:
IllegalArgumentException- when a segment is not a one-to-many with lines
-
check
Why a session would refuse the step, or null when it would run it: a path, field, button or chain the form does not have, anaddon a collection without lines, a value aFormLimit.Kind.WIDGETfield cannot hold. Positions and ids are not resolved: only a run knows the lines. -
toString
-