home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Chip 2005 May
/
CMCD0505.ISO
/
Software
/
Shareware
/
Programare
/
bugzero
/
jsp
/
view.jsp
< prev
Wrap
Text File
|
2004-12-30
|
4KB
|
118 lines
<%@ page
import="com.websina.bean.*,com.websina.util.*,com.websina.util.log.Log"
%>
<html>
<head>
<title>View and Print</title>
</head>
<body topmargin=0>
<%@ include file="_header.jspf" %>
<%
String issueStr = request.getParameter("entryId");
int entryId = 0;
try {
entryId = StringUtil.toInt(issueStr);
} catch (NumberFormatException e) {
String msg = MessageCode.get("number.format_error_issue");
msg = StringUtil.replace(msg, issueStr);
out.print("<center><font color=red><b>");
out.print(msg);
out.print("</b></font></center>");
return;
}
if (!person.viewAllowed(entryId)) {
String msg = MessageCode.get("servlet.issue.permission_error");
out.print("<center><font color=red><b>");
out.print(msg);
out.print("</b></font></center>");
return;
}
String projectId = person.getProject();
Project conf = Project.getInstance(projectId);
String group = person.getGroup();
com.websina.util.Field field;
String[] fields = conf.getFields();
Issue issue = null;
String useCache = request.getParameter("useCache");
try {
if (useCache != null) {
issue = (Issue)session.getAttribute("issue");
}
if (issue == null || issue.getId() != entryId) {
issue = Issue.load(projectId, entryId);
session.setAttribute("issue", issue);
}
} catch (Exception e) {
if (e instanceof InfoException) {
Log.info(e.getMessage());
} else {
Log.error(e);
}
String _error = e.getMessage();
if (_error == null) {
_error = "A runtime error occurred, check log for detail";
}
out.print("<center><font color=red><b>");
out.print(_error);
out.print("</b></font></center>");
return;
}
String indexParam = "";
String idxStr = request.getParameter("index");
if (idxStr != null && idxStr.trim().length() > 0) {
try {
int idx = -1;
idx = Integer.parseInt(idxStr.trim());
if (idx != -1) {
indexParam = "&index=" + idx;
}
} catch (Exception e) {}
}
%>
<% String msg = request.getParameter("msg");
if (msg != null) { %>
<center><font color=red><b><%=msg%></b></font></center>
<% } %>
<center>
<p>
<table cellspacing=1 cellpadding=2 border=0>
<tr><td colspan=2>
<%=label.get("entryId", projectId)%> <font color=red><b><%=entryId%></b></font>
<% if (person.saveAllowed(entryId)) { %>
<input class="button" type="button" value="<%=label.get("edit_button")%>"
onClick="location.href='edit.jsp?projectId=<%=projectId%>&entryId=<%=entryId + indexParam%>&useCache=1';">
<% } %>
</td></tr>
<tr class="header"><td colspan=2>
</td></tr>
<% for (int ix=0; ix<fields.length; ix++) {
String fieldName = fields[ix];
if (conf.isFieldEnabled(fieldName, group) && (field = conf.getField(fieldName)) != null) {
String field_name = label.get(fieldName, projectId);
String field_value = null;
if (fieldName.equals("attachment")
|| fieldName.equals("detail")
|| fieldName.equals("cc_mail")
|| fieldName.equals("author")
|| fieldName.equals("responsible")) {
continue;
} else if (field.isURLField()) {
field_value = issue.getLink(fieldName);
} else if (field.isTextAreaField()) {
field_value = HtmlParser.toHtml(issue.get(fieldName));
} else {
field_value = HtmlParser.escapeTag(issue.getDisplay(fieldName));
}
%>
<tr><td class="e8" valign=top><%=field_name%> </td>
<td class="f1"><%=field_value%></td></tr>
<% }} %>
</table>
</center>
<%@ include file="_trail.jspf" %>
</body></html>