Использование .withContainer()

Доброго дня.

Есть Родитель и Потомки. Есть броуз-экран, в котором показываю всех Потомков, как Родителя.
С помощью PopupButton вызываю следующий метод для создания потомка:

    @Inject
    private CollectionContainer<Unit> unitsDc;

    private <T extends Unit> void newUnit(Class<T> entityClass) {
        screenBuilders.editor(entityClass, this)
                .newEntity()
//                .withContainer(unitsDc)
                .build()
                .show();
    }

Так вот вопрос. Как мне правильно обновить броуз-экран после коммита, создаваемого экземпляра? withContainer использовать не получается:

withContainer
(com.haulmont.cuba.gui.model.CollectionContainer<T>)
in EditorBuilder cannot be applied
to
(com.haulmont.cuba.gui.model.CollectionContainer<com.borets.wedb.entity.Unit>)

Хотя может просто не докрутил чего-то с дженериками…

Получилось как-то так… Может кто подскажет и другие варианты.

    @Inject
    private GroupTable<Unit> unitsTable;

    private <T extends Unit> void newUnit(Class<T> entityClass) {
        screenBuilders.editor(entityClass, this)
                .newEntity()
                .withListComponent(((WebGroupTable) unitsTable))
                .build()
                .show();
    }

Здравствуйте,

Приведение типа к WebGroupTable не требуется. Эту задачу можно решать так:

@Inject
protected ScreenBuilders screenBuilders;
@Inject
protected Table<Customer> customersTable;

@SuppressWarnings("unchecked")
private void createCustomer(Class entityClass) {
    screenBuilders.editor(customersTable)
            .newEntity((Customer) metadata.create(entityClass))
            .build()
            .show();
}

У нас есть небольшой демо-проект, в котором показан похожий пример: https://github.com/cuba-labs/entity-aware-edit

1 симпатия

Спасибо за подсказку, Юрий.

Оставил вот так:

    private <T extends Unit> void newUnit(Class<T> entityClass) {
        screenBuilders.editor(unitsTable)
                .newEntity(metadata.create(entityClass))
                .build()
                .show();
    }

Не приходится душить предупреждение и преобразовывать тип.

Сообщение перенесено в новую тему: Открытие редактора композиции