Viewing Task Attachments

This post relates to the custom BPM worklist sample presented in this blog.

In this post, we will look at how to add support for viewing a list of the attachments for a Human Task.

You may recall from the post on creating the domain layer that we created a wrapper to simplify access to the Human Task object.  In that wrapper class,, we had a property called attachments which is a java.util.List of the attachments.

Attachments are represented by the BPM API class (see Javadoc here.)

We can add the following code into our view, src/main/webapp/WEB-INF/jsp/taskdetails.jsp, to display information about each attachment.  Here we are displaying three pieces of information about each attachment:

  • ${attachment.updatedBy} is the user who last updated (or created) the attachment,
  • ${attachment.updatedDate.time} is the time the attachment was last updated (or created), and
  • ${} is the name of the attachment, most likely this would be the filename, although attachments can also be URLs rather than files.

We also want to display a link to allow the user to download the attachment.  We are making the name into the link.  The link is constructed as follows:${model.task.number}&x_file=${}&x_version=${attachment.version}

We are passing the task number, the attachment name and version to a new  downloadattachment controller.  We will see this controller in the next post.

Here is the code we added to the view:

  <table width="50%">
      <th class="tl-head" width="150">User</th>
      <th class="tl-head" width="200">Date</th>
      <th class="th-head">Name</th>
  <table width="50%">
    <c:forEach items="${model.task.attachments}" var="attachment">
        <td class="tl-row" width="150">${attachment.updatedBy}</td>
        <td class="tl-row" width="200">${attachment.updatedDate.time}</td>
        <td class="tl-row">
          <a href="${model.task.number}&x_file=${}&x_version=${attachment.version}"

That’s all we need to view a list of the attachments!  In the next post we will look at how to allow the user to download (open/save) an attachment.


About Mark Nelson

Mark Nelson is an Architect in the Enterprise Cloud-Native Java Team at Oracle. Mark works mainly on making Java (traditional and microservices) easy to use in Kubernetes and the CNCF ecosystem. Before joining this team, Mark worked on Wercker, WebLogic and was a senior member of the A-Team since 2010, and worked in Sales Consulting at Oracle since 2006 and various roles at IBM since 1994.
This entry was posted in Uncategorized and tagged , , . Bookmark the permalink.

Leave a Reply

Please log in using one of these methods to post your comment: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s