I created a dialog and ran into 2 issues
- if you use InputParameter.fileParamer()… I found no option to set the maximum filesize so I had to resort to using a custom parameter
- if you use a custom parameter. the .withRequired(true) on the Inputparameter is
ignored, instead you have to have an extra setRequired(true) on the field declaration. No idea if this could be improved but it was misleading.
dialogs.createInputDialog(this)
.withHeader("Import theoretical maintenance schedule as .csv")
.withParameters(
InputParameter.stringParameter("name").withLabel("Name").withRequired(true),
InputParameter.parameter("file")
.withRequired(true) // IGNORED
.withLabel("File")
.withField(() -> {
FileUploadField field = uiComponents.create(FileUploadField.class);
field.setAcceptedFileTypes(".csv");
field.setMaxFileSize(TWENTY_MEGABYTE);
field.setRequired(true); // WORKING
return field;
})
)