问题
I have Table field as Templates.
For this Table field I have form data created with anotation
@FormData(value = AbstractMyTableData.class, sdkCommand = FormData.SdkCommand.USE, defaultSubtypeSdkCommand = FormData.DefaultSubtypeSdkCommand.CREATE)
public abstract class MyTableField extends AbstractTableField<MyTableField.Table>
Inside MyTableField.Table I have n
column and all of them is presented in form data for this field, so I can add rows like :
int rowNum = formData.addRow();
formData.setColumn_1(rowNumber, value);
....
formData.setColumn_n(rowNumber, value);
Now I want to extend my table so instead of :
public class Table extends AbstractExtensibleTable {
I now have
public class Table extends AbstractTreeTable {
AbstractTreeTable is template from this link.
It has two new columns inside. My problem is that inside AbstractMyTableData there is still only n
columns and not those two. So when I create new row by addRow
I can't set those two values to the row.
Pleas help.
Additional
I did't see that AbstractTableFieldBeanData
is not just random class name like AbstractMyTableFieldData
, but create different kind of form data.
Now I have bean based table data.
But my problem remain. Even in new bean based data, there is just columns from myTable and not from treeTable.
My hierarchy is like @Jmini described.
AbstractTable
| (no columns defined as inner class)
|
\---AbstractTreeTable
| (2 columns defined as inner class: ParentKeyColumn and KeyColumn)
|
\---MyTableField.Table
(additional columns defined as inner class)
This MyTableField.Table
is inside MyTableField
witch is template.
So my code looks like this :
@FormData(sdkCommand = FormData.SdkCommand.CREATE, value = AbstractTableFieldBeanData.class, defaultSubtypeSdkCommand = FormData.DefaultSubtypeSdkCommand.CREATE)
public abstract class MyTableField extends
AbstractTableField<MyTableField.Table> {
....
@Order(10.0)
public class Table extends AbstractTreeTable {
in AbstractTreeTable
I don't have any annotation like @Jmini suggest.
I add rows like :
MyTableFieldRowData row = formData.addRow();
row.setColumn1(value);
but inside MyTableFieldRowData
there is no additional rows from AbstractTreeTable
Have I miss something ?
回答1:
Array based TableData:
If you methods like this in the FormData:
LoremTable table = formData.getLoremTable();
int r = table.addRow();
table.setAaaa(r, "Hello world");
table.setBbbb(r, 42);
You are using Array based TableData.
Bean based TableData:
If you methods like this in the FormData:
IpsumTable table = formData.getIpsumTable();
IpsumTableRowData rowData = table.addRow();
rowData.setAaaa("Hello world");
rowData.setBbbb(42);
You are using Bean based TableData.
Your case:
To summarize your case, you have a TableField with a Table having a complex inheritance graph looking like that:
AbstractTable
| (no columns defined as inner class)
|
\---AbstractTreeTable
| (2 columns defined as inner class: ParentKeyColumn and KeyColumn)
|
\---MyTableField.Table
(additional columns defined as inner class)
You will need bean based table data, because with array based table data, the SDK will only consider the columns of MyTableField.Table
to generate the formData. With bean based table data you will get all the columns you expect.
A possible way to solve your problem, is to change the generated table data in the formData. This is configured on the table field class in the form.
Check the type hierarchy of your table field class:
AbstractTableField (defined in the scout jar -> you can not modify it)
|
\---MyTableField
The SDK checks the FormData
annotation down the type hierarchy.
With Scout Version smaller than 4.2, AbstractTableField
is configured to use array based table data. With version bigger than 4.3 it is configured to use bean based table data.
At each level you can define something else. For example at MyTableField
level. You can do something like that:
@FormData(sdkCommand = FormData.SdkCommand.USE, value = AbstractTableFieldBeanData.class, defaultSubtypeSdkCommand = FormData.DefaultSubtypeSdkCommand.CREATE)
public class MyTableField extends AbstractTableField<MyTableField.Table>
This will change the generated code.
On the wiki you can read additional examples. For example is you have something like:
AbstractTableField
|
\---AbstractMyAppTableField
|
\---MyTableField
You can define the table data you want at AbstractMyAppTableField
. If all your table field extends AbstractMyAppTableField
(which is a recommended practice), with one single config you can change all the table data of your application and you ensure that each developer will use the same pattern.
来源:https://stackoverflow.com/questions/28362697/column-in-extended-table-are-not-presented-in-form-data-on-eclipse-scout