Single task

The view/singleTask page (for example view/singleTask?taskId=2) is built in a similar way than the tasksList page, without requiring new definitions in the sitemap.

Shown below are the singleTask-specific portions of our code. Refer to the taskList page for the corresponding sitemap excerpts.

Flowscript query and display methods

These methods query the java objects and call the appropriate pipeline for display:

0020 // Query a single TaskBean object and display it
0021 function query_singleTask() {
0022    id = cocoon.request.getParameter("taskId");
0023    bean = db.getTaskBeanById(id);
0024    displayTaskBean(id,bean);
0025 }
...
0038 // Display a single TaskBean
0039 function displayTaskBean(id,bean) {
0040    cocoon.sendPage("internal/generate-view/singleTask", {
0041        title : "Task #" + id,
0042        task : bean,
0043        selectedTaskId : id
0044    });
0045 }
            

Note that no error checking is done, for example for a missing taskId parameter. This would obviously be needed in a production application.

JXTemplate page

<page id="page">
<title> #{title} </title>
<content>
<h2> Task info </h2>
<table>
<tr>
<td class="legend"> Task ID </td>
<td> #{task/id} </td>
</tr>
<tr>
<td class="legend"> Task name </td>
<td class="titleCell"> #{task/taskName} </td>
</tr>
<tr>
<td class="legend"> Assigned to </td>
<td> #{task/assignedTo} </td>
</tr>
</table>
<p>
<a href="../edit/singleTask?taskId=#{task/id}"> Edit this task </a>
</p>
<h2> Comments </h2>
<table>
<tr>
<c:forEach select="#{task/comments}">
<tr class="listRow">
<td>
<c:formatDate value="#{date}" dateStyle="medium"/>
</td>
<td> #{comment} </td>
</tr>
</c:forEach>
</tr>
</table>
<p class="footer">
<a href="../view/allTasks"> Back to the list of tasks </a>
</p>
</content>
</page>