vaadin / vaadin/framework

Binder.bindInstanceFields with BindingStrategy or BindingPredicate

Open
#8,462 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

candidate enhancement
Dominant language
Java
Stars
1.8k
Forks
717
Avg merge
2d 6h
Merged PRs (30d)
3

Description

Vaadin version: 8.0.0.beta2

There's a quite common pattern to name fields by appending some sort of field type indicator, for example one might want to bind User.name property to TextField named nameTextField. Currently no name resolution strategy is possible, so we're forced to sync property names with component names.

It should be fairly simple to introduce a notion of optional NameResolutionPredicate, for ex something as simple as below could do in most cases (prefix, ignorecase etc), for ex: this potentially buggy solution to the above:

Binder.bindInstanceFields(this).withBindingPredicate((fieldName, propertyName) -> fieldName.startsWith(propertyName));

and/or a full blown NameResolutionStrategy, to be able to specify more relaxed binding strategies.

Binder.bindInstanceFields(this).withBindingStrategy(ignoreFieldClassNameStrategy);

It would be great if one could specify Application wide defaults for the above.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the Binder.bindInstanceFields API and review how field and property names are currently matched. Evaluate the requested BindingPredicate, BindingStrategy, and application-wide defaults against the examples in the issue. Done means the chosen configuration supports alternate naming conventions and has coverage for the matching behavior.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
30/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.