All JSP code in a work item viewer must be inserted within the <USER_WORKITEM_AREA> tags.
This jspworkitem1.jsp example file echoes all of the properties as HTML input types.
<HTML>
<TM_WORKITEMVIEWER_VERSION>2.0</TM_WORKITEMVIEWER_VERSION>
<head>
<title>EPX’s TaskManager</title>
<TM_WORKITEMVIEWER_SCRIPT>
</TM_WORKITEMVIEWER_SCRIPT>
<USER_WORKITEMVIEWER_SCRIPT>
<script language="JavaScript">
<!--
//Intercept the return key event. If you need to process this
// event you should make sure the function kpress always
// returns a false value.
if (document.layers)
document.captureEvents(Event.KEYPRESS);
document.onkeypress=kpress;
function kpress(evt)
{
key=(document.layers)?evt.which:window.event.keyCode;
if(document.layers && key==13)
return false;
else if (key==13 && window.event.srcElement.type=="text")
return false;
}
function validateForm(action)
{
var passedValidation = true;
if (passedValidation == true)
{
return true;
}
else
{
return false;
}
}
-->
</script>
</USER_WORKITEMVIEWER_SCRIPT>
</head>
<body>
<TM_WIV_HEADER>
<table cellspacing="0" cellpadding="0" border="0" width="100%">
<tr><td align="left" valign="top" bgcolor="#383B70"><center>
<font size="5" color="#ffffff">
Work Item: <i>Work Item Name</i> | Priority: <i>Priority Name</i>
</font></center></td></tr></table>
</TM_WIV_HEADER>
<form name="WorkItemForm" action="oldAction" method="oldMethod" >
<USER_WORKITEM_AREA>
<!-- user area -->
<%@ page import="com.xacta.client.servlets.api.*,com.xacta.shared.util.ViewerU til;" %>
<%
java.lang.String sessionId =
request.getParameter("sessionid");
java.lang.String workitemId =
request.getParameter("wi_id");
StringBuffer outBuf = new StringBuffer();
// The Client properties of the given work item version
outBuf.append(" <table border=\"1\" cellpadding=\"2\"
cellspacing=\"0\" width=\"100%\"> ");
outBuf.append(
"<caption><strong> The Client Properties
</strong></caption>");
outBuf.append(" <th bgcolor=\"#CCCCFF\">Key</th>
<th bgcolor=\"#CCCCFF\">Value</th>" );
java.util.Properties wiProps =
TaskManagerAPI.getWorkItemProps(
sessionId, workitemId, true, false );
if ( wiProps != null && wiProps.size() > 0 )
{
String curKey = "";
String curVal = "";
java.util.Iterator sortedPropertyNamesIterator =
TaskManagerAPI.getSortedPropertyKeyList(wiProps)
.iterator();
while ( sortedPropertyNamesIterator.hasNext() )
{
curKey =
(String) sortedPropertyNamesIterator.next();
curVal = (String) wiProps.getProperty( curKey );
// text field – editable
outBuf.append( "<tr><td align=\"left\" >" );
outBuf.append( curKey );
outBuf.append( "</td><td align=\"left\" >" );
ViewerUtil.createFormInputTextField(
outBuf, curKey, curVal, 50, 60, true );
outBuf.append( "</td></tr>" );
outBuf.append( "\n" );}
}
else
{
// Add Some fields for testing 'poNumber'
outBuf.append( "<tr><td align=\"left\" >" );
outBuf.append( "Po Number" );
outBuf.append( "</td><td align=\"left\" >" );
ViewerUtil.createFormInputTextField(
outBuf, "poNumber", "", 50, 60, true );
outBuf.append( "</td></tr>" );
outBuf.append( "\n" );
// 'itemName'
outBuf.append( "<tr><td align=\"left\" >" );
outBuf.append( "Item Name" );
outBuf.append( "</td><td align=\"left\" >" );
ViewerUtil.createFormInputTextField(
outBuf, "itemName", "", 50, 60, true );
outBuf.append( "</td></tr>" );
outBuf.append( "\n" );
}
outBuf.append(" </table>" );
outBuf.append(" <p></p> " );
// The System properties of the given work item
// version
outBuf.append(" <table border=\"1\"
cellpadding=\"2\"
cellspacing=\"0\" width=\"100%\"> ");
outBuf.append("<caption><strong> The System Properties
</strong></caption>");
outBuf.append(" <th bgcolor=\"#CCCCFF\">Key</th>
<th bgcolor=\"#CCCCFF\">Value</th>" );
java.util.Properties wiSysProps =
TaskManagerAPI.getWorkItemSystemProps (
sessionId, workitemId );
if ( wiSysProps != null )
{
String sysKey = "";
String sysVal = "";
java.util.Iterator sortedSysPropertyNamesIterator
= TaskManagerAPI.getSortedPropertyKeyList
(wiSysProps).iterator();
while (
sortedSysPropertyNamesIterator.hasNext() )
{
sysKey = (String)
sortedSysPropertyNamesIterator.next();
sysVal = (String)
wiSysProps.getProperty( sysKey );
outBuf.append( "<tr bgColor=\"#EEEEEE\">
<td align=\"left\" >" );
outBuf.append( sysKey );
outBuf.append(
"</td><td align=\"left\" >" );
if ( sysVal == null || sysVal.equals( "" ) )
{
// fix browser's display-only field's
// display problem
sysVal = "<br/>";
}
ViewerUtil.createFormInputDisplayOnlyTextField
(outBuf,sysKey,sysVal);
outBuf.append( "</td></tr>" );
outBuf.append( "\n" );
}
}
outBuf.append(" </table>" );
String displayString = outBuf.toString();
outBuf = null;
%>
<%= displayString %>
<p></p>
<!-- user area -->
</USER_WORKITEM_AREA>
<!-- do not touch anything below this line -->
<TM_WIV_BUTTONS>
<hr align="left"/>
<center><table><tr>
<td><input type="submit" name="action" value="SEND"></input></td>
<td><input type="submit" name="action" value="SAVE"></input></td>
<td><input type="submit" name="action" value="CANCEL"></input></td>
</tr></table></center>
</TM_WIV_BUTTONS>
</form>
</body>
</HTML>