Skip to content

Auto filling HTML select elements fails on certain conditions #2

@poshjosh

Description

@poshjosh

Background

HTML select elements are auto filled by checking for dependents of previously filled elements.
For example if a form contains both a Category and a Subcategory input, and the Subcategory
entity has a relationship with the Category entity, then when a Category option is selected
in the HTML form, the Subcategory input is automatically populated by running query of
the form SELECT * FROM Subcategory WHERE Category = ?.

The above logic is handled by com.looseboxes.webform.form.DependentsProviderImpl.

Dependents were not appropriately provided as expected.

Problem

For com.looseboxes.webform.form.DependentsProviderImpl to execute the necessary query,
form inputs are often converted from String to the appropriate type using logic of format.

DomainTypeConverter converter;
if(converter.isConvertible(String.class, propertyClass)) {
    converter.convert(propertyValue, String.class, propertyClass);
}

converter.isConvertible from the above code returns false when true is expected.

Temporary Solution

We are manually converting. If the value is a number type, we assume it represents
the ordinal of an enum/ID of an entity and we attempt to use the value to find the
corresponding enum/entity.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions