Hi all - I’ve created a Form for editing a generic HashMap (which holds configuration properties for our application. We cannot use a Bean because the configuration will vary and the names of the properties aren’t known so we can’t create getters and setters.
I’ve created our own PropertySet and PropertyDefinition classes which seem to work fine. When I first construct the form, it dynamically reads the propertyset and populates the form.
So envision this - on the left side of the page, there is a list of available configurations, and on the right side, all of the fields that the configuration contains. When I first construct the page, the right side is populated with the propertyset of the first configuration on the list.
Following the tutorial (which uses Beans however), I’ve created a method to update the binder whenever a different configuration is selected on the left. The method is definitely being invoked, and we call binder.setBean(T) with the properly selected T, but then nothing happens. The fields on the right still show the values from the first configuration. And none of the log messages from our PropertySet are invoked, e.g. no getGetter or getSetter is called.
Here are some snippets from the code (ACO is short for App Config Object):
In the form constructor:
ACOPropertySet propertySet = new ACOPropertySet(aco);
binder = Binder.withPropertySet(propertySet);
VerticalLayout fieldsLayout = new VerticalLayout();
... iterate through the propertyset and add textfields for every property {
TextField c = new TextField(provider.getParameterName());
fieldsLayout.add(c);
binder.bind((HasValue<?, ?>) c, provider.getParameterName());
}
Then, the method that gets invoked when a new config is selected, which is definitely being invoked:
public void setAppConfigObject(AppConfigObject aco) {
this.aco = aco;
binder.setBean(aco);
if (aco != null)
logger.debug("Setting selected ACO to {}", aco.getName());
else
logger.debug("Deselecting any ACO");
}
At some point, again just trying to follow the tutorial, I added this to the constructor but it didn’t have any effect, which I presume is correct since I’m not using a Bean anyway:
binder.bindInstanceFields(fieldsLayout);
Any advice appreciated!