Build better business applications, faster. No more juggling REST endpoints or deciphering GraphQL queries. Hilla seamlessly connects Spring Boot and React to accelerate application development.
When creating a form for an entity with an N-to-one relatated entity that is represented by its id, I want the field() directive to support this case so that creating a form is as simple as when the related entity is referenced by an object reference.
Example (of the hack that is needed with Vaadin 19):
@Data
public class SnippetProjectDto {
@Nullable
private UUID snippetId;
@Nullable
private UUID projectId;
}
<vaadin-combo-box
label="Project"
id="project"
...="${field(this.snippetProjectBinder.model.projectId)}"
.items="${store.projectNames}"
></vaadin-combo-box>
...
await this.snippetProjectBinder.submitTo( entity => {
// hack: because object-comboboxes seem not to work yet, we must map the
// caption to the id:
if(entity.projectId) {
const project = store.projectByName(entity.projectId);
if(project) {
entity.projectId = project.id;
entity.snippetId = snippet.id;
SnippetProjectEndpoint.update(entity);
}
}
return new Promise((resolve) => { resolve(entity); });
} );
Expected
Note: the TBD part in the field() directive. There should be some API to tell the binder whether it should use the selectedItem or the value property of the combo-box. The default in V19 is selectedItem (see ComboBoxFieldStrategy)
When creating a form for an entity with an N-to-one relatated entity that is represented by its id, I want the
field()
directive to support this case so that creating a form is as simple as when the related entity is referenced by an object reference.Example (of the hack that is needed with Vaadin 19):
Expected Note: the TBD part in the
field()
directive. There should be some API to tell the binder whether it should use theselectedItem
or thevalue
property of the combo-box. The default in V19 isselectedItem
(seeComboBoxFieldStrategy
)