| Summary: | [Client] Define a minimal JavaScript API for custom widgets | ||
|---|---|---|---|
| Product: | [RT] RAP | Reporter: | Ralf Sternberg <rsternberg> |
| Component: | RWT | Assignee: | Project Inbox <rap-inbox> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | enhancement | ||
| Priority: | P3 | CC: | jens.borrmann, mknauer, rsternberg, stefan.roeck, tbuschto |
| Version: | 1.4 | ||
| Target Milestone: | 2.0 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | plan-version=1.4 plan-theme=widgets plan-status=committed | ||
| Bug Depends on: | 311355 | ||
| Bug Blocks: | |||
|
Description
Ralf Sternberg
Generally one needs to know 2-4 static methods to create a simple custom widget, plus the API of 2-3 objects (adapter, serverObject and the parent). All of this already exists in some form, but it might be a good idea to create a simple facade to group the static methods. These are: * rwt.protocol.AdapterRegistry.add -> registering the widget * rwt.protocol.ServerObjectFactory.getServerObject -> get ServerObject to send messages to the Server * rwt.protocol.AdapterUtil.callWithTarget -> required to attach to the parent widget * rwt.protocol.ObjectRegistry.getObject -> required if an protocol-id is to be send to the server as a parameter The "callWithTarget" and "getObject" methods may not be needed if we somehow solve their usecases within the adapter/serverObject. Since a custom widget should be based on dom-elements, (not extending any internal widgets), we also need a way to add those to a parent. The most simple way would be to modify Parent.js#add to accept html elements, but we could also try to find a solution that also eliminates callWithTarget. The facade could be placed either within our normal namespace-objects (rwt.*), or be a global object like "rap". I don't want to abuse the objects we use as a namespace and place functions in there. The serverObject API might also need to be discussed. There are some details i'm currently not happy with. A provisional API has been introduced with commit 749aed413a290955d3f0e91a7974333baaf190b6. A first draft for an API reference and custom widget tutorial can be found here: https://github.com/tbuschto/customWidgetTemplate/wiki/_pages We could use jsdoc (http://code.google.com/p/jsdoc-toolkit/) to generate an API reference at least for the "rap" object and possibly for the RemoteObject. Not sure if/how it could work for the protocol-adapter/type-handler interface. I tried it, and it works very well for me. Example: /** * @namespace Holds all public API of the RAP WebClient. */ rap = { /** * @description Used to register RAP type handler * @param {String} type * @param {Object} handler */ registerTypeHandler : function( type, handler ) { .... Added JsDoc for rap.js and ServerObject.js with commit 395bea5e5b41fadae1918ff8d64ce0f9d0ed958c. With RAP 2.0, a minimal JS API has been published: http://download.eclipse.org/rt/rap/doc/2.0/guide/reference/jsdoc/index.html |