Hi Alejandro This component is a real time saver. Thank you for contributi

Hi Alejandro

This component is a real time saver.
Thank you for contributing!

I am having a small visual issue with the form.
My entity contains a property of type Date.
To be able to present it properly I’ve added a property of type LocalDate.
For this type, I can use the LocalDateRenderer.
I assume, the idea is to use LocalDate in favor of Date?

However for the form, I supplied a Converter of type Converter<String, LocalDate> to be able to display the date in a user friendly format.
The problem is, that this converter never gets called.
A Map of Converters is contained in CrudFormConfiguration, but I don’t see these converters being read.

My converter looks like this:

crud.getCrudFormFactory().setConverter("dayLoc", new Converter<String, LocalDate>() {
	@Override
	public Result<LocalDate> convertToModel(String value, ValueContext context) {
		return Result.ok(MyUtil.parse2LocDate(value));
	}
	@Override
	public String convertToPresentation(LocalDate value, ValueContext context) {
		return  MyUtil.dayformat().format(value);
	}
});

I am using Vaadin 14.0.12 and crudui 4.1.0.

Are you able to help out?

Hi,

The add-on works out-of-the-box with LocalDate. It shows a DatePicker in the forms. Not sure what’s your usecase, though.

Hi,

In the grid, the format for the “dayLoc” column is set with

grid.addColumn(new LocalDateRenderer<>(BOMeeting::getDayLoc, "YYYY-MM-dd"));

I would like to use the same format in the form, but what I get is displayed in dayLocFormat.png.

17978982.png

You are setting a renderer on the Grid. For the input field you can use something like:
formFactory.setFieldCreationListener("birthDate", field -> ((DateField) field).setDateFormat("yyyy-MM-dd"));

Your hint solved my problem. I just had to adapt the code a bit:

formFactory.setFieldCreationListener("dayLoc", field -> 
	((DatePicker) field).setLocale(Locale.GERMANY)
);

Thank you for helping out!

Nice. And thank you for sharing your code!