Wiki source code of Wiki based components
Last modified by Vincent Massol on 2024/11/19 16:12
Show last authors
| author | version | line-number | content |
|---|---|---|---|
| 1 | {{include document="XWiki.DesignClassSheet"/}} | ||
| 2 | |||
| 3 | = Goal = | ||
| 4 | |||
| 5 | Be able to implements any component in a wiki page like we implement wiki macro in a wiki page. | ||
| 6 | |||
| 7 | Prototype in contrib's sandbox : http://svn.xwiki.org/svnroot/xwiki/contrib/sandbox/xwiki-wiki-components/ | ||
| 8 | |||
| 9 | = Descriptor = | ||
| 10 | |||
| 11 | == ComponentClass (1 object) == | ||
| 12 | |||
| 13 | Indicate the page is a component. | ||
| 14 | |||
| 15 | * implemented role | ||
| 16 | * role hint | ||
| 17 | |||
| 18 | == ComponentRequirementClass (several objects) == | ||
| 19 | |||
| 20 | Indicate which components the page require | ||
| 21 | |||
| 22 | * role | ||
| 23 | * role hint | ||
| 24 | * binding name | ||
| 25 | * type (single, list, map) | ||
| 26 | |||
| 27 | == ComponentMethod (several objects) == | ||
| 28 | |||
| 29 | Describe one method of the component, that's the tricky part. This object contains the actual implementation of the method (like wiki macro object contains the implementation of Macro#execute component method). | ||
| 30 | |||
| 31 | * method name | ||
| 32 | * method implementation | ||
| 33 | |||
| 34 | A method is not more than input and output so the idea is to have something like: | ||
| 35 | |||
| 36 | {{code}} | ||
| 37 | {{velocity}} | ||
| 38 | #set($param1 = $xcontext.method.input.1) | ||
| 39 | $xcontext.method.output.returnValue("return first param ${param} as string") | ||
| 40 | {{/velocity}} | ||
| 41 | {{/code}} | ||
| 42 | |||
| 43 | If {{code}}$xcontext.method.output.returnValue(){{/code}} as not been called rendering the resulting XDOM with plain/1.0 renderer and return it if the return type is a string. | ||
| 44 | |||
| 45 | Access to an equivalent of ##this## is made available through the binding ##xcontext.method.component##. | ||
| 46 | |||
| 47 | = Implementation = | ||
| 48 | |||
| 49 | Use a proxy to implement the component role and execute proper wiki content for each method. |