Hi,
I need help with the sorting of the column 'Next Stage' see below; the way to get the results in the colum is:
String nextStage = item.getNextStage().getStageTemplate().getDescription();
<%
String systemStr = request.getParameter("systemId");
String taskStr = request.getParameter("taskId");
String incCompleted = request.getParameter("incCompleted");
String sortOrder = request.getParameter("sortOrder");
String isAsc = request.getParameter("isAscending");
DecimalFormat roundPercentage = new DecimalFormat("0");
int systemId;
int itemTypeId = 0;
int completed = 0;
if(systemStr != null) {
systemId = Integer.parseInt(systemStr);
} else {
// select the users home system.
systemId = theUser.getSystemId();
}
if(taskStr != null) {
itemTypeId = Integer.parseInt(taskStr);
}
if(incCompleted != null) {
completed = Integer.parseInt(incCompleted);
}
if (sortOrder == null)
{
sortOrder = "itemType.DESCRIPTION";
}
if (isAsc == null)
{
isAsc = "true";
}
Criteria cr = new Criteria();
cr.addJoin(ItemPeer.SYSTEMID, SystemPeer.SYSTEMID);
cr.addJoin(ItemPeer.STAGEID, StagePeer.STAGEID);
cr.addJoin(StagePeer.STAGETEMPLATEID, StageTemplatePeer.STAGETEMPLATEID);
cr.addJoin(ItemPeer.ITEMTYPEID, ItemTypePeer.ITEMTYPEID);
if (systemId > 0)
{
cr.add(SystemPeer.SYSTEMID, systemId);
}
if (itemTypeId > 0)
{
cr.add(ItemPeer.ITEMTYPEID, itemTypeId);
}
if (completed == 0)
{
cr.add(ItemPeer.NEXTSTAGEID, 0, Criteria.GREATER_THAN);
}
if ("true".equals(isAsc)) {
cr.addAscendingOrderByColumn(sortOrder);
}
else {
cr.addDescendingOrderByColumn(sortOrder);
}
List items = ItemPeer.doSelect(cr);
String btnDown = "<img border=\"0\" src=\"buttons/btn_down_white.gif\">";
String btnUp = "<img border=\"0\" src=\"buttons/btn_up_white.gif\">";
String urlPrefix = "?taskId=" + itemTypeId + "&systemId=" + systemId + "&";
TableHeadFormat th = new TableHeadFormat("tableheads", "wlink", urlPrefix, btnDown, btnUp, isAsc, sortOrder);
%>
<html>
<BODY bgColor=#c0c0c0 leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<h2 class=pageheads>Interactive Completion Report</h2>
<form name="f1" action="completionsChart.jsp" method="get">
<table width=80% bgcolor=white border=1 cellspacing=0 cellpadding=6 align=center>
<tr>
<%= th.format(ItemTypePeer.DESCRIPTION, "Item Type") %>
<%= th.format(SystemPeer.NAME, "System") %>
<%= th.format(ItemPeer.JTD, "JTD") %>
<%= th.format(ItemPeer.TAG, "Tag") %>
<%= th.format(StageTemplatePeer.DESCRIPTION, "Status") %>
<th class=tableheads nowrap>Next Stage</th>
<th class=tableheads nowrap>% Complete</th>
<th class=tableheads nowrap>Bar Graph</th>
</tr>
<%
Iterator i = items.iterator();
ArrayList nextStageList = new ArrayList();
while(i.hasNext()) {
double pc;
Item item = (Item) i.next();
if(item.getNextStage().getStageId() == Stage.DONE) {
pc = 100.0;
}
else {
int done = item.getHistory().size();
int total = item.getItemType().getStages().size();
pc = 100.0 * done / total;
}
String nextStage = item.getNextStage().getStageTemplate().getDescription();
nextStageList.add(nextStage);
session.setAttribute("nextStageList", nextStageList);
%>
<tr>
<td class=columnwhite><%=item.getItemType().getDescription()%></td>
<td class=columnwhite><%=item.getSystem().getName()%></td>
<td class=columnwhite><%=item.getJtd()%></td>
<td class=columnwhite><%=item.getTag()%></td>
<td class=columnwhite><%=item.getStage().getStageTemplate().getDescription()%></td>
<td class=columnwhite><%=nextStage%></td>
<td class=columnwhite><%=roundPercentage.format(pc)%>%</td>
<td class=columnwhite width="75">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #000000;">
<tr>
<% if (pc > 0.00001) {%>
<td width="<%=pc%>%"><img src="images/bargrph_blue.gif" width="100%" height="10"></td>
<%}%>
<% if (pc < 100.00000) {%>
<td bgcolor="#CCCCFF"><img src="images/bargrph_spacer.gif" width="1" height="10"></td>
<%}%>
</tr>
</table>
</td>
</tr>
<%
}
%>
<input type=hidden name=nextStageList value="<%= nextStageList %>">
</TABLE>
</form>
Can anybody help? or direct me where to get help?
Thanks
vero
I need help with the sorting of the column 'Next Stage' see below; the way to get the results in the colum is:
String nextStage = item.getNextStage().getStageTemplate().getDescription();
<%
String systemStr = request.getParameter("systemId");
String taskStr = request.getParameter("taskId");
String incCompleted = request.getParameter("incCompleted");
String sortOrder = request.getParameter("sortOrder");
String isAsc = request.getParameter("isAscending");
DecimalFormat roundPercentage = new DecimalFormat("0");
int systemId;
int itemTypeId = 0;
int completed = 0;
if(systemStr != null) {
systemId = Integer.parseInt(systemStr);
} else {
// select the users home system.
systemId = theUser.getSystemId();
}
if(taskStr != null) {
itemTypeId = Integer.parseInt(taskStr);
}
if(incCompleted != null) {
completed = Integer.parseInt(incCompleted);
}
if (sortOrder == null)
{
sortOrder = "itemType.DESCRIPTION";
}
if (isAsc == null)
{
isAsc = "true";
}
Criteria cr = new Criteria();
cr.addJoin(ItemPeer.SYSTEMID, SystemPeer.SYSTEMID);
cr.addJoin(ItemPeer.STAGEID, StagePeer.STAGEID);
cr.addJoin(StagePeer.STAGETEMPLATEID, StageTemplatePeer.STAGETEMPLATEID);
cr.addJoin(ItemPeer.ITEMTYPEID, ItemTypePeer.ITEMTYPEID);
if (systemId > 0)
{
cr.add(SystemPeer.SYSTEMID, systemId);
}
if (itemTypeId > 0)
{
cr.add(ItemPeer.ITEMTYPEID, itemTypeId);
}
if (completed == 0)
{
cr.add(ItemPeer.NEXTSTAGEID, 0, Criteria.GREATER_THAN);
}
if ("true".equals(isAsc)) {
cr.addAscendingOrderByColumn(sortOrder);
}
else {
cr.addDescendingOrderByColumn(sortOrder);
}
List items = ItemPeer.doSelect(cr);
String btnDown = "<img border=\"0\" src=\"buttons/btn_down_white.gif\">";
String btnUp = "<img border=\"0\" src=\"buttons/btn_up_white.gif\">";
String urlPrefix = "?taskId=" + itemTypeId + "&systemId=" + systemId + "&";
TableHeadFormat th = new TableHeadFormat("tableheads", "wlink", urlPrefix, btnDown, btnUp, isAsc, sortOrder);
%>
<html>
<BODY bgColor=#c0c0c0 leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<h2 class=pageheads>Interactive Completion Report</h2>
<form name="f1" action="completionsChart.jsp" method="get">
<table width=80% bgcolor=white border=1 cellspacing=0 cellpadding=6 align=center>
<tr>
<%= th.format(ItemTypePeer.DESCRIPTION, "Item Type") %>
<%= th.format(SystemPeer.NAME, "System") %>
<%= th.format(ItemPeer.JTD, "JTD") %>
<%= th.format(ItemPeer.TAG, "Tag") %>
<%= th.format(StageTemplatePeer.DESCRIPTION, "Status") %>
<th class=tableheads nowrap>Next Stage</th>
<th class=tableheads nowrap>% Complete</th>
<th class=tableheads nowrap>Bar Graph</th>
</tr>
<%
Iterator i = items.iterator();
ArrayList nextStageList = new ArrayList();
while(i.hasNext()) {
double pc;
Item item = (Item) i.next();
if(item.getNextStage().getStageId() == Stage.DONE) {
pc = 100.0;
}
else {
int done = item.getHistory().size();
int total = item.getItemType().getStages().size();
pc = 100.0 * done / total;
}
String nextStage = item.getNextStage().getStageTemplate().getDescription();
nextStageList.add(nextStage);
session.setAttribute("nextStageList", nextStageList);
%>
<tr>
<td class=columnwhite><%=item.getItemType().getDescription()%></td>
<td class=columnwhite><%=item.getSystem().getName()%></td>
<td class=columnwhite><%=item.getJtd()%></td>
<td class=columnwhite><%=item.getTag()%></td>
<td class=columnwhite><%=item.getStage().getStageTemplate().getDescription()%></td>
<td class=columnwhite><%=nextStage%></td>
<td class=columnwhite><%=roundPercentage.format(pc)%>%</td>
<td class=columnwhite width="75">
<table width="100%" border="0" cellspacing="0" cellpadding="0" style="border:1px solid #000000;">
<tr>
<% if (pc > 0.00001) {%>
<td width="<%=pc%>%"><img src="images/bargrph_blue.gif" width="100%" height="10"></td>
<%}%>
<% if (pc < 100.00000) {%>
<td bgcolor="#CCCCFF"><img src="images/bargrph_spacer.gif" width="1" height="10"></td>
<%}%>
</tr>
</table>
</td>
</tr>
<%
}
%>
<input type=hidden name=nextStageList value="<%= nextStageList %>">
</TABLE>
</form>
Can anybody help? or direct me where to get help?
Thanks
vero