I've just checked in some experimental improvements to the Woody Flowscript API and an associated sample. Because the changes are not backward compatible I've placed the files in a new package.

The idea is to try to remove the duplication present in the current API in two places:

1) The original JavaScript wrapper of the Woody widget exposed very limited functionality. As a result someone chose to also expose the Java Widget objects directly. The new ScriptableWidget should be able to support all of the functionality of the Java objects (and more) allowing us to remove this duplication.
2) Since the JavaScript wrapper's of the widgets are full-fledged JavaScript objects you can assign additional properties (not found in the form definition) to them which can then be accessed in your pipeline (e.g. in JXTemplate's). In addition, you can access the widgets themselves more easily via this wrapper, i.e. instead of


#{getWidget(getWidget(form, 'foo'), 'bar'))}

you can do

#{form/foo/bar}

Therefore I've removed the additional "bizData" argument from showForm() (which seemed like an another unnecessary duplication)

Here is a summary:

1) All widgets are fully modelled. Previously leaf-nodes in the widget tree were treated as simple values (String, Number, etc). Leaf widgets like Field's now have a 'value' property to assign or access their values.
2) Initialization of complex widgets is possible.
3) I added some basic support for event handling (onClick() for Action's and onChange() for fields). I know Sylvain intentionally chose not to follow this approach (and instead to place the event handlers in the form definition) but there is an advantage to having these in the flowscript: namely that you have access to the rest of your application data there. In addition, using the new API it is quite easy to add and remove repeater rows and to set event handlers on them (see the sample).
4) You can programatically set validation errors on widgets, via the setValidationError() function.
5) You can set selection lists on widgets via the setSelectionList() function.
6) The implementation of showForm() uses a "bookmark" continuation to implement the validation loop (instead of a while loop). The sample takes advantage of this to implement a multipage form with a back button (in a hackish way, but hopefully you'll get the idea).


Here are some of the problems:
1) Locale handling is broken at the moment
2) Event handling seems a bit flaky (not sure why...)
3) I didn't support Choice/Union/Class (because I don't really know how to use them yet).
4) I didn't experiment with or test the Binding stuff but just left it the same as before.


Note this is not intended to be a final solution, but rather to just to spur discussion and hopefully progress toward a better API for Woody.

Regards,

Chris

Reply via email to