Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow to use custom field provider not by property name but by property type #47

Closed
flozano opened this issue May 22, 2023 · 3 comments
Closed

Comments

@flozano
Copy link

flozano commented May 22, 2023

I would like to centralize making all columns of a given type to be handled in a specific way. Currently it's allowed to set values for specific properties, only.

in AbstractAutoGeneratedCrudFormFactory:

    protected HasValueAndElement buildField(CrudFormConfiguration configuration, String property, Class<?> propertyType, T domainObject) throws InstantiationException, IllegalAccessException {
        HasValueAndElement<?, ?> field;
        FieldProvider<?, T> provider = (FieldProvider<?, T>) configuration.getFieldProviders().get(property);

        if (provider != null) {
            field = provider.buildField(domainObject);
        } else {
            Class<? extends HasValueAndElement<?, ?>> fieldType = configuration.getFieldTypes().get(property);
            if (fieldType != null) {
                field = fieldType.newInstance();
            } else {
                field = new DefaultFieldProvider(propertyType).buildField(domainObject);
            }
        }

it would be great if it was possible to override

                field = new DefaultFieldProvider(propertyType).buildField(domainObject);

by changing
new DefaultFieldProvider(propertyType) to a new method getFieldProvider(propertyType) and make it overridable.

Or, is there any other better way to achieve this?

@samie
Copy link
Member

samie commented May 22, 2023

Hi @flozano! I think this is related to crud-ui-add-on by @alejandro-du
https://github.com/alejandro-du/crudui and should in that repo?

@flozano
Copy link
Author

flozano commented May 22, 2023

🤦 I blindly clicked on the directory "report issues" here:
https://vaadin.com/directory/component/crud-ui-add-on

I'm sorry for the mistake!
feel free to close.
image

@samie
Copy link
Member

samie commented May 23, 2023

No problem. You just pointed out that it is misleading. I created an enhancement issue #48 for that.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants