Crud UI Add-on

Лешик ツ:
How add own render?
For example I have field instant

If you mean a column renderer in a Grid component, you can add it as follows:

crud.getGrid().getColumn("theColumn").setRenderer(...);

Deepak Chainani:
Hello Alejandro,

I am using the Hibernate Validation to validate my UI fields. The built-in validations and custom field level validations are working perfectly fine. For one of the requirements I have created a custom class level validator but it does not seem to be working as expected. I have followed the steps as mentioned in the http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-class-level-constraints

I feel the validator class is not getting invoked. Can you please help me in this regards?

Hi, If V8, it’s a known issue. Please upvote it here: https://github.com/vaadin/framework/issues/8498

Alejandro Duarte:

Лешик ツ:
How add own render?
For example I have field instant

If you mean a column renderer in a Grid component, you can add it as follows:

crud.getGrid().getColumn("theColumn").setRenderer(...);

No I mean DefaultCrudFormFactory

DefaultCrudFormFactory<AdminEntity> defaultCrudFormFactory = getDefaultCrudFormFactory();
defaultCrudFormFactory.setVisibleProperties(AdminEntity.FIELD_ID,
		AdminEntity.FIELD_LOGIN,
		AdminEntity.FIELD_PASSWORD,
		AdminEntity.FIELD_EMAIL,
		AdminEntity.FIELD_ADMIN_ROLE,
		AdminEntity.FIELD_CREATED,
		AdminEntity.FIELD_ACTIVE);

AdminEntity.FIELD_CREATED is instant field and don’t show on DefaultCrudFormFactory

[https://github.com/alejandro-du/crudui]
(https://github.com/alejandro-du/crudui)

crud.getGrid().setColumns("name", "birthDate", "email", "mainGroup", "active");
crud.getGrid().getColumn("mainGroup").setRenderer(group -> group == null ? "" : ((Group) group).getName(), new TextRenderer());
crud.getGrid().getColumn("mainGroup.name").setHeaderCaption("Main group");

Is it actual&
There aren’t getColumn and setRenderer

Is DefaultCrudFormFactory support Upload component?

Alejandro Duarte:

Deepak Chainani:
Hello Alejandro,

I am using the Hibernate Validation to validate my UI fields. The built-in validations and custom field level validations are working perfectly fine. For one of the requirements I have created a custom class level validator but it does not seem to be working as expected. I have followed the steps as mentioned in the http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-class-level-constraints

I feel the validator class is not getting invoked. Can you please help me in this regards?

Hi, If V8, it’s a known issue. Please upvote it here: https://github.com/vaadin/framework/issues/8498

I am using Vaadin v10,

Hi Alejandro, your advices worked great ! ( i’m using Vaadin 8, next step will be implement V10… :slight_smile: )
A little question: to introduce non bean-linked objects into the form, like custom buttons,what do you suggest ?
I thinked to extend the form factory classes, do you think there’s a better way with your Add On ?
Thanks in advance

One last thing.
Should form fields labels be responsive ? When displayed on a smaller screen they can be showed superimposed while fields are correctly resized.
Many thanks.

Alejandro, please forgive my new request.
How do you suggest to return data ( a bean ) back from a crud add-on view to a caller view ?
Thank you in advance.

Hi Alejandro,

How to fix the number of columns of the form?
I want to have 3 columns to edit/create my bean.
Thanks,

Another question:
should be possible to visually group some of the formfactory fields together ?
In that case , what do you suggest to achieve it , by css, components …
Thank you.

Alejandro Duarte:
Viktor, the DefaultFieldProvider works only with LocalDate since DatePicker doesn’t support time selection. You can use a custom FieldProvider to build any field you want for a property:

formFactory.setFieldProvider("groups", () -> {
    CheckBoxGroup<Group> checkboxes = new CheckBoxGroup<>("Groups", groups);
    checkboxes.setItemCaptionGenerator(Group::getName);
    return checkboxes;
});

Can you give small example how use LocalDateTime and providers?

Hello Alejandro,

For one of my requirement, in the CRUD Form Layout I have a couple ComboBoxProviders added and few text boxes. As per the requirement while selecting a value from the one of the ComboBox I wish to disable 2 text fields and if the value again is changed for the combo box I need to again enable the text boxes.

I tried the following code with component ComboBox instead of the ComboBoxProvider:

gridData.getCrudFormFactory().setFieldProvider(WebGuiConstants.REPAY_DEDUCTION_TYPE_FLD, () -> {
			ComboBox<AdvanceDeductionType> comboBox = new ComboBox<>(WebGuiConstants.REPAY_DEDUCTION_TYPE_FLD,
					Arrays.asList(AdvanceDeductionType.values()));
			comboBox.addValueChangeListener(event -> {
				if (event.getSource().isEmpty()) {
					gridData.getCrudFormFactory().setDisabledProperties("");
					return;
				} else
					switch (event.getValue()) {
					case EMI:
						gridData.getCrudFormFactory().setDisabledProperties("");
						break;
					case ONETIME:
						gridData.getCrudFormFactory().setDisabledProperties("repayDeductionTerm",
								"fixedDeductionAmount");
						break;

					}
			});
			return comboBox;
		});

Please help me with sample code for the same.

How can setDisabledProperties be managed in real time?
For example, if userDto.isDemo, then make several fields unavailable

Лешик ツ:
How can setDisabledProperties be managed in real time?
For example, if userDto.isDemo, then make several fields unavailable

Nobody faced such a problem?

Лешик ツ:
AdminEntity.FIELD_CREATED is instant field and don’t show on DefaultCrudFormFactory

You can use the formFactory.setFieldProvider method to return an instance of any field you want.

Лешик ツ:
There aren’t getColumn and setRenderer

In Vaadin 10+ you have to use crud.getGrid().getColumnByKey("theColumn")

Лешик ツ:
Is DefaultCrudFormFactory support Upload component?

I’m affraid not.

Deepak Chainani:

Alejandro Duarte:

Deepak Chainani:
Hello Alejandro,

I am using the Hibernate Validation to validate my UI fields. The built-in validations and custom field level validations are working perfectly fine. For one of the requirements I have created a custom class level validator but it does not seem to be working as expected. I have followed the steps as mentioned in the http://docs.jboss.org/hibernate/stable/validator/reference/en-US/html_single/#section-class-level-constraints

I feel the validator class is not getting invoked. Can you please help me in this regards?

Hi, If V8, it’s a known issue. Please upvote it here: https://github.com/vaadin/framework/issues/8498

I am using Vaadin v10,

Can you please check if this is also an issue in Vaadin 10+? Thanks!

Gianluigi Ferraris:
Hi Alejandro, your advices worked great ! ( i’m using Vaadin 8, next step will be implement V10… :slight_smile: )
A little question: to introduce non bean-linked objects into the form, like custom buttons,what do you suggest ?
I thinked to extend the form factory classes, do you think there’s a better way with your Add On ?
Thanks in advance

Extending or implementing your own CrudFormFactory could be a way to achieve this.

Gianluigi Ferraris:
One last thing.
Should form fields labels be responsive ? When displayed on a smaller screen they can be showed superimposed while fields are correctly resized.
Many thanks.

I think they are in the version for Vaadin 10, since it uses FormLayout which is responsive. They are unfortunatelly not responsive in previous versions of the add-on.

Gianluigi Ferraris:
Alejandro, please forgive my new request.
How do you suggest to return data ( a bean ) back from a crud add-on view to a caller view ?
Thank you in advance.

If what you mean is getting the row selected in the grid, you can use crud.getGrid().asSingleSelect().getValue().