timleh
(Tim Lehmkuhl)
April 10, 2025, 2:12pm
1
Hi everyone,
I recently created a GitHub issue regarding a problem with uploading Word (DOCX) templates in Jmix Reports.
Problem Summary
After uploading a new Word template to an existing report and trying to download it again later, the resulting DOCX file appears to be corrupted and cannot be opened in Microsoft Word.
Temporary Workaround
To temporarily fix the issue, I’ve overridden the initTemplateEditor method in ReportTemplateDetailView and commented out the following code:
// templateFileEditor.addValueChangeListener(e -> {
// reportTemplate.setContent(e.getValue().getBytes(StandardCharsets.UTF_8));
// });
With this change, uploading and downloading DOCX templates seems to work again.
Question
This workaround seems to solve the problem for now, but I assume it might lead to side effects elsewhere. Is there a cleaner or recommended workaround until a fix is provided in the framework?
Thanks in advance!
Edit:
Maybe that is more correct?
...
if (hasHtmlCsvTemplateOutput(outputType)) {
String templateContent = new String(reportTemplate.getContent(), StandardCharsets.UTF_8);
templateFileEditor.setValue(templateContent);
templateFileEditor.addValueChangeListener(e -> {
reportTemplate.setContent(e.getValue().getBytes(StandardCharsets.UTF_8));
});
}
...
informatica
(Ajuntament Canals)
April 15, 2025, 8:25am
3
Hi,
Any news about this issue ? All our reports doesn’t work in JMIX 2.5.1
Thanks,
timleh
(Tim Lehmkuhl)
April 15, 2025, 3:42pm
4
Hi, i just override the method like this:
@Route(value = "reports/templates/ext:id", layout = DefaultMainViewParent.class)
@ViewController(id = "report_ReportTemplate.detail")
@ViewDescriptor(path = "ext-report-template-detail-view.xml")
public class ExtReportTemplateDetailView extends ReportTemplateDetailView {
@Override
protected void initTemplateEditor(ReportTemplate reportTemplate) {
String extension = FilenameUtils.getExtension(templateUploadField.getFileName());
if (extension == null) {
visibleTemplateEditor(null);
return;
}
ReportOutputType outputType = ReportOutputType.getTypeFromExtension(extension.toUpperCase());
visibleTemplateEditor(outputType);
if (hasHtmlCsvTemplateOutput(outputType)) {
String templateContent = new String(reportTemplate.getContent(), StandardCharsets.UTF_8);
templateFileEditor.setValue(templateContent);
templateFileEditor.addValueChangeListener(e -> {
reportTemplate.setContent(e.getValue().getBytes(StandardCharsets.UTF_8));
});
}
templateFileEditor.setReadOnly(
!secureOperations.isEntityUpdatePermitted(metadata.getClass(reportTemplate), policyStore));
templateFileEditor.setMode(getCodeEditorMode(reportTemplate));
}
}
Seems to work.
shchienko
(Nikita Schienko)
April 16, 2025, 6:16am
5
Hello @timleh ,
Thank you for the detailed description of the problem. Yes, the bug was introduced in the last update. We will fix the problem in the next release.
Workaround :
You can override the method in ReportTemplateDetailView:
protected void initTemplateEditor(ReportTemplate reportTemplate) {
String extension = FilenameUtils.getExtension(templateUploadField.getFileName());
if (extension == null) {
visibleTemplateEditor(null);
return;
}
ReportOutputType outputType = ReportOutputType.getTypeFromExtension(extension.toUpperCase());
visibleTemplateEditor(outputType);
if (hasHtmlCsvTemplateOutput(outputType)) {
String templateContent = new String(reportTemplate.getContent(), StandardCharsets.UTF_8);
templateFileEditor.setValue(templateContent);
}
templateFileEditor.setReadOnly(
!secureOperations.isEntityUpdatePermitted(metadata.getClass(reportTemplate), policyStore));
// templateFileEditor.addValueChangeListener(e -> {
// reportTemplate.setContent(e.getValue().getBytes(StandardCharsets.UTF_8));
// });
templateFileEditor.setMode(getCodeEditorMode(reportTemplate));
}
Regards,
Nikita Shchienko
1 Like
informatica
(Ajuntament Canals)
April 18, 2025, 10:21am
7
Hi,
Where is ReportTemplateDetailView code ?
Thanks,
Hi Konstantin,
We have the same problem in jmix 1.5
What is the solution (workaround) for 1.5?
shchienko
(Nikita Schienko)
May 16, 2025, 1:15pm
10
Hello @mile.simic1 ,
This issue occurs in Jmix version 2.5.1. It is related to the commit:
committed 07:20PM - 23 Mar 25 UTC
In version 1.5, these changes were not made.
Regards,
Nikita
krivopustov
(Konstantin Krivopustov)
May 19, 2025, 5:52am
12
Hi Mile,
Thank you for the clarification. We’ll check this.
Regards,
Konstantin
Hi Mile,
Problem was reproduced on version 1.7-RC. Ticket was issued: Unreadable content in DOCX report · Issue #4445 · jmix-framework/jmix
Thank you!
Regards,
Igor
pinyazhin
(Roman Pinyazhin)
June 9, 2025, 2:08pm
16