This content has been marked as final. Show 4 replies
Others will be have different suggestions, but here is what I'd do.
I'd suggest that you steer away from trying to store all of the information inside of each work item instance's payload. Instead, have the BPM process store the ID and then use that ID to retrieve the information from the database using ADFbc when the ADF form loads. It's not obvious how this is done and I struggled with it as well. Here's a blog post I wrote a few months ago that describes step-by-step how this is done- http://www.avioconsulting.com/blog/datwood/2012/06/19/using-bpm-process-variable-adf-form-retrieve-database-information-0.
Sure you've already done this, but hit the Oracle ADF forum (JDeveloper and ADF This forum is incredibly active and if you decide to go the ADFbc database route, they'll be able to help you with your ADF form questions.
1. Dan already put you in the right direction with his tips and pointers. We have a similar use-case but not for like "n" number of records but for a single record set. The below steps should give you an idea. You may find other approaches also. I used ADF BC stuff with minimal code possible.
2. Create a DB Table (hopefully you already have), with columns like ID (Pk, uses Sequence Generator), BpmTaskNumber (this is the unique TaskId for each Process that you get from Payload), and your own custom columns like MY_DATE, MY_YEAR, MY_COL1, MY_COL2, MY_COL3 etc. If you familiar with JPA/Entities/ADF Framework, then just create a Java Entity for this Table. For PK variable add annotation to automatically generate the sequence using sequence generator for the PK value. Lets name this Entity as "MyEntity.java".
3. Create a simple stateless Session EJB with couple of methods to create/read records from this table using Entities. Test them from a simple java client, to make sure all this works as expected.
4. Now coming to integrating on the screen, for you TaskDetails jspx, create a simple ADF ManagedBean and link it to this page. Your task details page should already have lots of out of box managed beans linked in adf-config.xml file etc. On task details page, you may have dragged your 2 payload elements for startDate and endDate. Now add a Command Button (for now) and for this create a action method in your own managed bean like generateForm(). This managed bean, will have a instance variable of type List that corresponds to your entity like List<MyEntity> myEntities = new ArrayList<Entity>(); In generateForm() method, first using bindings get the startDate, endDate values. Do basic validation like they both are entered etc. If yes, get the difference between those dates (months). Create that many Empty MyEntity instances like MyEntity myEnt = new MyEntity() in a loop and add to the myEntities list.
5. On the TaskDetails jsp file, create a af:table component, for this myEntities list. Then for columns add all your columns with input text fields, date fileds, etc etc. Do NOT add bpmTaskNumber, ID for now.
6. For quick testing, add another button like "MySave" that calls another new method on your manage bean like saveData(). In this saveData(), get the fully populated myEntites list. Get taskId from the task payload and set it to each record to the variable bpmTaskNumber. This is very important. Because once the taskDetails page is saved and log out. Next day when you open that task details page, you should see all the "n" number of rows. This is where you will use your taskId from payload and do a query on your EJB with that bpmTaskNumber that pulls all records (MyEntity) and show on screen.
7. Once all this works on click on 2 buttons like "GenerateForm" and 'MySave", now you to link them to actual Task Save, Submit actions etc. For generation form, go with custom button or do like onChange of second date fields etc. But for task actions, look at the code snippet, you can hook up your own new method in the actionListener. In this first save "n" records to database and then continue the task action. Basically you had to intercept the out of box actions. I have a code snippet in this below post.
https://forums.oracle.com/forums/thread.jspa?threadID=2217874&start=0&tstart=0 (If you want to store "n" myEntities in Payload, this post can help).
If you are familiar with bindings, then once you create EJB, simply create a DataControl for that EJB Local interface. This will create all methods you defined like save, get, update, delete etc etc. Drag and drop them on the taskDetails page and create ui components for them like Table etc. Edit the generated code with your column names etc. For any parameters to these methods, set them in managed bean invoke these data control actions by getting those bindings and using like execute methods.
I hope the above should put you in some direction. Just note that, it needs a decent adf knowledge unless you want to write native sql code to talk to db tables.