|
| 1 | +# Custom Components |
| 2 | + |
| 3 | +The [Imixs Form Specification](forms.html) defines a set of |
| 4 | +[standard input types](forms-input-types.html) that every conforming implementation must support. |
| 5 | +Beyond these, any application built on Imixs-Workflow can define and register its own |
| 6 | +**custom components** — without modifying the BPMN model structure or the workflow engine itself. |
| 7 | + |
| 8 | +This extensibility is by design. The specification defines two levels at which custom |
| 9 | +components can be introduced: |
| 10 | + |
| 11 | +- **Custom Item** — a single input field rendered by a custom component |
| 12 | +- **Custom Section** — an entire form section rendered by a custom component |
| 13 | + |
| 14 | +In both cases the workflow engine stores the XML as-is and plays no role in rendering. |
| 15 | +The application resolves the custom component at runtime. |
| 16 | + |
| 17 | +--- |
| 18 | + |
| 19 | +## Custom Items |
| 20 | + |
| 21 | +A custom item replaces a single `<item>` with an application-specific input component. |
| 22 | +It is defined by setting `type="custom"` and adding a `path` attribute that identifies |
| 23 | +the component: |
| 24 | + |
| 25 | +```xml |
| 26 | +<imixs-form-section label="Request"> |
| 27 | + <item name="request.text" type="custom" path="markdowneditor" label="Request:" /> |
| 28 | +</imixs-form-section> |
| 29 | +``` |
| 30 | + |
| 31 | +### Attributes |
| 32 | + |
| 33 | +| Attribute | Type | Mandatory | Description | |
| 34 | +| ---------- | ------- | --------- | ----------------------------------------------------------- | |
| 35 | +| `type` | text | ✓ | Must be `custom` | |
| 36 | +| `path` | text | ✓ | Identifies the custom component to be rendered | |
| 37 | +| `name` | text | ✓ | The item name in the workitem (same as for standard types) | |
| 38 | +| `label` | text | | Optional visible label (same as for standard types) | |
| 39 | +| `readonly` | boolean | | Optional, renders the component as read-only | |
| 40 | +| `options` | text | | Optional configuration string, interpreted by the component | |
| 41 | + |
| 42 | +The `path` value is application-specific. How it is resolved — whether as a file path, |
| 43 | +a component name, a CDI bean identifier, or any other mechanism — depends entirely on the |
| 44 | +rendering implementation. |
| 45 | + |
| 46 | +### Responsibilities |
| 47 | + |
| 48 | +A custom item component is responsible for: |
| 49 | + |
| 50 | +1. **Rendering** an appropriate UI element for the given `name` and `path` |
| 51 | +2. **Reading** the current value from the workitem item identified by `name` |
| 52 | +3. **Writing** the user's input back to the workitem item identified by `name` |
| 53 | + |
| 54 | +The data type stored in the workitem is defined by the custom component itself, not by |
| 55 | +this specification. |
| 56 | + |
| 57 | +### Example: Markdown Editor |
| 58 | + |
| 59 | +```xml |
| 60 | +<item name="request.body" type="custom" path="markdowneditor" label="Request:" /> |
| 61 | +``` |
| 62 | + |
| 63 | +### Example: Custom Component with Options |
| 64 | + |
| 65 | +The `options` attribute can pass configuration to the component. |
| 66 | +Its format and interpretation are entirely up to the component: |
| 67 | + |
| 68 | +```xml |
| 69 | +<item name="product.image" type="custom" path="imageupload" |
| 70 | + label="Product Image:" options="maxsize=2MB;accept=image/png,image/jpeg" /> |
| 71 | +``` |
| 72 | + |
| 73 | +--- |
| 74 | + |
| 75 | +## Custom Sections |
| 76 | + |
| 77 | +A custom section replaces an entire `<imixs-form-section>` with an application-specific |
| 78 | +component. This is useful for complex form areas that go beyond what individual items |
| 79 | +can express — for example sections with conditional visibility, dynamic content, |
| 80 | +or multiple interacting fields. |
| 81 | + |
| 82 | +A custom section is defined by adding a `path` attribute directly to the |
| 83 | +`<imixs-form-section>` element. It contains no `<item>` children: |
| 84 | + |
| 85 | +```xml |
| 86 | +<imixs-form-section label="References" path="sub_references_form" /> |
| 87 | +``` |
| 88 | + |
| 89 | +### Attributes |
| 90 | + |
| 91 | +| Attribute | Type | Mandatory | Description | |
| 92 | +| ---------- | ------- | --------- | ------------------------------------------------------------------ | |
| 93 | +| `path` | text | ✓ | Identifies the custom section component to be rendered | |
| 94 | +| `label` | text | | Optional visible heading for the section | |
| 95 | +| `readonly` | boolean | | Optional, signals to the component that it should render read-only | |
| 96 | + |
| 97 | +### Responsibilities |
| 98 | + |
| 99 | +A custom section component takes full control over its rendering area. It is responsible for: |
| 100 | + |
| 101 | +1. **Rendering** the complete section UI for the given `path` |
| 102 | +2. **Reading and writing** workitem data directly, using whatever item names it requires |
| 103 | +3. **Respecting the `readonly` attribute** when provided |
| 104 | + |
| 105 | +A custom section may implement any interaction pattern supported by the host application, |
| 106 | +including dynamic updates and interdependent fields. The details of that interaction |
| 107 | +are outside the scope of this specification and are defined by the application. |
| 108 | + |
| 109 | +--- |
| 110 | + |
| 111 | +## Implementing Custom Components in Your Application |
| 112 | + |
| 113 | +How custom components are implemented depends on the technology stack of the application. |
| 114 | +The following projects provide documented extension mechanisms: |
| 115 | + |
| 116 | +- **Imixs-Office-Workflow** — supports custom items and custom sections via Jakarta Faces |
| 117 | + composite components. See the |
| 118 | + [Custom Input Parts](https://doc.office-workflow.com/forms/parts-custom.html) |
| 119 | + documentation for a step-by-step guide. |
| 120 | + |
| 121 | +- **Imixs-Forms (JavaScript)** — custom types can be registered as JavaScript modules |
| 122 | + at application startup. See the |
| 123 | + [Imixs-Forms repository](https://github.com/imixs/imixs-forms) for details. |
| 124 | + |
| 125 | +If you are building your own application on top of Imixs-Workflow, you are free to define |
| 126 | +your own resolution mechanism for the `path` attribute. The only contract this specification |
| 127 | +defines is the XML structure of the `<item>` and `<imixs-form-section>` elements. |
| 128 | + |
| 129 | +--- |
| 130 | + |
| 131 | +## Portability Considerations |
| 132 | + |
| 133 | +Because custom components are application-specific, form definitions that use `type="custom"` |
| 134 | +or a `path` on a section are not fully portable across different implementations. |
| 135 | +When sharing BPMN models between applications, keep the following in mind: |
| 136 | + |
| 137 | +- Standard types (`text`, `date`, `currency`, etc.) are always portable. |
| 138 | +- Custom items and sections are only rendered correctly by applications that have the |
| 139 | + referenced component registered under the same `path` name. |
| 140 | +- If a rendering application encounters an unknown `path`, it should degrade gracefully — |
| 141 | + for example by rendering a plain text input or skipping the section entirely. |
| 142 | + |
| 143 | +This is not a limitation but a deliberate trade-off: it allows each application to build |
| 144 | +rich, domain-specific form components while keeping the core specification lean and stable. |
0 commit comments