Best Practices from Oracle Development's A‑Team

Viewing Task Attachments

Mark Nelson


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.

Main Article

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:


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.

Be the first to comment

Comments ( 0 )
Please enter your name.Please provide a valid email address.Please enter a comment.CAPTCHA challenge response provided was incorrect. Please try again.Captcha

Recent Content