public class DataTable extends Control implements IContainer
A Data Table is composed by the Data Model backing up the actual content and an Entry Model defining what is shown from each entry and how. The Entry Model is like a Group, any Control (except Submits or other Data Tables) can be added to it. Each Control added must reference a Path from the entries in Data Model, and must not have an initial value. The Entry Model will be repeated for each entry in the Data Model, and each of its Controls initialized with the data of that Entry found in the given reference Path of the Control.
WARNING: A Data Table is like a Group, it must be added to a SimpleUIRequest or a Group BEFORE any element can be added to its Entry Model. This is because the Tables�s Entry Model is not actually created until it's added. The Data Model however must be set BEFORE the Data Table is added, thus the order of operations is the following: 1) Create Data Table. 2) Set Data Model. 3) Add Data Table to parent. 4) Add Controls to Entry Model.
There are two ways of constructing Data Tables: Inferring the Data Model entries from the parent's root resource or setting the Data Model entries explicitly.
Example render:
Label --------------------------------------- | Control1Label | Control2Label | --------------------------------------- | Control1Render(1) | Control2Render(1) | --------------------------------------- | Control1Render(2) | Control2Render(2) | --------------------------------------- | Control1Render(3) | Control2Render(3) | --------------------------------------- ...
Constructor and Description |
---|
DataTable()
Generic empty constructor.
|
DataTable(String ref)
Constructor with the reference of the Table Data Model to be used .
|
DataTable(String label,
Resource[] initialEntries)
Constructor without reference of Table Data Model.
|
DataTable(String ref,
String label)
Constructor with the reference of the Table Data Model to be used .
|
Modifier and Type | Method and Description |
---|---|
String[] |
add(Control ctrl)
Add the given Simple Control UI element to the Table Entry Model.
|
void |
addEntry(Resource entry)
Add an entry to the Data Model backing up this Data Table.
|
String[] |
create(Group group)
This method is for internal use of utils only.
|
Resource[] |
getEntries()
Get the entries of the Data Model backing up this Data Table.
|
Boolean |
isDeletable()
Check if entries can be removed by the user.
|
Boolean |
isEditable()
Check if entries can be edited by the user.
|
Boolean |
isExpandable()
Check if entries can be added by the user.
|
void |
setDeletable(Boolean deletable)
Set if entries can be removed by the user.
|
void |
setEditable(Boolean editable)
Set if entries can be edited by the user.
|
void |
setEntries(Resource[] entries)
Set the entries of the Data Model backing up this Data Table.
|
void |
setExpandable(Boolean expandable)
Set if entries can be added by the user.
|
getHelp, getHint, getLabel, getReference, setHelp, setHint, setLabel, setReference, setReference
public DataTable()
public DataTable(String ref)
Location root=new Location(URI1);
Location adj=new Location(URI2);
root.addAdjacentLocation(adj);
Dialog d=new Dialog(user,"Title",root);
DataTable rp=new DataTable(Location.PROP_IS_ADJACENT_TO);
take into account that the referenced property must allow cardinality > 1ref
- The simple reference identifying the Table Data Model from the
parent root. Set to null to auto-generate and not use a Data
Model from the root.public DataTable(String ref, String label)
Location root=new Location(URI1);
Location adj=new Location(URI2);
root.addAdjacentLocation(adj);
Dialog d=new Dialog(user,"Title",root);
DataTable rp=new DataTable(Location.PROP_IS_ADJACENT_TO);
take into account that the referenced property must allow cardinality > 1ref
- The simple reference identifying the Table Data Model from the
parent root. Set to null to auto-generate and not use a Data
Model from the root.label
- The label text that identifies the Table to the user.public DataTable(String label, Resource[] initialEntries)
label
- The label text that identifies the Table to the user.initialEntries
- Array of Resources representing the entries of the Data Model.public String[] create(Group group)
Control
create
in class Control
group
- The UI group to which the control is being added.public String[] add(Control ctrl)
(Root) --PROP1-- (ResA) --PROP2-- (ResB) _____________ Table Path _____________ Control PathIf the Table used explicit entries instead of a reference path, then the reference of the Controls must start with (or be) one of the properties of the type of Resource used for the explicit entries.
Once the control is added it cannot be modified. Controls are renedered in the same order they are added. Controls that are Containers and can add elements as well, like Group or DataTables, must be added BEFORE other controls can be added to them. Controls that need references, like Inputs (with property paths), or Submits (with IDs) will be given an automatic reference if none was set. This reference will be returned by this method, in the form of an Array of Strings representing the reference: a Path for Inputs, or a single String for Submits IDs.
add
in interface IContainer
ctrl
- The Simple Control UI element to be added.public Boolean isDeletable()
public void setDeletable(Boolean deletable)
deletable
- If entries can be removed by the user.public Boolean isEditable()
public void setEditable(Boolean editable)
editable
- If entries can be edited by the user.public Boolean isExpandable()
public void setExpandable(Boolean expandable)
expandable
- If entries can be added by the user.public Resource[] getEntries()
public void addEntry(Resource entry)
option
- The entry to add to the Data Model.public void setEntries(Resource[] entries)
entries
- An array of Resources representing the entries the Data Model.Copyright © 2018 universAAL Consortium. All rights reserved.