2

Given an Apache Isis project with a simple domain model such as below, what are the absolute minimum requirements for a create dialogue that will display a dropdown selection of all available Offices when creating a new Person?

Current state: I can create an office objects, list all office objects, but when I want to create a Person, the create dialogue doesn't show a dropdown of the available offices, it just says "(none)" (see screenshot).

Currently my create dialogue for Person looks like this:

Person create dialog

How can I display a dropdown of all available offices in this dialogue?

Here is a rough layout of the DOM code I have (JDO annotations omitted):

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

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

and corresponding menu/repository classes such as

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);
    }    
}
mwhs
  • 5,878
  • 2
  • 28
  • 34

1 Answers1

1

You can use the choices supporting method, the autoComplete supporting method, or annotate the referenced class as @DomainObject(bounded=true). The latter is mostly appropriate for reference data objects with a limited (ie bounded) number of instances.

eg:

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

See these apache isis docs for (links to) further detali.

If you have other questions, I recommend you sign up to the apache.isis mailing list.

Thx Dan

Dan Haywood
  • 2,215
  • 2
  • 17
  • 23
  • Thx Dan. I tried looking into the documentation earlier but exactly this part of the documentation is empty and only says "TODO". – mwhs Sep 16 '16 at 06:38
  • re the docs... well, they are not quite empty, because they do have links to the relevant parts of the reference guides. But I do admit that at first glance it would seem that there's no info there. Re: the code snippet, have fixed (my bad). – Dan Haywood Sep 16 '16 at 08:32
  • Thanks for clarifying Dan. On a side note: is there actually a reference of the isis metamodel constructed form the java code? I was reading through the [project ideas](https://cwiki.apache.org/confluence/display/ISIS/ProjectIdeasForStudents) and it talks about the programming model, but I wasn't able to find any documentation on the metamodel itself. Just curious if you could point me somewhere, even a place in the code. – mwhs Sep 16 '16 at 10:57
  • You would never have found this, but I did write up some stuff on this [README](https://github.com/alejandro-du/vaadin-viewer) for a viewer that one of the vaadin guys was going to do as his 10% project, but never found the time. – Dan Haywood Sep 16 '16 at 12:05