home *** CD-ROM | disk | FTP | other *** search
/ Chip 2005 May / CMCD0505.ISO / Software / Shareware / Programare / bugzero / jsp / view.jsp < prev   
Text File  |  2004-12-30  |  4KB  |  118 lines

  1. <%@ page 
  2.     import="com.websina.bean.*,com.websina.util.*,com.websina.util.log.Log"
  3. %>
  4. <html>
  5. <head>
  6. <title>View and Print</title>
  7. </head>
  8. <body topmargin=0>
  9. <%@ include file="_header.jspf" %>
  10. <%      
  11.   String issueStr = request.getParameter("entryId");
  12.   int entryId = 0;
  13.   try {
  14.     entryId = StringUtil.toInt(issueStr);
  15.   } catch (NumberFormatException e) {
  16.     String msg = MessageCode.get("number.format_error_issue");
  17.     msg = StringUtil.replace(msg, issueStr);
  18.     out.print("<center><font color=red><b>");
  19.     out.print(msg);
  20.     out.print("</b></font></center>");
  21.     return;
  22.   }
  23.   if (!person.viewAllowed(entryId)) {
  24.     String msg = MessageCode.get("servlet.issue.permission_error");
  25.     out.print("<center><font color=red><b>");
  26.     out.print(msg);
  27.     out.print("</b></font></center>");
  28.     return;
  29.   }
  30.  
  31.   String projectId = person.getProject();
  32.   Project conf = Project.getInstance(projectId);
  33.   String group = person.getGroup();
  34.   com.websina.util.Field field;
  35.   String[] fields = conf.getFields();
  36.   Issue issue = null;
  37.   String useCache = request.getParameter("useCache");
  38.   try {
  39.     if (useCache != null) {
  40.       issue = (Issue)session.getAttribute("issue");
  41.     }
  42.     if (issue == null || issue.getId() != entryId) {
  43.       issue = Issue.load(projectId, entryId);
  44.       session.setAttribute("issue", issue);
  45.     }
  46.   } catch (Exception e) {
  47.     if (e instanceof InfoException) {
  48.       Log.info(e.getMessage());
  49.     } else {
  50.       Log.error(e);
  51.     }
  52.     String _error = e.getMessage();
  53.     if (_error == null) {
  54.       _error = "A runtime error occurred, check log for detail";
  55.     }
  56.     out.print("<center><font color=red><b>");
  57.     out.print(_error);
  58.     out.print("</b></font></center>");
  59.     return;
  60.   }
  61.   String indexParam = "";
  62.   String idxStr = request.getParameter("index");
  63.   if (idxStr != null && idxStr.trim().length() > 0) {
  64.     try {
  65.       int idx = -1;
  66.       idx = Integer.parseInt(idxStr.trim());
  67.       if (idx != -1) {
  68.         indexParam = "&index=" + idx;
  69.       }
  70.     } catch (Exception e) {}
  71.   }
  72. %>
  73. <% String msg = request.getParameter("msg");
  74.    if (msg != null) { %>
  75. <center><font color=red><b><%=msg%></b></font></center>
  76. <% } %>
  77.  
  78. <center>
  79. <p>
  80. <table cellspacing=1 cellpadding=2 border=0>
  81.   <tr><td colspan=2> 
  82.   <%=label.get("entryId", projectId)%> <font color=red><b><%=entryId%></b></font>
  83. <% if (person.saveAllowed(entryId)) { %>
  84.   <input class="button" type="button" value="<%=label.get("edit_button")%>" 
  85. onClick="location.href='edit.jsp?projectId=<%=projectId%>&entryId=<%=entryId + indexParam%>&useCache=1';">
  86. <% } %>
  87.   </td></tr>
  88.   <tr class="header"><td colspan=2> 
  89.   </td></tr>
  90. <% for (int ix=0; ix<fields.length; ix++) {
  91.      String fieldName = fields[ix];
  92.      if (conf.isFieldEnabled(fieldName, group) && (field = conf.getField(fieldName)) != null) {
  93.        String field_name = label.get(fieldName, projectId);
  94.        String field_value = null;
  95.        if (fieldName.equals("attachment")
  96.           || fieldName.equals("detail")
  97.           || fieldName.equals("cc_mail")
  98.           || fieldName.equals("author") 
  99.           || fieldName.equals("responsible")) {
  100.          continue;
  101.        } else if (field.isURLField()) {
  102.          field_value = issue.getLink(fieldName);
  103.        } else if (field.isTextAreaField()) {
  104.          field_value = HtmlParser.toHtml(issue.get(fieldName));
  105.        } else {
  106.          field_value = HtmlParser.escapeTag(issue.getDisplay(fieldName));
  107.        }
  108. %>
  109.   <tr><td class="e8" valign=top><%=field_name%>  </td>
  110.   <td class="f1"><%=field_value%></td></tr>
  111. <% }} %>
  112. </table>
  113. </center>
  114.  
  115. <%@ include file="_trail.jspf" %>
  116.  
  117. </body></html>
  118.