This discussion is archived
3 Replies Latest reply: May 21, 2012 5:37 AM by Steven Davelaar RSS

Programmatically add rows to a child table

Brent Harlow Newbie
Currently Being Moderated
Hi guys,

JHeadstart 11.1.13

I have a wizard created with master/detail records. On the first page of the wizard, the user enters details for the newly created master record. On the next page of the wizard, the detail group is shown as a table. When this wizard page is displayed I need the detail table to be pre-populated with a number of rows. In each row I need one of the attributes displayed to be populated from a static list

eg

1. First train stop : New Patient
2. Second stop : Table of patient medical history, populated with 5 rows - the first column of each row populated with values ('ValueA','ValueB','ValueC' etc...)

How should I go about doing this ?

Do I override the PatientRowImpl class and create the detail records in there ? Do I create a new method in the AM to get the current patient record, create the details records and then use the taskflow to run the method before the second train stop loads ? Or backing bean method that executes appropriate "CreateXXX" operation binding and wire that method into wizard flow ?

Cheers,
Brent
  • 1. Re: Programmatically add rows to a child table
    Steven Davelaar Employee ACE
    Currently Being Moderated
    Brent,

    It is easiest to implement this in the Patient EO in the Create method, after calling super you also create the 5 detail rows.

    Steven Davelaar,
    JHeadstart team.
  • 2. Re: Programmatically add rows to a child table
    Brent Harlow Newbie
    Currently Being Moderated
    Hi Steven,

    Brilliant, that worked a treat thanks :)

    One more question on topic, what is the best way to approach this to be able to create new detail records for an existing parent ? So for new parent/new child I created my child rows in the parent EO create method.

    I am also using the wizard layout to edit existing parent records. On one of the train stops, I need new child records created and attached to the existing parent record. The user needs to update the details records during the transaction so I can't simply create the child records in the parent doDML method after the user has saved the transaction.

    Cheers,
    Brent
  • 3. Re: Programmatically add rows to a child table
    Steven Davelaar Employee ACE
    Currently Being Moderated
    Brent,

    If they always update some fixed attribute in the existing parent row, you could implement it in this setAttribute method.
    If not, you need to create an AM method that creates the child rows, and then either call this method using a method activity in the taskflow, or using the invokeAction executable in the page def.

    Steven Davelaar,
    Jheadstart Team.

Legend

  • Correct Answers - 10 points
  • Helpful Answers - 5 points