Scout的表单数据中未显示扩展表中的列

Scout的表单数据中未显示扩展表中的列

本文介绍了Eclipse Scout的表单数据中未显示扩展表中的列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有Table字段作为模板.

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>

在MyTableField.Table里面,我有n列,并且所有这些都以该字段的表单数据形式显示,因此我可以添加以下行:

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 {

我现在有

public class Table extends AbstractTreeTable {

AbstractTreeTable是此链接的模板.

AbstractTreeTable is template from this link.

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

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.

请帮助.

其他

我没有看到AbstractTableFieldBeanData不仅是像AbstractMyTableFieldData这样的随机类名,而且还创建了不同类型的表单数据.

I did't see that AbstractTableFieldBeanData is not just random class name like AbstractMyTableFieldData, but create different kind of form data.

现在我有基于bean的表数据.

Now I have bean based table data.

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

But my problem remain. Even in new bean based data, there is just columns from myTable and not from treeTable.

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

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)

MyTableField.Table位于MyTableField内部,是模板.

This MyTableField.Table is inside MyTableField witch is template.

所以我的代码如下:

@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建议之类的注释.

in AbstractTreeTable I don't have any annotation like @Jmini suggest.

我添加如下行:

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

,但在MyTableFieldRowData内部,没有来自AbstractTreeTable

but inside MyTableFieldRowData there is no additional rows from AbstractTreeTable

我错过了什么吗?

推荐答案

基于数组的TableData:

如果您在FormData中使用类似方法:

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);

您正在使用基于数组的TableData .

如果您在FormData中使用类似方法:

If you methods like this in the FormData:

IpsumTable table = formData.getIpsumTable();
IpsumTableRowData rowData = table.addRow();
rowData.setAaaa("Hello world");
rowData.setBbbb(42);

您正在使用基于Bean的TableData .

总结一下您的情况,您有一个TableField,其中一个Table带有一个复杂的继承图,如下所示:

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)

您将需要基于bean的表数据,因为对于基于数组的表数据,SDK将仅考虑MyTableField.Table的列来生成formData.使用基于bean的表数据,您将获得所需的所有列.

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.

解决问题的一种可能方法是更改​​formData中生成的表数据.这是在表格字段类上配置的.

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

SDK在类型层次结构中检查FormData批注.

The SDK checks the FormData annotation down the type hierarchy.

当Scout版本小于4.2时,AbstractTableField被配置为使用基于数组的表数据.大于4.3的版本将其配置为使用基于bean的表数据.

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.

在每个级别上,您都可以定义其他内容.例如在MyTableField级别.您可以执行以下操作:

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>

这将更改生成的代码.

在Wiki上,您可以阅读其他示例.例如,您有类似的东西:

On the wiki you can read additional examples. For example is you have something like:

AbstractTableField
|
\---AbstractMyAppTableField
    |
    \---MyTableField

您可以在AbstractMyAppTableField定义所需的表数据.如果您所有的表字段都扩展了AbstractMyAppTableField(建议的做法),则只需一个配置,就可以更改应用程序的所有表数据,并确保每个开发人员都将使用相同的模式.

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.

这篇关于Eclipse Scout的表单数据中未显示扩展表中的列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 07:20