0 votes
649 views
in Coach Views by (30.6k points)

1 Answer

0 votes
by (30.6k points)

The Event configuration option type (BPM 8.5.7 / 8.6) lets a coach view expose named events that the person who places the view on a coach can wire with JavaScript - the way the UI Toolkit controls offer On click, On change, On row selected. Before it existed, a view could only fire its single boundary event or expect callers to monkey-patch functions.

  1. In the coach view: Configuration > add an option, type Event, name onSelected, description "fires with the selected item". Document in the option's description which variables the handler receives (the toolkit convention is me plus named arguments).
  2. In the view's code, fire it:
// coach view code (load handler or wherever the event happens)
var _this = this;
this.context.element.querySelector("ul").addEventListener("click", function (e) {
  var item = e.target.textContent;
  // call the handler text the coach author entered for the option "onSelected"
  var handler = _this.context.options.onSelected;                     // an Event option is exposed as a callable
  if (typeof handler === "function") handler({ item: item, me: _this });   // 8.6+: options.<event>(args) runs the coach author's script
});
  1. On the coach: select the view, in the Configuration tab the option shows as a script box: ${Details}.setData(item) - the author writes JavaScript that receives the arguments you passed (and me).

Under the hood the framework compiles the author's text into a function (the same machinery the UI Toolkit uses for eventON_CLICK). Compared with a boundary event: an Event option does not leave the coach, needs no diagram wiring, can pass data, and a view may have many of them; the boundary event is still the way to continue the CSHS flow (service calls, navigation).

References

Related questions

+1 vote
1 answer 2.3k views
0 votes
1 answer 1.9k views
0 votes
1 answer 1.3k views
0 votes
1 answer 1.9k views
0 votes
1 answer 3.3k views
0 votes
1 answer 3.1k views
0 votes
1 answer 1.3k views
0 votes
1 answer 1.1k views
0 votes
1 answer 2.4k views
0 votes
1 answer 2.0k views
0 votes
2 answers 3.2k views
0 votes
1 answer 1.2k 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
...