I am using ISIS 1.16.2 for a project at work and struggling with attachments and some related issues. I hope, you can help me (at least for a subset of my issues).
Context: My item classes need to store an arbitrary number of attachments (Blobs and/or Clobs).
From the example for one attachment:
@Persistent(defaultFetchGroup = "false",
columns = { @Column(name = "attachment_name"),
@Column(name = "attachment_mimetype"),
@Column(name = "attachment_bytes",
jdbcType = "BLOB",
sqlType = "LONGVARBINARY")
})
@Column(allowsNull = "true")
private Blob attachment;
First approach for multiple attachments:
@javax.jdo.annotations.Persistent(???)
@org.apache.isis.applib.annotation.Property(
domainEvent = AttachmentDomainEvent.class,
optionality = Optionality.OPTIONAL,
hidden = Where.ALL_TABLES)
@org.apache.isis.applib.annotation.Collection
@lombok.Getter
private List<Blob> attachments = new LinkedList<>();
@Action public void uploadFiles(List<Blob> files) {...}
Maybe a bit off-topic but related to the problem above:
List<Blob> attachments;
(see above), I get ??? EntityModel objectAdapter oid: null
for each attachment in the table because the Blob/Clob classes are value types instead of reference types. What is the "right" way to provide the necessary information to render these value types correctly? (I have the same issue with enum sets)Thanks in advance!
Ans 1: It isn't possible to store a List<Blob>
as a single property. Instead, you'll need to define an entity, call it something like Document
, and let it have a single Blob
. You can then have a List<Document>
. That might seem like more work (it is, I suppose), but you'll probably have some metadata that you want to store about those Blob
s anyway. In effect, the Blob
becomes an entity rather than a value.
Ans 2: not supported, see previous answer.
Ans 3: no, it doesn't. I think it would be possible to implement something like this (I see that Wicket 7 has a widget [1] to support it), so raise a ticket on the Apache Isis JIRA.
Ans 4: this is what an entity such as Document
(as per ans. 1) would let you do. You can still provide a download action, this would be a regular action on the Document
... just return the Blob
as the return type of the action and it'll be downloaded. Also, if by any chance these blobs you are storing are PDFs, then check out the pdfjs viewer [2] from the incode platform.