Java 如何使Apache ISIS中的集合显示在父对象屏幕中?

Java 如何使Apache ISIS中的集合显示在父对象屏幕中?,java,isis,Java,Isis,我有一个名为“Company”的域对象和一组名为“Location”的域对象 我可以添加每个的对象,并将位置关联到公司的父对象,但由于某些原因,位置对象表在公司页面中始终为空。我错过了什么 位置类别- @javax.jdo.annotations.PersistenceCapable(schema = "todo", table = "Locations", identityType = IdentityType.DATASTORE) @javax.jdo.annotations.Datasto

我有一个名为“Company”的域对象和一组名为“Location”的域对象

我可以添加每个的对象,并将位置关联到公司的父对象,但由于某些原因,位置对象表在公司页面中始终为空。我错过了什么

位置类别-

@javax.jdo.annotations.PersistenceCapable(schema = "todo", table = "Locations", identityType = IdentityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(strategy = javax.jdo.annotations.IdGeneratorStrategy.IDENTITY, column = "id")
@javax.jdo.annotations.Version(strategy = VersionStrategy.VERSION_NUMBER, column = "version")
@SuppressWarnings("serial")
public class Location extends AbstractDomainObject implements Comparable<Location> {

    public String title() {
        final TitleBuffer buf = new TitleBuffer();
        buf.append(getName());
        return buf.toString();
    }

    @Column(allowsNull = "false")
    @Property(editing = Editing.DISABLED)
    @Getter
    @Setter
    private Company company;

    @javax.jdo.annotations.Column(allowsNull = "false", length = 100)
    @Property(domainEvent = LocationNameDomainEvent.class, regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*", editing = Editing.ENABLED)
    @Getter
    @Setter
    private String name;

    public static class LocationNameDomainEvent extends LocationPropertyDomainEvent<String> {
    }

    @javax.jdo.annotations.Column(allowsNull = "false", length = 100)
    @Property(domainEvent = LocationAddressDomainEvent.class, regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*", editing = Editing.ENABLED)
    @Getter
    @Setter
    private String address;

    public static class LocationAddressDomainEvent extends LocationPropertyDomainEvent<String> {
    }

    @javax.jdo.annotations.Column(allowsNull = "true", length = 100)
    @Property(domainEvent = LocationAddress2DomainEvent.class, regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*", editing = Editing.ENABLED)
    @Getter
    @Setter
    private String address2;

    public static class LocationAddress2DomainEvent extends LocationPropertyDomainEvent<String> {
    }

    @javax.jdo.annotations.Column(allowsNull = "false", length = 100)
    @Property(domainEvent = LocationCityDomainEvent.class, regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*", editing = Editing.ENABLED)
    @Getter
    @Setter
    private String city;

    public static class LocationCityDomainEvent extends LocationPropertyDomainEvent<String> {
    }

    @javax.jdo.annotations.Column(allowsNull = "false", length = 2)
    @Property(domainEvent = LocationStateDomainEvent.class, regexPattern = "[A-ZA-Z]", editing = Editing.ENABLED)
    @Getter
    @Setter
    private String state;

    public static class LocationStateDomainEvent extends LocationPropertyDomainEvent<String> {
    }

    @javax.jdo.annotations.Column(allowsNull = "false", length = 5)
    @Property(domainEvent = LocationZipCodeDomainEvent.class, regexPattern = "[0-9]*5", editing = Editing.ENABLED)
    @Getter
    @Setter
    private String zipCode;

    public static class LocationZipCodeDomainEvent extends LocationPropertyDomainEvent<String> {
    }

    // region > events
    public static abstract class LocationPropertyDomainEvent<T> extends ToDoAppDomainModule.PropertyDomainEvent<Location, T> {
    }

    public static abstract class LocationActionDomainEvent extends ToDoAppDomainModule.ActionDomainEvent<Location> {
    }
    // endregion

    @Override
    public int compareTo(Location o) {
        // TODO Auto-generated method stub
        return String.valueOf(o).compareTo(this.name);
    }

}
@javax.jdo.annotations.PersistenceCapable(schema=“todo”,table=“Locations”,identityType=identityType.DATASTORE)
@DatastoreIdentity(strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,column=“id”)
@javax.jdo.annotations.Version(strategy=VersionStrategy.Version\u NUMBER,column=“Version”)
@抑制警告(“串行”)
公共类位置扩展了AbstractDomainObject{
公共字符串标题(){
最终标题缓冲buf=新标题缓冲();
追加(getName());
返回buf.toString();
}
@列(allowsNull=“false”)
@属性(编辑=编辑。禁用)
@吸气剂
@塞特
私营公司;
@Column(allowNull=“false”,长度=100)
@属性(domainEvent=LocationNameDomainEvent.class,regexpatern=“\\w[@&:\\-\\,\\.\+\\w]*”,editing=editing.ENABLED)
@吸气剂
@塞特
私有字符串名称;
公共静态类LocationNameDomainEvent扩展LocationPropertyDomainEvent{
}
@Column(allowNull=“false”,长度=100)
@属性(domainEvent=LocationAddressDomainEvent.class,regexpatern=“\\w[@&:\\-\\,\\.\+\\w]*”,编辑=编辑。已启用)
@吸气剂
@塞特
私有字符串地址;
公共静态类LocationAddressDomainEvent扩展LocationPropertyDomainEvent{
}
@Column(allowNull=“true”,长度=100)
@属性(domainEvent=LocationAddress2DomainEvent.class,regExpatern=“\\w[@&:\-\\,\\.\+\\w]*”,编辑=编辑。已启用)
@吸气剂
@塞特
私有字符串地址2;
公共静态类LocationAddress2DomainEvent扩展LocationPropertyDomainEvent{
}
@Column(allowNull=“false”,长度=100)
@属性(domainEvent=LocationCityDomainEvent.class,regExpatern=“\\w[@&:\-\\,\\.\+\\w]*”,编辑=编辑。已启用)
@吸气剂
@塞特
私人城市;
公共静态类LocationCityDomainEvent扩展LocationPropertyDomainEvent{
}
@Column(allowNull=“false”,长度=2)
@属性(domainEvent=LocationStateDomainEvent.class,regExpatern=“[A-ZA-Z]”,editing=editing.ENABLED)
@吸气剂
@塞特
私有字符串状态;
公共静态类LocationStateDomainEvent扩展LocationPropertyDomainEvent{
}
@Column(allowNull=“false”,长度=5)
@属性(domainEvent=LocationZipCodeDomainEvent.class,regexpatern=“[0-9]*5”,editing=editing.ENABLED)
@吸气剂
@塞特
私有字符串zipCode;
公共静态类LocationZipCodeDomainEvent扩展LocationPropertyDomainEvent{
}
//区域>事件
公共静态抽象类LocationPropertyDomainEvent扩展到OAppDomainModule.PropertyDomainEvent{
}
公共静态抽象类LocationActionDomainEvent扩展到OAppDomainModule.ActionDomainEvent{
}
//端区
@凌驾
公共内部比较(位置o){
//TODO自动生成的方法存根
返回字符串.valueOf(o).compareTo(this.name);
}
}
公司级-

@javax.jdo.annotations.PersistenceCapable(
        schema = "todo",
        table = "Company",
        identityType=IdentityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(
        strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
         column="id")
@javax.jdo.annotations.Version(
        strategy=VersionStrategy.VERSION_NUMBER, 
        column="version")
@javax.jdo.annotations.Uniques({
    @javax.jdo.annotations.Unique(
            name="Company_name_must_be_unique", 
            members={"name"})
})
@SuppressWarnings("serial")
public class Company extends AbstractDomainObject{

    public String title() {
        final TitleBuffer buf = new TitleBuffer();
        buf.append(getName());
        return buf.toString();
    }

    @javax.jdo.annotations.Column(allowsNull="false", length=100)
    @Property(
        domainEvent = CompanyNameDomainEvent.class,
        regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*",
            editing = Editing.ENABLED
    )
    @Getter @Setter
    private String name;
    public static class CompanyNameDomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Column(allowsNull="false", length=100)
    @Property(
        domainEvent = CompanyAddressDomainEvent.class,
        regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*",
            editing = Editing.ENABLED
    )
    @Getter @Setter
    private String address;
    public static class CompanyAddressDomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Column(allowsNull="true", length=100)
    @Property(
        domainEvent = CompanyAddress2DomainEvent.class,
        regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*",
            editing = Editing.ENABLED
    )
    @Getter @Setter
    private String address2;
    public static class CompanyAddress2DomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Column(allowsNull="false", length=100)
    @Property(
        domainEvent = CompanyCityDomainEvent.class,
        regexPattern = "\\w[@&:\\-\\,\\.\\+ \\w]*",
            editing = Editing.ENABLED
    )
    @Getter @Setter
    private String city;
    public static class CompanyCityDomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Column(allowsNull="false", length=2)
    @Property(
        domainEvent = CompanyStateDomainEvent.class,
        regexPattern = "[A-ZA-Z]",
            editing = Editing.ENABLED
    )
    @Getter @Setter
    private String state;
    public static class CompanyStateDomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Column(allowsNull="false", length=5)
    @Property(
        domainEvent = CompanyZipCodeDomainEvent.class,
        regexPattern = "[0-9]*5",
            editing = Editing.ENABLED
    )
    @Getter @Setter
    private String zipCode;
    public static class CompanyZipCodeDomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Column(allowsNull="true", length=100)
    @Property(
        domainEvent = CompanyWebsiteDomainEvent.class,
        editing = Editing.ENABLED
    )
    @Getter @Setter
    private String website;
    public static class CompanyWebsiteDomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Column(allowsNull="false", length=12)
    @Property(
        domainEvent = CompanyPhoneNumberDomainEvent.class,
        editing = Editing.ENABLED
    )
    @Getter @Setter
    private String phoneNumber;
    public static class CompanyPhoneNumberDomainEvent extends CompanyPropertyDomainEvent<String> { }


    @javax.jdo.annotations.Persistent(table="CompanyLocations", mappedBy="company")
    @javax.jdo.annotations.Join(column="dependingId")
    @javax.jdo.annotations.Element(column="dependentId")
    private Set<Location> locations = new TreeSet<>();
    @Collection()
    public Set<Location> getLocations() {
        return locations;
    }
    public void setLocations(final Set<Location> locations) {
        this.locations = locations;
    }
    public void addToLocations(final Location location) {
        getLocations().add(location);
    }
    public void removeFromLocations(final Location location) {
        getLocations().remove(location);
    }

    @Action
    @ActionLayout(cssClassFa = "fa fa-plus")
    @MemberOrder(sequence = "5")
    public Company newLocation(
            @Parameter(maxLength=100)
            final String name, 
            @Parameter(maxLength=100)
            final String address, 
            @Parameter(maxLength=100)
            final String address2, 
            @Parameter(maxLength=100)
            final String city, 
            @Parameter(maxLength=2)
            final String state, 
            @Parameter(maxLength=5)
            final String zipCode){
        Location location = repository.instantiate(Location.class);
        location.setName(name);
        location.setAddress(address);
        location.setAddress2(address2);
        location.setCity(city);
        location.setState(state);
        location.setZipCode(zipCode);
        location.setCompany(this);
        repository.persistAndFlush(location);
        return addLocation(location);
    }
    @Programmatic
    public Company addLocation(final Location location) {
        // By wrapping the call, Isis will detect that the collection is modified
        // and it will automatically send CollectionInteractionEvents to the Event Bus.
        wrapperFactory.wrapSkipRules(this).addToLocations(location);
        repository.persistAndFlush(this);
        return this;
    }
    @Programmatic
    public Company removeLocation(final Location location) {
        // By wrapping the call, Isis will detect that the collection is modified
        // and it will automatically send a CollectionInteractionEvent to the Event Bus.
        wrapperFactory.wrapSkipRules(this).removeFromLocations(location);
        repository.persistAndFlush(this);
        return this;
    }


    //region > events
    public static abstract class CompanyPropertyDomainEvent<T> extends ToDoAppDomainModule.PropertyDomainEvent<Company, T> { }
    public static abstract class CompanyActionDomainEvent extends ToDoAppDomainModule.ActionDomainEvent<Company> { }
    //endregion



    @javax.inject.Inject
    WrapperFactory wrapperFactory;
    @Inject
    Locations locationService;
    @javax.inject.Inject
    RepositoryService repository;

}
@javax.jdo.annotations.PersistenceCapable(
schema=“todo”,
table=“公司”,
identityType=identityType.DATASTORE)
@javax.jdo.annotations.DatastoreIdentity(
strategy=javax.jdo.annotations.IdGeneratorStrategy.IDENTITY,
column=“id”)
@javax.jdo.annotations.Version(
策略=VersionStrategy.VERSION\u编号,
column=“version”)
@javax.jdo.annotations.Uniques({
@javax.jdo.annotations.Unique(
name=“公司名称必须是唯一的”,
成员={“名称”})
})
@抑制警告(“串行”)
公共类公司扩展AbstractDomainObject{
公共字符串标题(){
最终标题缓冲buf=新标题缓冲();
追加(getName());
返回buf.toString();
}
@Column(allowNull=“false”,长度=100)
@财产(
domainEvent=CompanyNameDomainEvent.class,
regexpatern=“\\w[@&:\-\\,\\.\+\\w]*”,
编辑=编辑。已启用
)
@Getter@Setter
私有字符串名称;
公共静态类CompanyNameDomainEvent扩展了CompanyPropertyDomainEvent{}
@Column(allowNull=“false”,长度=100)
@财产(
domainEvent=CompanyAddressDomainEvent.class,
regexpatern=“\\w[@&:\-\\,\\.\+\\w]*”,
编辑=编辑。已启用
)
@Getter@Setter
私有字符串地址;
公共静态类CompanyAddressDomainEvent扩展了CompanyPropertyDomainEvent{}
@Column(allowNull=“true”,长度=100)
@财产(
domainEvent=CompanyAddress2DomainEvent.class,
regexpatern=“\\w[@&:\-\\,\\.\+\\w]*”,
编辑=编辑。已启用
)
@Getter@Setter
私有字符串地址2;
公共静态类CompanyAddress2DomainEvent扩展了CompanyPropertyDomainEvent{}
@Column(allowNull=“false”,长度=100)
@财产(
domainEvent=CompanyCityDomainEvent.class,
regexpatern=“\\w[@&:\-\\,\\.\+\\w]*”,
编辑=编辑。已启用
)
@Getter@Setter
私人城市;
公共静态类CompanyCityDomainEvent扩展了CompanyPropertyDomainEvent{}
@Column(allowNull=“false”,长度=2)
@财产(
domainEvent=CompanyStateDomainEvent.class,
regexpatern=“[A-ZA-Z]”,