0 votes
1.7k views
in Coach Views by
I tried to bind a complex object, a list of strings , but I always catch an error in the browser.

1 Answer

0 votes
by (30.6k points)

A coach table needs a list of business objects (one object per row) - a list of String or a single complex object is exactly what raises the browser error you see. Steps for BPM 8.5.6 with the UI Toolkit (Spark) or the Coaches toolkit table:

  1. Create a business object for the row, e.g. OrderLine { item: String, qty: Integer, price: Decimal }.
  2. Declare the variable as tw.local.lines = list of OrderLine (tick "Is list") and initialise it (default, or a script before the coach).
  3. Drag the variable onto the coach - BPM creates a Table bound to tw.local.lines with one column per field; or drag a Table control and set its binding to the list, then add columns bound to currentItem.item etc.
// script before the coach (server or client side): initialise the list with data
tw.local.lines = new tw.object.listOf.OrderLine();
var l = new tw.object.OrderLine(); l.item = "Widget"; l.qty = 3; l.price = 9.5;
tw.local.lines.insertIntoList(tw.local.lines.listLength, l);

// a list of strings can be shown too - wrap each string in an object
tw.local.rows = new tw.object.listOf.NameValuePair();      // System Data has NameValuePair {name, value}
for (var i = 0; i < tw.local.names.listLength; i++) { var nv = new tw.object.NameValuePair(); nv.name = tw.local.names[i]; tw.local.rows.insertIntoList(i, nv); }

Common causes of the browser error on 8.5.6: binding the table to a non-list, binding a column to the list instead of currentItem.field, a column control whose type does not match the field (Integer control on a String), and nested lists in cells (not supported by the OOB table - use a custom view). The Coaches toolkit "Table" (Dojo) and the Spark "Table" differ in look, but both need the list-of-BO binding. On 8.5.7+ use the UI Toolkit table; it also gives sorting, paging and inline editing.

References

Related questions

0 votes
1 answer 1.9k views
0 votes
1 answer 1.7k views
0 votes
1 answer 1.2k views
0 votes
1 answer 2.2k views
0 votes
1 answer 1.7k views
0 votes
1 answer 1.0k views
0 votes
1 answer 2.1k views
0 votes
1 answer 1.4k views
0 votes
1 answer 1.3k views
0 votes
1 answer 2.5k views
0 votes
1 answer 3.0k views
0 votes
1 answer 798 views
0 votes
2 answers 4.7k views

723 questions

807 answers

98 comments

4.9k users

Join BPM Community Discord Channel

Welcome to BPM Tips Q&A, Community wiki/forum where you can ask questions and receive answers from other IBM BPM experts and members of the community. Users with 2000 points will automatically be promoted to expert level.
Created by Dosvak LLC
Our Youtube Channel
...