【问题标题】:Apache Isis: create dialog with referenced object dropdownApache Isis:使用引用的对象下拉菜单创建对话框
【发布时间】:2016-09-16 16:32:26
【问题描述】:

假设 Apache Isis 项目具有如下所示的简单域模型,在创建新人员时,创建对话框将显示所有可用办公室的下拉选择的绝对最低要求是什么?

当前状态:我可以创建一个办公室对象,列出所有办公室对象,但是当我想创建一个人时,创建对话框没有显示可用办公室的下拉列表,它只是说“(无)”(见截图)。

目前我为 Person 创建对话如下所示:

如何在此对话框中显示所有可用办公室的下拉列表?

这是我拥有的 DOM 代码的粗略布局(省略了 JDO 注释):

public class Office {
    private String name;
    // getter/setter ...
}

public class Person {
    private String name;
    private Office office;
    // getter/setter...
}

以及相应的菜单/存储库类,例如

public class OfficeRepository {
    public List<Office> listAll() {
        // ...
    }
}

public class PersonRepository {
    public Person create(String name, final Office office) {
        // ...
    }
}

public class PersonMenu {
    public static class CreateDomainEvent extends ActionDomainEvent<Person> {}    
    @Action(domainEvent = CreateDomainEvent.class)        
    public Person create(
        @ParameterLayout(named="Name")
        final String name,
        final Office office) {
        return personRepository.create(name, office);
    }    
}

【问题讨论】:

    标签: isis


    【解决方案1】:

    你可以使用choices支持方法,autoComplete支持方法,或者将引用的类注解为@DomainObject(bounded=true)。后者主要适用于实例数量有限(即有界)的引用数据对象。

    例如:

    public List<Office> choices1Create()
        return officerRepository.findAll();
    } 
    

    请参阅这些apache isis docs 了解(链接到)更多详细信息。

    如果您还有其他问题,我建议您注册 apache.isis mailing list

    谢谢 丹

    【讨论】:

    • 谢谢丹。我之前尝试过查看文档,但这部分文档是空的,只写了“TODO”。
    • re 文档...好吧,它们不是很空,因为它们确实具有指向参考指南相关部分的链接。但我承认,乍一看,那里似乎没有任何信息。回复:代码 sn-p,已修复(我的错误)。
    • 感谢丹的澄清。附带说明:实际上是否有从 java 代码构造的 isis 元模型的引用?我正在阅读project ideas,它谈到了编程模型,但我找不到关于元模型本身的任何文档。只是好奇你能不能给我指出一个地方,甚至是代码中的一个地方。
    • 你永远不会发现这个,但我确实在这个 README 上为一位观众写了一些东西,其中一个 vaadin 人将作为他 10% 的项目做,但从未找到时间。
    猜你喜欢
    • 1970-01-01
    • 2017-03-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多