public class XdevVirtualFormular extends Object implements Formular, Pageable
XdevVirtualFormular
is a collection containing
FormularComponent
s and ManyToManyComponent
s provided as a
alternative for the XdevFormular
but without an UI representation.
The XdevVirtualFormular
can be used to display a row of a
VirtualTable
. Therefore the XdevVirtualFormular
must contain
FormularComponent
s that are mapped to the columns of the
VirtualTable
you want to display. This can be done by the XDEV IDE or
manually.
The XdevVirtualFormular
also manages n:m-relations. Therefore
ManyToManyComponent
s can be added into this container.
The XdevVirtualFormular
provides methods to:
VirtualTable.VirtualTableRow
s like
setModel(xdev.vt.VirtualTable.VirtualTableRow)
VirtualTable.VirtualTableRow
s like insert(boolean)
VirtualTable.VirtualTableRow
s like
update(boolean)
VirtualTable.VirtualTableRow
s like
delete(boolean)
FormularGroupListener
,
FormularComponent
,
MasterDetailComponent
,
ManyToManyComponent
,
XdevVirtualFormular
Formular.WorkingState
Modifier and Type | Field and Description |
---|---|
protected EventListenerList |
listenerList |
protected PropertyChangeSupport |
propertChangeSupport |
CLIENT_PROPERTY_KEY, SAVE_STATE_AFTER_MODEL_UPDATE_PROPERTY
Constructor and Description |
---|
XdevVirtualFormular()
Creates a new
XdevVirtualFormular . |
Modifier and Type | Method and Description |
---|---|
void |
addFormularListener(FormularListener l)
Registers a
FormularListener so that it will receive form events. |
Condition |
createCondition(String connector)
Alias for
createCondition(connector,null) . |
Condition |
createCondition(String connector,
Collection paramCollection)
Creates a
Condition depending on the input component's values and
their conditional settings. |
Condition |
createCondition(String connector,
Query query)
Creates a
Condition depending on the input component's values and
their conditional settings. |
QueryInfo |
createQuery(String connector)
Creates a query (SELECT * FROM ..) of the connected
VirtualTable
with a WHERE condition created by the values of the
FormularComponent s of this formular. |
void |
delete()
Alias for
delete(true). |
void |
delete(boolean synchronizeDB)
|
protected void |
fireFormularComponentValueChanged(FormularComponent formularComponent,
Object formularComponentEventObject) |
protected void |
fireModelChanged() |
protected void |
fireSavePerformed() |
Iterable<FormularComponent> |
formComponents() |
Object |
getClientProperty(Object key)
Returns the value of the property with the specified key.
|
Map<String,Object> |
getData(boolean withNulls)
|
FormularComponent[] |
getFormComponents() |
FormularListener[] |
getFormularListeners() |
Object |
getHiddenField(String name)
Returns the value of the hidden field with the specified name.
|
Iterable<String> |
getHiddenFieldNames()
Returns all hidden field names of this form.
|
ManyToManyComponent[] |
getManyToManyComponents() |
VirtualFormularPageControl |
getPageControl() |
boolean |
getPagingAutoQuery() |
boolean |
getSaveStateAfterModelUpdate()
Determines if the formular saves its state after an update of the model.
|
String |
getURLAdd()
Returns a parameter list consisting of key value pairs containing all
components of this
Formular and their values. |
VirtualTable |
getVirtualTable()
Returns the assigned
VirtualTable of this Formular . |
VirtualTable.VirtualTableRow |
getVirtualTableRow()
Returns the current assigned
VirtualTable.VirtualTableRow . |
Formular.WorkingState |
getWorkingState()
Returns the working state of the form.
|
boolean |
hasStateChanged()
Checks if one of the
FormularComponent 's or
ManyToManyComponent 's state since the last call of
Formular.saveState() has changed. |
void |
insert()
Alias for
insert(true). |
void |
insert(boolean synchronizeDB)
Propagates the values of this
Formular / the mapped components in
the Formular to the set VirtualTable as new row. |
void |
insertRowInVT(VirtualTable vt,
boolean synchronizeDB)
Propagates the values of this
Formular / the mapped components in
the Formular to the set VirtualTable as new row. |
boolean |
isPagingEnabled() |
Iterable<ManyToManyComponent> |
manyToManyComponents() |
void |
putClientProperty(Object key,
Object value)
Adds an arbitrary key/value "client property" to this component.
|
void |
putHiddenField(String name,
Object value)
Adds an arbitrary name/value "hidden field" to this form.
|
void |
removeFormularListener(FormularListener l)
Removes the listener from the listener list of this form.
|
void |
reset()
|
void |
reset(VirtualTable vt)
Resets this
Formular / the mapped components in the
Formular to the default values of the specified
VirtualTable vt . |
void |
restoreState()
|
void |
save()
Alias for
save(true). |
void |
save(boolean synchronizeDB)
Propagates the values of this
Formular / the mapped components in
the Formular to the set VirtualTable as new row if the
row is new to the VirtualTable , otherwise an update is performed. |
void |
saveState()
Saves the state of all
FormularComponent s in this formular. |
void |
search(String connector,
VirtualTableOwner target)
Updates the model of the
VirtualTableOwner target. |
void |
setFormComponents(FormularComponent[] formularComponents)
Sets the
FormularComponent s which should be used in this
FormularGroup. |
void |
setManyToManyComponents(ManyToManyComponent[] manyToManyComponents)
Sets the
ManyToManyComponent s which should be used in this
FormularGroup |
void |
setModel(int row,
VirtualTable vt)
Fills this
Formular / the mapped components in the
Formular with the values provided by the specified
row in the VirtualTable vt . |
void |
setModel(VirtualTable.VirtualTableRow virtualTableRow)
|
void |
setModel(VirtualTable vt)
Resets this
Formular / the mapped components in the
Formular to the default values of the specified
VirtualTable vt . |
void |
setModelForPaging(VirtualTable vt) |
void |
setModelForPaging(VirtualTable vt,
SELECT select,
Object... params) |
void |
setPagingAutoQuery(boolean pagingAutoQuery) |
void |
setPagingEnabled(boolean pagingEnabled)
Turns the paging behavior on or off.
|
void |
setSaveStateAfterModelUpdate(boolean saveStateAfterModelUpdate)
Sets if the formular should save its state after an update of the model.
|
void |
submit(String url,
String target)
Submits the contents of this
Formular to the given
url . |
void |
update()
Alias for
update(true) . |
void |
update(boolean synchronizeDB)
Propagates the values of this
Formular / the mapped components in
the Formular to the set VirtualTable / the set
VirtualTable.VirtualTableRow . |
void |
updateRowsInVT(VirtualTable vt,
KeyValues keyValues,
boolean synchronizeDB)
Propagates the values of this
Formular / the mapped components in
the Formular to the specified VirtualTable
vt , to the rows which matches the given KeyValues
pkv . |
Validation |
validateFormularComponents()
Validates all
FormularComponent s of this formular. |
Validation |
validateFormularComponents(Validation validation)
Validates all
FormularComponent s of this formular depending on an
given validation object. |
boolean |
verifyFormularComponents()
Returns
ture if all values of all FormularComponent s
of this Formular could be verified, false otherwise. |
protected final EventListenerList listenerList
protected final PropertyChangeSupport propertChangeSupport
public XdevVirtualFormular()
XdevVirtualFormular
.public Iterable<FormularComponent> formComponents()
formComponents
in interface Formular
public FormularComponent[] getFormComponents()
public void setFormComponents(FormularComponent[] formularComponents)
FormularComponent
s which should be used in this
FormularGroup.formularComponents
- public Iterable<ManyToManyComponent> manyToManyComponents()
manyToManyComponents
in interface Formular
public ManyToManyComponent[] getManyToManyComponents()
public void setManyToManyComponents(ManyToManyComponent[] manyToManyComponents)
ManyToManyComponent
s which should be used in this
FormularGroupmanyToManyComponents
- public Formular.WorkingState getWorkingState()
getWorkingState
in interface Formular
public void addFormularListener(FormularListener l)
FormularListener
so that it will receive form events.addFormularListener
in interface Formular
l
- the listener to registerpublic void removeFormularListener(FormularListener l)
removeFormularListener
in interface Formular
l
- the listener to removepublic FormularListener[] getFormularListeners()
getFormularListeners
in interface Formular
protected void fireModelChanged()
protected void fireFormularComponentValueChanged(FormularComponent formularComponent, Object formularComponentEventObject)
protected void fireSavePerformed()
public void setSaveStateAfterModelUpdate(boolean saveStateAfterModelUpdate)
setSaveStateAfterModelUpdate
in interface Formular
saveStateAfterModelUpdate
- true
if the state should be saved,
false
otherwiseFormular.setModel(VirtualTable.VirtualTableRow)
,
Formular.saveState()
public boolean getSaveStateAfterModelUpdate()
getSaveStateAfterModelUpdate
in interface Formular
true
if the state is saved, false
otherwiseFormular.setModel(VirtualTable.VirtualTableRow)
,
Formular.saveState()
public void saveState()
FormularComponent
s in this formular.saveState
in interface Formular
Formular.reset()
,
FormularComponent.saveState()
public void restoreState()
Formular
/ the mapped components in the
Formular
to the default values of the components.
This method is a synonym for Formular.reset()
restoreState
in interface Formular
Formular.saveState()
,
FormularComponent.restoreState()
public void reset()
Formular
/ the mapped components in the
Formular
to the default values of the components.
This method is a synonym for Formular.restoreState()
reset
in interface Formular
Formular.saveState()
,
FormularComponent.restoreState()
public boolean hasStateChanged()
FormularComponent
's or
ManyToManyComponent
's state since the last call of
Formular.saveState()
has changed.hasStateChanged
in interface Formular
true
if one component's state has changed,
false
otherwiseFormularComponent.hasStateChanged()
,
ManyToManyComponent.hasStateChanged()
public void setModel(VirtualTable vt)
Formular
/ the mapped components in the
Formular
to the default values of the specified
VirtualTable
vt
.setModel
in interface Formular
vt
- VirtualTable
to reset on.public void reset(VirtualTable vt)
Formular
/ the mapped components in the
Formular
to the default values of the specified
VirtualTable
vt
.
Alias for setModel(vt.createRow())
reset
in interface Formular
vt
- VirtualTable
to reset on.public void setModel(int row, VirtualTable vt)
Formular
/ the mapped components in the
Formular
with the values provided by the specified
row
in the VirtualTable
vt
.setModel
in interface Formular
row
- the row index of the VirtualTable
vt
- VirtualTable
to take the data from.VirtualTable.VirtualTableRow
,
Formular.setModel(VirtualTable.VirtualTableRow)
public void setModel(VirtualTable.VirtualTableRow virtualTableRow)
Formular
/ the mapped components in the
Formular
with the values provided by the specified
row
.setModel
in interface Formular
virtualTableRow
- VirtualTable.VirtualTableRow
to take the data from.VirtualTable.VirtualTableRow
,
Formular.setModel(int, VirtualTable)
public void putHiddenField(String name, Object value)
If value is null
this method will remove the field.
putHiddenField
in interface Formular
name
- the new hidden field namevalue
- the new hidden field value; if null
this method
will remove the fieldFormular.getHiddenField(String)
,
Formular.getHiddenFieldNames()
public Object getHiddenField(String name)
putHiddenField
will return a non-
null
value.getHiddenField
in interface Formular
name
- the being queriednull
Formular.putHiddenField(String, Object)
,
Formular.getHiddenFieldNames()
public final Iterable<String> getHiddenFieldNames()
getHiddenFieldNames
in interface Formular
Formular.putHiddenField(String, Object)
,
Formular.getHiddenField(String)
public VirtualTable.VirtualTableRow getVirtualTableRow()
VirtualTable.VirtualTableRow
.getVirtualTableRow
in interface Formular
VirtualTable.VirtualTableRow
Formular.setModel(VirtualTable.VirtualTableRow)
public VirtualTable getVirtualTable()
VirtualTable
of this Formular
.getVirtualTable
in interface Formular
VirtualTable
public void save() throws VirtualTableException, DBException
Alias for save(true).
save
in interface Formular
VirtualTableException
- if the new row can't be set to the VirtualTable
.DBException
- if the new row can't be propagated to the underling database.Formular.save(boolean)
public void save(boolean synchronizeDB) throws VirtualTableException, DBException
Propagates the values of this Formular
/ the mapped components in
the Formular
to the set VirtualTable
as new row if the
row is new to the VirtualTable
, otherwise an update is performed.
save
in interface Formular
synchronizeDB
- true
if the new row should be propagated to the
underling database as well; otherwise false
.VirtualTableException
- if the new row can't be set to the VirtualTable
.DBException
- if the new row can't be propagated to the underling database.public void update() throws VirtualTableException, DBException
update(true)
.update
in interface Formular
VirtualTableException
- if the values can't be set to the VirtualTable
.DBException
- if the values can't be propagated to the underling database.Formular.update(boolean)
public void update(boolean synchronizeDB) throws VirtualTableException, DBException
Propagates the values of this Formular
/ the mapped components in
the Formular
to the set VirtualTable
/ the set
VirtualTable.VirtualTableRow
.
Warning: In order to be able to update a row, you need
to set a VirtualTable.VirtualTableRow
for this Formular
. You can do
this by calling Formular.setModel(int, VirtualTable)
or
Formular.setModel(VirtualTable.VirtualTableRow)
.
update
in interface Formular
synchronizeDB
- true
if the changes should be propagated to the
underling database as well; otherwise false
.VirtualTableException
- if the values can't be set to the VirtualTable
.DBException
- if the values can't be propagated to the underling database.Formular.setModel(VirtualTable.VirtualTableRow)
public void updateRowsInVT(VirtualTable vt, KeyValues keyValues, boolean synchronizeDB) throws VirtualTableException, DBException
Propagates the values of this Formular
/ the mapped components in
the Formular
to the specified VirtualTable
vt
, to the rows which matches the given KeyValues
pkv
.
updateRowsInVT
in interface Formular
vt
- VirtualTable
to propagate the changes tokeyValues
- The values which identify the rows to updatesynchronizeDB
- true
if the changes should be propagated to the
underling database as well; otherwise false
.VirtualTableException
- if the values can't be set to the VirtualTable
.DBException
- if the values can't be propagated to the underling database.public void insertRowInVT(VirtualTable vt, boolean synchronizeDB) throws VirtualTableException, DBException
Propagates the values of this Formular
/ the mapped components in
the Formular
to the set VirtualTable
as new row.
insertRowInVT
in interface Formular
vt
- VirtualTable
to propagate the new row tosynchronizeDB
- true
if the changes should be propagated to the
underling database as well; otherwise false
.VirtualTableException
- if the values can't be set to the VirtualTable
.DBException
- if the values can't be propagated to the underling database.public void insert() throws VirtualTableException, DBException
Alias for insert(true).
insert
in interface Formular
VirtualTableException
- if the new row can't be set to VirtualTable
.DBException
- if the new row can't be propagated to underling database.Formular.insert(boolean)
public void insert(boolean synchronizeDB) throws VirtualTableException, DBException
Propagates the values of this Formular
/ the mapped components in
the Formular
to the set VirtualTable
as new row.
insert
in interface Formular
synchronizeDB
- true
if the new row should be propagated to the
underling database as well; otherwise false
.VirtualTableException
- if the new row can't be set to VirtualTable
.DBException
- if the new row can't be propagated to underling database.public void delete() throws VirtualTableException, DBException
Alias for delete(true).
delete
in interface Formular
VirtualTableException
- if row can't be deleted from VirtualTable
.DBException
- if the row can't be deleted from the underling database.Formular.delete(boolean)
public void delete(boolean synchronizeDB) throws VirtualTableException, DBException
Deletes the VirtualTable.VirtualTableRow
represented by this Formular
from the set VirtualTable
.
Warning: In order to be able to delete a row, you need
to set a VirtualTable.VirtualTableRow
for this Formular
. You can do
this by calling Formular.setModel(VirtualTable.VirtualTableRow)
or
Formular.setModel(int, VirtualTable)
.
delete
in interface Formular
synchronizeDB
- true
if the row should also be deleted from the
underling database as well; otherwise false
.VirtualTableException
- if row can't be deleted from VirtualTable
.DBException
- if the row can't be deleted from the underling database.public boolean verifyFormularComponents()
ture
if all values of all FormularComponent
s
of this Formular
could be verified, false
otherwise.
This method shows a message box, if a validation fails.
This is a alternative method forFormular.validateFormularComponents()
,
but this method returns a boolean depending on the validation's result,
not the result itself.verifyFormularComponents
in interface Formular
true
if all values of all FormularComponent
s
of this Formular
could be verified, false
otherwise.public Validation validateFormularComponents()
FormularComponent
s of this formular.
Example:
if(formular.validateFormularComponents().hasError()) { // show message } else { formular.save(); }
validateFormularComponents
in interface Formular
Validation.hasError()
public Validation validateFormularComponents(Validation validation)
FormularComponent
s of this formular depending on an
given validation object.validateFormularComponents
in interface Formular
Validation.hasError()
public void submit(String url, String target) throws IOException
Formular
to the given
url
.submit
in interface Formular
url
- url to send the contents totarget
- HTML target (_blank
, _parent
etc.)IOException
- if the submit failspublic String getURLAdd()
Formular
and their values.
e.g. ?txtFirstname=John&txtLastname=Doepublic QueryInfo createQuery(String connector) throws IllegalStateException, IllegalArgumentException
VirtualTable
with a WHERE
condition created by the values of the
FormularComponent
s of this formular.createQuery
in interface Formular
connector
- "AND" or "OR"VirtualTable
with
a WHERE
condition created by the values of the
FormularComponent
s of this formular.IllegalStateException
- if no data binding is availableIllegalArgumentException
- if connector != "AND" resp. "OR"Formular.createCondition(String, Collection)
,
Formular.search(String, VirtualTableOwner)
public Condition createCondition(String connector) throws IllegalArgumentException
Alias for createCondition(connector,null)
.
createCondition
in interface Formular
connector
- "AND" or "OR"WHERE
condition depending on the input component's
values, or null
if no values are availableIllegalArgumentException
- if connector != "AND" resp. "OR"Formular.createCondition(String, Query)
,
Formular.createCondition(String, Collection)
,
Formular.createQuery(String)
public Condition createCondition(String connector, Query query) throws IllegalArgumentException
Condition
depending on the input component's values and
their conditional settings.createCondition
in interface Formular
connector
- "AND" or "OR"query
- The Query
to create this WHERE
condition for
(optional)WHERE
condition depending on the input component's
values, or null
if no values are availableIllegalArgumentException
- if connector != "AND" resp. "OR"Formular.createCondition(String, Collection)
,
Formular.createQuery(String)
public Condition createCondition(String connector, Collection paramCollection) throws IllegalArgumentException
Condition
depending on the input component's values and
their conditional settings.createCondition
in interface Formular
connector
- "AND" or "OR"paramCollection
- The Collection
to add the WHERE
condition's
parameter to (optional)WHERE
condition depending on the input component's
values, or null
if no values are availableIllegalArgumentException
- if connector != "AND" resp. "OR"Formular.createCondition(String, Query)
,
Formular.createQuery(String)
public void search(String connector, VirtualTableOwner target) throws IllegalArgumentException
VirtualTableOwner
target.
First a Condition
depending on the input component's values and
their conditional settings is created and then handed over to
VirtualTableOwner.updateModel(Condition, Object...)
of
target
.
search
in interface Formular
connector
- "AND" or "OR"target
- the component to updateIllegalArgumentException
- if connector != "AND" resp. "OR"Formular.createCondition(String)
,
Formular.createCondition(String, Collection)
,
Formular.createCondition(String, Query)
,
Formular.createQuery(String)
public void putClientProperty(Object key, Object value)
The get/putClientProperty
methods provide access to a small
per-instance hashtable. Callers can use get/putClientProperty to annotate
components that were created by another module. For example, a layout
manager might store per child constraints this way. For example:
componentA.putClientProperty("to the left of",componentB);If value is
null
this method will remove the property.
Changes to client properties are reported with
PropertyChange
events. The name of the property (for the
sake of PropertyChange events) is key.toString()
.
The clientProperty
dictionary is not intended to support
large scale extensions to form nor should be it considered an alternative
to subclassing when designing a new component.
putClientProperty
in interface Formular
key
- the new client property keyvalue
- the new client property value; if null
this
method will remove the propertyFormular.getClientProperty(java.lang.Object)
public Object getClientProperty(Object key)
putClientProperty
will return a non-
null
value.getClientProperty
in interface Formular
key
- the being queriednull
Formular.putClientProperty(java.lang.Object, java.lang.Object)
public boolean isPagingEnabled()
isPagingEnabled
in interface Pageable
true
if the paging behavior is on,
false
otherwisePageable.setPagingEnabled(boolean)
public void setPagingEnabled(boolean pagingEnabled)
Pageable
setPagingEnabled
in interface Pageable
pagingEnabled
- true
if the paging should be controlled via the
Pageable.getPageControl()
Pageable.isPagingEnabled()
public void setPagingAutoQuery(boolean pagingAutoQuery)
public boolean getPagingAutoQuery()
public void setModelForPaging(VirtualTable vt) throws DBException
DBException
public void setModelForPaging(VirtualTable vt, SELECT select, Object... params) throws DBException
DBException
public VirtualFormularPageControl getPageControl()
getPageControl
in interface Pageable
Copyright © 2003–2021 XDEV Software. All rights reserved.