add/remove row not working in ListTableContentProvider

I’m using Designer 7.1 to create task view. I have an array in my TaskData. I create a ListTableContentProvider off the array, then bind the contentprovider to a table. And then add the Add/Remove Row buttons to the table. I confirmed RowVariable, RowBindingId, RowType, etc are set properly. I confirmed data get updated when I hit “Submit” task. That tells me the binding is done correctly. Add/Remove works fine on client-side. But when I hit “Submit”, rows are NOT added/removed to/from the array in the taskdata.

However, when the data is a java.util.List. Everything works fine. When data is Object, add/remove row does not work.

Did i miss something ?
thanks

Yes there is some important difference between using java.util.ArrayList and native java array. The difference is that arrays in java are immutable and in order to add/remove an item from an array a new array object has to be created.

In order to implement add/remove with array you need to follow this pattern:

  • Do not use data binding to specify source array for ListTableContentProvider, instead assign source array in the initialize() dataflow available on each page bean. This needs to be done so old array does not override a new array object each time provider is accessed
  • When you need to use the new array with added/removed rows (e.g. submitting a task or something). Use data binding to bind array to be consumed from ListTableContentProvider or re-assign array property directly in the dataflow action from provider to your task data

Also please take a look at the wm_coreproviderstest sample available from http://www.ajax-softwareag.com which demonstrates use case like this

Thanks for the response.

I’m working on the TaskView Page. The array is part of the java object autogenerated from an IS document.

I looked at the wm_coreprovider example. It wouldn’t work in my example because initialize() only run once. So when I go from one task to another task in INBOX, the data is stale from the initial array copy.

Here is what I tried:

  1. in the autogenerated java object (IS document), I manually created a list (member variable). In the list’s getter, I load the list with whatever in the array.
  2. create ListTableContentProvider from this list.
  3. when I “submit” or “complete” task, I copy the list back into the array.

This works fine… except for one situation:
When the initial array in the java object is empty (or null). The table appears to be empty (which is correct). When I click the “Add Row” icon, it creates a row on the page. But when I submit, the table goes back to empty. Then I create the row one more time and submit, it’s fine.

The 1st time I submit, i notice listcontentprovider.getRowCount()=0 while the table.getContentProvider().getRowCount()=1. So the listcontentprovider seems to be incorrect when the list is initially empty.

Any suggestion what else I can do ?
Thanks !

I’ve tried the solution posted on the page but I can’t make it work with the List binding. Is there something else I should tae care?

I’ve just replaced the bindin from array to list. type, variable and ID are the same.

The underlying list doesn’t get modified.

Thank in advance