Thanks a lot! Worked on first try! But what do I have to add to delete the domain object at the same time as I am removing it from the collection?
Med vennlig hilsen / Best regards, Marianne Hagaseth Forsker – Maritime transportsystemer Research Scientist – Maritime Transport Systems MARINTEK (Norsk Marinteknisk Forskningsinstitutt AS) Address: POB 4125 Valentinlyst, NO-7450 Trondheim, Norway Mobile: +47 90 95 64 69 - Phone: +47 464 15 000 Web: www.marintek.sintef.no -----Original Message----- From: Stephen Cameron [mailto:[email protected]] Sent: 3. mars 2016 12:09 To: [email protected] Subject: Re: How to create a new object at the same time when adding it to a list? correction: 'participations' collection header On Thu, Mar 3, 2016 at 10:07 PM, Stephen Cameron <[email protected] > wrote: > These two actions appear as buttons in the Participants collection > header. > > @Action() > @ActionLayout(named = "Add") > @MemberOrder(name = "participations", sequence = "1") > public Activity addParticipant(final Participant participant) { > if (findParticipation(participant) == null) { > participantsRepo.createParticipation(this, participant); > } else { > container.informUser("A Participant (" + > participant.getFullName() + ") is already participating in this Activity"); > } > return this; > } > > @Action() > @ActionLayout(named = "Add New") > @MemberOrder(name = "participations", sequence = "2") > public Activity addNewParticipant(final @ParameterLayout(named = > "First name") String firstname, final @ParameterLayout(named = > "Surname") String surname, > final @ParameterLayout(named = "Date of Birth") LocalDate > dob) { > addParticipant(participantsRepo.newParticipant(firstname, > surname, dob)); > return this; > } > > On Thu, Mar 3, 2016 at 9:44 PM, Marianne Hagaseth < > [email protected]> wrote: > >> Sorry, >> What I have is just a simple 1:n relationship with a list of object >> similar to for instance the todo-app: for the todoapp-admin, you can >> add a list of roles to each user. However, here the roles must have >> been already entered before a role can be added to the user. >> I just want to add an object (similar to the role) at the same time >> as I add it to the collection/set. >> In my example: I want to create the FreeText object and then add this >> FreeText object to the collection/set that is linked to the parent object. >> All in one operation. I do not want to first enter the FreeText >> object in a different window. >> >> >> Med vennlig hilsen / Best regards, >> Marianne Hagaseth >> Forsker – Maritime transportsystemer >> Research Scientist – Maritime Transport Systems >> >> MARINTEK (Norsk Marinteknisk Forskningsinstitutt AS) >> Address: POB 4125 Valentinlyst, NO-7450 Trondheim, Norway >> Mobile: +47 90 95 64 69 - Phone: +47 464 15 000 >> Web: www.marintek.sintef.no >> >> -----Original Message----- >> From: Dan Haywood [mailto:[email protected]] >> Sent: 3. mars 2016 09:42 >> To: users >> Subject: Re: How to create a new object at the same time when adding >> it to a list? >> >> I'm struggling to follow. >> Can you show us some code (abbreviated if possible ) to explain what >> you have already. >> Thx, Dan >> On 3 Mar 2016 7:11 am, "Marianne Hagaseth" < >> [email protected]> wrote: >> >> > Hi, >> > >> > How can I add new FreeTexts to the SOLAS object that currently does >> > not exist? >> > >> > I would like to press the Add FreeText button, then I do not want >> > to choose between existing FreeText objects. Rather, I would like >> > to create new FreeText objects on the fly, and then have this >> > object linked to the SOLAS object (1:n between SOLAS and freetext). >> > >> > Are there an example out there on how to do that? >> > >> > Best, >> > >> > Marianne. >> > >> > >> > >> > >> > >> > Med vennlig hilsen / Best regards, >> > >> > *Marianne Hagaseth* >> > >> > Forsker – Maritime transportsystemer >> > >> > Research Scientist – Maritime Transport Systems >> > >> > >> > >> > *MARINTEK* (Norsk Marinteknisk Forskningsinstitutt AS) >> > >> > Address: POB 4125 Valentinlyst, NO-7450 Trondheim, Norway >> > >> > Mobile: +47 90 95 64 69 - Phone: +47 464 15 000 >> > >> > Web: www.marintek.sintef.no >> > >> > >> > >> > >
