Hi Martin,

This requirement has only come up infrequently so far, not sufficiently to
build a particular widget or programming model for it.

Where we have required it, we've simply provided two optional parameters,
one listing the existing objects, the other for the name of a new object.
 (This assumes that a single string is sufficient to create said new
object).

public Concert create(@Nullable ConcertLocation
existingConcertLocation, @Nullable String newConcertLocationName, String
concertName) {

    ConcertLocation concertLocation =
        existingConcertLocation != null
         ? existingConcertLocation
         : concertLocationRepository.findOrCreate(newConcertLocationName);

    return concertRepository.create(concertName, concertLocation);
}
public String validateCreate(ConcertLocation existingConcertLocation,
String newConcertLocationName, String concertName) {
    if (existingConcertLocation == null && newConcertLocationName == null)
return "Specify either an existing location or the name of a new one";
    if (existingConcertLocation != null && newConcertLocationName != null)
return "Specify either an existing location or the name of a new one";
    return null;
}

However, that has the side effect of cluttering up the common use case (new
Concert in an existing ConcertLocation), so I don't know if it's worth the
effort.  My recommendation would simply be to treat the creation of concert
locations and of new concerts independently.

HTH
Dan




On 28 September 2016 at 09:32, Martin <mwhesse+apachem...@gmail.com> wrote:

> Let's say we have an entity Concert and an entity ConcertLocation and the
> model is such that a Concert would reference a ConcertLocation (shared
> ManyToOne association).
>
> In a create dialogue for the Concert entity I would like to offer the
> possibility to create a new ConcertLocation item if the desired location is
> not found in the dropdown or select box.
>
> This could for instance be by displaying a "create new location" icon next
> to the dropdown box for locations or anything else, which would then open
> another modal on top of the create dialogue to create that
> new ConcertLocation.
>
> Once the new ConcertLocation has been created it should then appear in the
> list of available locations in the Concert create dialogue.
>
> How would I go about this in Apache Isis?
>
> I haven't found anything of the kind in the kitchen sink or the todo app or
> any other examples available.
>
> Thanks and regards,
> Martin
>

Reply via email to