CommandExecuteIn 后台抛出 "Not an (encodable) value" 错误

CommandExecuteIn Background throws a "Not an (encodable) value" error

我目前正在尝试在后台实现文件导出,以便用户可以在文件下载时执行一些操作。

我使用了 apache isis CommandExexuteIn:Background 操作属性。但是,我收到一个错误 "Not an (encodable) value",这是 ScalarValueRenderer class.

抛出的错误

我的方法是这样的:

@Action(semantics = SemanticsOf.SAFE,
        command = CommandReification.ENABLED)
        commandExecuteIn =  CommandExecuteIn.BACKGROUND)
public Blob exportViewAsPdf() {
    final Contact contact = this;
    final String filename = this.businessName + " Contact Details";

    final Map<String, Object> parameters = new HashMap<>();
    parameters.put("contact", contact);

    final String template = templateLoader.buildFromTemplate(Contact.class, "ContactViewTemplate", parameters);
    return pdfExporter.exportAsPdf(filename, template);
}

我认为该错误与实际上未调用操作的命令有关,而是 return 持久化的后台命令。

此实现实际上适用于没有 return 类型的方法。我错过了什么?或者有没有办法实现后台命令并得到预期的结果?

有趣的用例,但它不是我在实施框架的那部分时预料到的,所以我对它不起作用并不感到惊讶。显然你在这里得到的错误信息很模糊,所以我提出了一个 JIRA ticket 看看我们是否至少可以改进一下。

我想知道您认为该框架应该提供什么样的用户体验?

Estatio application that we work on (that has driven out many of the features added to the framework over the last few years) we have a somewhat similar requirement to obtain PDFs from a reporting server (which takes 5 to 10 seconds) and then download them. This is for all the tenants in a shopping centre, so there could be 5 to 50 of these to generate in a single go. The design we went with was to move the rendering into a background command (similar to the templateLoader.buildFromTemplate(...) and pdfExporter.exportAsPdf(...) method calls in your code fragment, and to capture the output as a Document, via the document module. We then use the pdfbox addon 中将所有文档 PDF 拼接在一起作为一个可下载的 PDF 进行打印。

希望这能为您提供一些支持用例的不同方式的想法

谢谢 旦