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, com.oracle.ateam.domain.MTask, we had a property called attachments which is a java.util.List of the attachments.

Attachments are represented by the BPM API class oracle.bpel.services.workflow.task.model.Attachment (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
  • ${attachment.name} 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:


downloadattachment.do?x_tasknumber=${model.task.number}&x_file=${attachment.name}&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:


  <h2>Attachments</h2>
  <table width="50%">
    <tr>
      <th class="tl-head" width="150">User</th>
      <th class="tl-head" width="200">Date</th>
      <th class="th-head">Name</th>
    </tr>
  </table>
  <table width="50%">
    <c:forEach items="${model.task.attachments}" var="attachment">
      <tr>
        <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="downloadattachment.do?x_tasknumber=${model.task.number}&x_file=${attachment.name}&x_version=${attachment.version}"
             target="_blank">${attachment.name}</a>
        </td>
      </tr>
    </c:forEach>
  </table>

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 (an "IC6") in the Fusion Middleware Central Development Team at Oracle. Mark's job is to make Fusion Middleware easy to use in the cloud and at home, for developers and operations folks, with special focus on continuous delivery, configuration management and provisioning - making it simple to manage the configuration of complex environments and applications built with Oracle Database, Fusion Middleware and Fusion Applications, on-premise and in the cloud. Before joining this team, Mark 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:

WordPress.com Logo

You are commenting using your WordPress.com 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 )

Google+ photo

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

Connecting to %s