0

我有表格字段作为模板。

对于此表字段,我使用注释创建了表单数据

@FormData(value = AbstractMyTableData.class, sdkCommand = FormData.SdkCommand.USE, defaultSubtypeSdkCommand = FormData.DefaultSubtypeSdkCommand.CREATE)
public abstract class MyTableField extends AbstractTableField<MyTableField.Table>

在 MyTableField.Table 中,我有n列,所有列都显示在该字段的表单数据中,因此我可以添加如下行:

int rowNum = formData.addRow();
formData.setColumn_1(rowNumber, value);
....
formData.setColumn_n(rowNumber, value);

现在我想扩展我的表,而不是:

public class Table extends AbstractExtensibleTable {

我现在有

public class Table extends AbstractTreeTable {

AbstractTreeTable 是来自此链接的模板。

它里面有两个新的列。我的问题是 AbstractMyTableData 里面仍然只有n列而不是那两个。因此,当我创建新行时,addRow我无法将这两个值设置为该行。

请帮忙。


额外的

我没有看到这AbstractTableFieldBeanData不仅仅是随机的类名AbstractMyTableFieldData,而是创建不同类型的表单数据。

现在我有了基于 bean 的表数据。

但我的问题仍然存在。即使在基于 bean 的新数据中,也只有 myTable 中的列,而不是 treeTable 中的列。

我的层次结构就像@Jmini 描述的那样。

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)

MyTableField.Table是里面的MyTableField女巫是模板。

所以我的代码如下所示:

@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 {

AbstractTreeTable我没有像@Jmini 建议的任何注释。

我添加如下行:

 MyTableFieldRowData row = formData.addRow();
 row.setColumn1(value);

但里面MyTableFieldRowData没有额外的行AbstractTreeTable

我错过了什么吗?

4

1 回答 1

0

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.

于 2015-02-06T10:27:32.450 回答