jmix-framework / jmix

Jmix framework
https://www.jmix.io
Apache License 2.0
486 stars 113 forks source link

Data binding for HTML components #3288

Open syncro opened 1 month ago

syncro commented 1 month ago

In some cases usage of flowui components can be not enough to fit developer's requirements and java-side data assignments to achieve simple display purposes may feel too verbose. So there should be a way to easily render context data into custom ui layout, e.g. to show label with localized field title or span with database entity field value.

Possible solutions:

  1. Add property attribute support for all or most-used and suitable html components, e.g. for container-like ones: span, div, label, headings, lists etc.

  2. Implement new component for data binded output or add data-binding to html/div componets only

glebfox commented 2 weeks ago

Option 1: Implement generic XML element aka wrapper for HTML components.

<htmlDataBinder dataContainer="usersDc" property="username">
    <span/>
</htmlDataBinder>

or

<htmlDataBinder dataContainer="usersDc">
    <span property="username"/>
    <div property="firstName"/>
</htmlDataBinder>

Option 2: Support dataContainer and property attributes for HTML components in XML only. Loader creates one-way data binding.

<span dataContainer="usersDc" property="username"/>

Both options assumes something like ReadOnlyDataBidner that creates one-way data binding for passed component.